1 11 package org.eclipse.ui.internal.presentations.util; 12 13 import java.util.Arrays ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.ui.IMemento; 18 import org.eclipse.ui.internal.IWorkbenchConstants; 19 import org.eclipse.ui.presentations.IPresentablePart; 20 import org.eclipse.ui.presentations.IPresentationSerializer; 21 22 25 public class LeftToRightTabOrder extends TabOrder { 26 27 private IPresentablePartList list; 28 29 public LeftToRightTabOrder(IPresentablePartList list) { 30 this.list = list; 31 } 32 33 36 public void add(IPresentablePart newPart) { 37 list.insert(newPart, list.size()); 38 } 39 40 43 public void addInitial(IPresentablePart newPart) { 44 add(newPart); 45 } 46 47 50 public void insert(IPresentablePart newPart, int index) { 51 list.insert(newPart, index); 52 } 53 54 57 public void remove(IPresentablePart removed) { 58 list.remove(removed); 59 } 60 61 64 public void select(IPresentablePart selected) { 65 list.select(selected); 66 } 67 68 71 public void move(IPresentablePart toMove, int newIndex) { 72 list.move(toMove, newIndex); 73 } 74 75 76 79 public IPresentablePart[] getPartList() { 80 return list.getPartList(); 81 } 82 83 89 public void restoreState(IPresentationSerializer serializer, 90 IMemento savedState) { 91 IMemento[] parts = savedState.getChildren(IWorkbenchConstants.TAG_PART); 92 93 for (int idx = 0; idx < parts.length; idx++) { 94 String id = parts[idx].getString(IWorkbenchConstants.TAG_ID); 95 96 if (id != null) { 97 IPresentablePart part = serializer.getPart(id); 98 99 if (part != null) { 100 addInitial(part); 101 } 102 } 103 } 104 } 105 106 109 public void saveState(IPresentationSerializer context, IMemento memento) { 110 111 List parts = Arrays.asList(list.getPartList()); 112 113 Iterator iter = parts.iterator(); 114 while (iter.hasNext()) { 115 IPresentablePart next = (IPresentablePart) iter.next(); 116 117 IMemento childMem = memento 118 .createChild(IWorkbenchConstants.TAG_PART); 119 childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next)); 120 } 121 } 122 } 123 | Popular Tags |