1 11 package org.eclipse.ui.internal; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.swt.graphics.Rectangle; 16 import org.eclipse.ui.IMemento; 17 18 22 public class DetachedPlaceHolder extends PartPlaceholder implements 23 ILayoutContainer { 24 ArrayList children = new ArrayList (); 25 26 Rectangle bounds; 27 28 33 public DetachedPlaceHolder(String id, Rectangle bounds) { 34 super(id); 35 this.bounds = bounds; 36 } 37 38 41 public void add(LayoutPart newPart) { 42 if (!(newPart instanceof PartPlaceholder)) { 43 return; 44 } 45 children.add(newPart); 46 } 47 48 55 public boolean allowsBorder() { 56 return false; 57 } 58 59 public Rectangle getBounds() { 60 return bounds; 61 } 62 63 66 public LayoutPart[] getChildren() { 67 LayoutPart result[] = new LayoutPart[children.size()]; 68 children.toArray(result); 69 return result; 70 } 71 72 75 public void remove(LayoutPart part) { 76 children.remove(part); 77 } 78 79 82 public void replace(LayoutPart oldPart, LayoutPart newPart) { 83 remove(oldPart); 84 add(newPart); 85 } 86 87 88 92 public void restoreState(IMemento memento) { 93 Integer bigInt; 95 bigInt = memento.getInteger(IWorkbenchConstants.TAG_X); 96 int x = bigInt.intValue(); 97 bigInt = memento.getInteger(IWorkbenchConstants.TAG_Y); 98 int y = bigInt.intValue(); 99 bigInt = memento.getInteger(IWorkbenchConstants.TAG_WIDTH); 100 int width = bigInt.intValue(); 101 bigInt = memento.getInteger(IWorkbenchConstants.TAG_HEIGHT); 102 int height = bigInt.intValue(); 103 104 bounds = new Rectangle(x, y, width, height); 105 106 IMemento childrenMem[] = memento 108 .getChildren(IWorkbenchConstants.TAG_VIEW); 109 for (int i = 0; i < childrenMem.length; i++) { 110 PartPlaceholder holder = new PartPlaceholder(childrenMem[i] 111 .getString(IWorkbenchConstants.TAG_ID)); 112 holder.setContainer(this); 113 children.add(holder); 114 } 115 } 116 117 121 public void saveState(IMemento memento) { 122 memento.putInteger(IWorkbenchConstants.TAG_X, bounds.x); 124 memento.putInteger(IWorkbenchConstants.TAG_Y, bounds.y); 125 memento.putInteger(IWorkbenchConstants.TAG_WIDTH, bounds.width); 126 memento.putInteger(IWorkbenchConstants.TAG_HEIGHT, bounds.height); 127 128 for (int i = 0; i < children.size(); i++) { 130 IMemento childMem = memento 131 .createChild(IWorkbenchConstants.TAG_VIEW); 132 LayoutPart child = (LayoutPart) children.get(i); 133 childMem.putString(IWorkbenchConstants.TAG_ID, child.getID()); 134 } 135 } 136 137 public void findSashes(LayoutPart part, PartPane.Sashes sashes) { 138 ILayoutContainer container = getContainer(); 139 140 if (container != null) { 141 container.findSashes(this, sashes); 142 } 143 } 144 145 148 public boolean allowsAutoFocus() { 149 return false; 150 } 151 } 152 | Popular Tags |