1 11 package org.eclipse.ui.internal.presentations.util; 12 13 import org.eclipse.jface.action.GroupMarker; 14 import org.eclipse.jface.action.MenuManager; 15 import org.eclipse.jface.action.Separator; 16 import org.eclipse.swt.graphics.Point; 17 import org.eclipse.swt.widgets.Control; 18 import org.eclipse.swt.widgets.Menu; 19 import org.eclipse.ui.internal.WorkbenchMessages; 20 import org.eclipse.ui.internal.presentations.SystemMenuClose; 21 import org.eclipse.ui.internal.presentations.SystemMenuMaximize; 22 import org.eclipse.ui.internal.presentations.SystemMenuMinimize; 23 import org.eclipse.ui.internal.presentations.SystemMenuMove; 24 import org.eclipse.ui.internal.presentations.SystemMenuRestore; 25 import org.eclipse.ui.internal.presentations.UpdatingActionContributionItem; 26 import org.eclipse.ui.presentations.IPresentablePart; 27 import org.eclipse.ui.presentations.IStackPresentationSite; 28 29 35 public class StandardViewSystemMenu implements ISystemMenu { 36 37 MenuManager menuManager = new MenuManager(); 38 private SystemMenuRestore restore; 39 private SystemMenuMove move; 40 private SystemMenuMinimize minimize; 41 private SystemMenuMaximize maximize; 42 private SystemMenuClose close; 43 44 49 public StandardViewSystemMenu(IStackPresentationSite site) { 50 restore = new SystemMenuRestore(site); 51 move = new SystemMenuMove(site, getMoveMenuText(), false); 52 minimize = new SystemMenuMinimize(site); 53 maximize = new SystemMenuMaximize(site); 54 close = new SystemMenuClose(site); 55 56 { menuManager.add(new GroupMarker("misc")); menuManager.add(new GroupMarker("restore")); menuManager.add(new UpdatingActionContributionItem(restore)); 60 61 menuManager.add(move); 62 menuManager.add(new GroupMarker("size")); menuManager.add(new GroupMarker("state")); menuManager.add(new UpdatingActionContributionItem(minimize)); 65 66 menuManager.add(new UpdatingActionContributionItem(maximize)); 67 menuManager.add(new Separator("close")); menuManager.add(close); 69 70 site.addSystemActions(menuManager); 71 } 73 } 74 75 String getMoveMenuText() { 76 return WorkbenchMessages.ViewPane_moveView; 77 } 78 79 82 public void show(Control parent, Point displayCoordinates, IPresentablePart currentSelection) { 83 restore.update(); 84 move.setTarget(currentSelection); 85 move.update(); 86 minimize.update(); 87 maximize.update(); 88 close.setTarget(currentSelection); 89 90 Menu aMenu = menuManager.createContextMenu(parent); 91 menuManager.update(true); 92 aMenu.setLocation(displayCoordinates.x, displayCoordinates.y); 93 aMenu.setVisible(true); 94 } 95 96 99 public void dispose() { 100 menuManager.dispose(); 101 menuManager.removeAll(); 102 } 103 104 } 105 | Popular Tags |