1 11 package org.eclipse.ui.presentations; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jface.util.Geometry; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.graphics.Point; 17 import org.eclipse.swt.graphics.Rectangle; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.ui.IMemento; 20 import org.eclipse.ui.ISizeProvider; 21 22 43 public abstract class StackPresentation implements ISizeProvider { 44 45 48 public static final int AS_INACTIVE = 0; 49 50 53 public static final int AS_ACTIVE_FOCUS = 1; 54 55 59 public static final int AS_ACTIVE_NOFOCUS = 2; 60 61 64 private IStackPresentationSite site; 65 66 71 protected StackPresentation(IStackPresentationSite stackSite) { 72 Assert.isNotNull(stackSite); 73 site = stackSite; 74 } 75 76 80 protected IStackPresentationSite getSite() { 81 return site; 82 } 83 84 89 public abstract void setBounds(Rectangle bounds); 90 91 102 public Point computeMinimumSize() { 103 return new Point(0,0); 104 } 105 106 109 public int getSizeFlags(boolean width) { 110 boolean hasMaximumSize = getSite().getState() == IStackPresentationSite.STATE_MINIMIZED; 111 112 return SWT.MIN | (hasMaximumSize ? SWT.MAX : 0); 113 } 114 115 118 public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredResult) { 119 int minSize = Geometry.getCoordinate(computeMinimumSize(), width); 120 121 if (getSite().getState() == IStackPresentationSite.STATE_MINIMIZED || preferredResult < minSize) { 122 return minSize; 123 } 124 125 return preferredResult; 126 } 127 128 132 public abstract void dispose(); 133 134 141 public abstract void setActive(int newState); 142 143 154 public abstract void setVisible(boolean isVisible); 155 156 169 public abstract void setState(int state); 170 171 176 public abstract Control getControl(); 177 178 190 public abstract void addPart(IPresentablePart newPart, Object cookie); 191 192 197 public abstract void removePart(IPresentablePart oldPart); 198 199 207 public void movePart(IPresentablePart toMove, Object cookie) { 208 removePart(toMove); 209 addPart(toMove, cookie); 210 211 if (getSite().getSelectedPart() == toMove) { 212 selectPart(toMove); 213 toMove.setFocus(); 214 } 215 } 216 217 223 public abstract void selectPart(IPresentablePart toSelect); 224 225 235 public abstract StackDropResult dragOver(Control currentControl, 236 Point location); 237 238 242 public abstract void showSystemMenu(); 243 244 247 public abstract void showPaneMenu(); 248 249 253 public void showPartList() { 254 255 } 256 257 264 public void saveState(IPresentationSerializer context, IMemento memento) { 265 266 } 267 268 275 public void restoreState(IPresentationSerializer context, IMemento memento) { 276 277 } 278 279 285 public abstract Control[] getTabList(IPresentablePart part); 286 } 287 | Popular Tags |