1 13 package org.eclipse.ui.internal; 14 15 import org.eclipse.jface.action.IMenuManager; 16 import org.eclipse.ui.internal.presentations.PresentablePart; 17 import org.eclipse.ui.internal.presentations.PresentationFactoryUtil; 18 import org.eclipse.ui.internal.presentations.SystemMenuDetach; 19 import org.eclipse.ui.internal.presentations.SystemMenuFastView; 20 import org.eclipse.ui.internal.presentations.SystemMenuSize; 21 import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem; 22 import org.eclipse.ui.presentations.AbstractPresentationFactory; 23 import org.eclipse.ui.presentations.IPresentablePart; 24 import org.eclipse.ui.presentations.IStackPresentationSite; 25 import org.eclipse.ui.presentations.StackPresentation; 26 27 40 public class ViewStack extends PartStack { 41 42 private boolean allowStateChanges; 43 44 private WorkbenchPage page; 45 46 private SystemMenuSize sizeItem = new SystemMenuSize(null); 47 48 private SystemMenuFastView fastViewAction; 49 50 private SystemMenuDetach detachViewAction; 51 52 public void addSystemActions(IMenuManager menuManager) { 53 appendToGroupIfPossible(menuManager, 54 "misc", new UpdatingActionContributionItem(fastViewAction)); appendToGroupIfPossible(menuManager, 56 "misc", new UpdatingActionContributionItem(detachViewAction)); sizeItem = new SystemMenuSize(getSelection()); 58 appendToGroupIfPossible(menuManager, "size", sizeItem); } 60 61 public ViewStack(WorkbenchPage page) { 62 this(page, true); 63 } 64 65 public ViewStack(WorkbenchPage page, boolean allowsStateChanges) { 66 this(page, allowsStateChanges, PresentationFactoryUtil.ROLE_VIEW, null); 67 } 68 69 public ViewStack(WorkbenchPage page, boolean allowsStateChanges, 70 int appearance, AbstractPresentationFactory factory) { 71 super(appearance, factory); 72 73 this.page = page; 74 setID(this.toString()); 75 77 this.allowStateChanges = allowsStateChanges; 78 fastViewAction = new SystemMenuFastView(getPresentationSite()); 79 detachViewAction = new SystemMenuDetach(getPresentationSite()); 80 } 81 82 protected WorkbenchPage getPage() { 83 return page; 84 } 85 86 protected boolean canMoveFolder() { 87 Perspective perspective = page.getActivePerspective(); 88 89 if (perspective == null) { 90 return false; 93 } 94 95 return !perspective.isFixedLayout(); 96 } 97 98 protected void updateActions(PresentablePart current) { 99 ViewPane pane = null; 100 101 if (current != null && current.getPane() instanceof ViewPane) { 102 pane = (ViewPane) current.getPane(); 103 } 104 105 fastViewAction.setPane(current); 106 detachViewAction.setPane(pane); 107 sizeItem.setPane(pane); 108 } 109 110 118 public void setMinimized(boolean minimized) { 119 Perspective persp = getPage().getActivePerspective(); 121 if (Perspective.useNewMinMax(persp)) { 122 FastViewManager fvm = persp.getFastViewManager(); 123 if (minimized) { 124 fvm.moveToTrim(this, false); 125 } else { 126 if (persp.getPresentation().getMaximizedStack() != null) { 128 PartStack maxStack = persp.getPresentation().getMaximizedStack(); 129 if (maxStack != null) { 130 maxStack.setState(IStackPresentationSite.STATE_RESTORED); 131 } 132 } 133 134 fvm.restoreToPresentation(getID()); 135 } 136 } 137 138 super.setMinimized(minimized); 139 } 140 141 144 protected boolean isMoveable(IPresentablePart part) { 145 ViewPane pane = (ViewPane) getPaneFor(part); 146 Perspective perspective = page.getActivePerspective(); 147 if (perspective == null) { 148 return true; 151 } 152 return perspective.isMoveable(pane.getViewReference()); 153 } 154 155 158 protected boolean supportsState(int newState) { 159 if (page.isFixedLayout()) { 160 return false; 161 } 162 return allowStateChanges; 163 } 164 165 168 protected void derefPart(LayoutPart toDeref) { 169 page.getActivePerspective().getPresentation().derefPart(toDeref); 170 } 171 172 175 protected boolean allowsDrop(PartPane part) { 176 return part instanceof ViewPane; 177 } 178 179 186 public StackPresentation getTestPresentation() { 187 return getPresentation(); 188 } 189 } 190 | Popular Tags |