List of usage examples for org.eclipse.jface.action MenuManager isEmpty
@Override
public boolean isEmpty()
From source file:com.bdaum.zoom.rcp.internal.ApplicationActionBarAdvisor.java
License:Open Source License
@Override protected void fillMenuBar(IMenuManager menuBar) { MenuManager catMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Catalog"), //$NON-NLS-1$ IZoomActionConstants.M_CATALOG); menuBar.add(catMenu);// www .j a va2 s. com catMenu.add(new Separator(IZoomActionConstants.CATALOG_START)); final MenuManager recentMenu = new MenuManager( Messages.getString("ApplicationActionBarAdvisor.recently_opened_cats"), "recentCats"); //$NON-NLS-1$ //$NON-NLS-2$ recentMenu.setRemoveAllWhenShown(true); recentMenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { CoreActivator activator = CoreActivator.getDefault(); File file = activator.getDbManager().getFile(); CatLocation current = file == null ? null : new CatLocation(file); int i = 0; for (CatLocation cat : activator.getRecentCats()) if ((current == null || !current.equals(cat)) && cat.exists()) recentMenu.add(new OpenAction(cat, ++i)); if (recentMenu.isEmpty()) recentMenu.add(new OpenAction(null, 0)); } }); catMenu.add(recentMenu); catMenu.add(new Separator(IZoomActionConstants.CATALOG_EXT1)); catMenu.add(getAction(ActionFactory.PRINT.getId())); catMenu.add(new Separator(IZoomActionConstants.CATALOG_EXT2)); catMenu.add(new Separator(IZoomActionConstants.CATALOG_EXT3)); if (!Constants.OSX) catMenu.add(getAction(ActionFactory.QUIT.getId())); catMenu.add(new Separator(IZoomActionConstants.CATALOG_END)); MenuManager fileMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.File"), //$NON-NLS-1$ IWorkbenchActionConstants.M_FILE); menuBar.add(fileMenu); fileMenu.add(new Separator(IWorkbenchActionConstants.FILE_START)); fileMenu.add(new Separator(IZoomActionConstants.FILE_EXT1)); fileMenu.add(new Separator(IZoomActionConstants.FILE_EXT2)); fileMenu.add(new Separator(IWorkbenchActionConstants.FILE_END)); MenuManager navigateMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Navigate"), //$NON-NLS-1$ IWorkbenchActionConstants.M_NAVIGATE); menuBar.add(navigateMenu); navigateMenu.add(new Separator(IWorkbenchActionConstants.NAV_START)); navigateMenu.add(new Separator(IZoomActionConstants.NAV_EXT1)); navigateMenu.add(new Separator(IZoomActionConstants.NAV_EXT2)); navigateMenu.add(new Separator(IWorkbenchActionConstants.NAV_END)); MenuManager editMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Edit"), //$NON-NLS-1$ IWorkbenchActionConstants.M_EDIT); menuBar.add(editMenu); editMenu.add(new Separator(IWorkbenchActionConstants.EDIT_START)); editMenu.add(new Separator(IWorkbenchActionConstants.EDIT_END)); MenuManager imageMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Image"), //$NON-NLS-1$ IZoomActionConstants.M_IMAGE); menuBar.add(imageMenu); imageMenu.add(new Separator(IZoomActionConstants.IMAGE_START)); imageMenu.add(new Separator(IZoomActionConstants.IMAGE_EXT1)); imageMenu.add(new Separator(IZoomActionConstants.IMAGE_EXT2)); imageMenu.add(new Separator(IZoomActionConstants.IMAGE_EXT3)); imageMenu.add(new Separator(IZoomActionConstants.IMAGE_END)); MenuManager metaMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Metadata"), //$NON-NLS-1$ IZoomActionConstants.M_META); menuBar.add(metaMenu); metaMenu.add(new Separator(IZoomActionConstants.META_START)); metaMenu.add(new Separator(IZoomActionConstants.META_EXT1)); metaMenu.add(new Separator(IZoomActionConstants.META_EXT2)); metaMenu.add(new Separator(IZoomActionConstants.META_END)); MenuManager windowMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Window"), //$NON-NLS-1$ IWorkbenchActionConstants.M_WINDOW); menuBar.add(windowMenu); windowMenu.add(new Separator(IZoomActionConstants.WINDOW_START)); windowMenu.add(new Separator(IZoomActionConstants.WINDOW_EXT)); windowMenu.add(new Separator()); MenuManager perspective = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.perspective"), //$NON-NLS-1$ "perspective"); //$NON-NLS-1$ windowMenu.add(perspective); perspective.add(getAction(ActionFactory.OPEN_PERSPECTIVE_DIALOG.getId())); perspective.add(getAction(ActionFactory.EDIT_ACTION_SETS.getId())); perspective.add(getAction(ActionFactory.RESET_PERSPECTIVE.getId())); perspective.add(getAction(ActionFactory.SAVE_PERSPECTIVE.getId())); perspective.add(getAction(ActionFactory.CLOSE_PERSPECTIVE.getId())); perspective.add(getAction(ActionFactory.CLOSE_ALL_PERSPECTIVES.getId())); windowMenu.add(new Separator(IZoomActionConstants.WINDOW_EXT1)); ActionContributionItem preferencesActionItem = new ActionContributionItem( getAction(ActionFactory.PREFERENCES.getId())); windowMenu.add(preferencesActionItem); MenuManager helpMenu = new MenuManager(Messages.getString("ApplicationActionBarAdvisor.Help"), //$NON-NLS-1$ IWorkbenchActionConstants.M_HELP); menuBar.add(helpMenu); helpMenu.add(getAction(ActionFactory.INTRO.getId())); helpMenu.add(new Separator(IWorkbenchActionConstants.HELP_START)); helpMenu.add(getAction(ActionFactory.HELP_CONTENTS.getId())); helpMenu.add(getAction(ActionFactory.HELP_SEARCH.getId())); helpMenu.add(new Separator(IZoomActionConstants.HELP_EXT)); helpMenu.add(new Separator(IZoomActionConstants.HELP_UPDATE)); helpMenu.add(new Separator(IWorkbenchActionConstants.HELP_END)); // Help ActionContributionItem aboutActionItem = new ActionContributionItem(getAction(ActionFactory.ABOUT.getId())); helpMenu.add(aboutActionItem); if (Constants.OSX) { preferencesActionItem.setVisible(false); aboutActionItem.setVisible(false); } }
From source file:com.iw.plugins.spindle.editors.spec.SpecEditor.java
License:Mozilla Public License
protected void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); if ((getStorage(getEditorInput()) instanceof IFile)) { addAction(menu, NAV_GROUP, OpenDeclarationAction.ACTION_ID); addAction(menu, NAV_GROUP, ShowInPackageExplorerAction.ACTION_ID); }/*w w w .ja va 2s . c o m*/ MenuManager moreNav = new MenuManager("Jump"); for (int i = 0; i < fJumpActions.length; i++) { fJumpActions[i].editorContextMenuAboutToShow(moreNav); } if (!moreNav.isEmpty()) menu.appendToGroup(NAV_GROUP, moreNav); MenuManager sourceMenu = new MenuManager("Source"); sourceMenu.add(getAction("Format")); menu.appendToGroup(SOURCE_GROUP, sourceMenu); }
From source file:com.nokia.tools.ui.editor.BaseGraphicalContextMenuProvider.java
License:Open Source License
@Override public void buildContextMenu(IMenuManager menu) { super.buildContextMenu(menu); IAction action = getActionRegistry().getAction(GEFActionConstants.ZOOM_IN); // bugfix#24649: // Removed ZoomIn and ZoomOut operations from context pop-up menu in Outline view and same are activated for Editor. boolean checkActivePage = (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null); if (action != null && action.isEnabled() && checkActivePage == true && PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof IEditorPart) menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action); action = getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT); if (action != null && action.isEnabled() && checkActivePage == true && PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof IEditorPart) menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action); // Alignment Actions // @Externalize MenuManager submenu = new MenuManager("Alignment Tools"); action = getActionRegistry().getAction(GEFActionConstants.ALIGN_LEFT); if (action != null && action.isEnabled()) { submenu.add(action);//from w w w . j a va 2 s .co m } action = getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER); if (action != null && action.isEnabled()) { submenu.add(action); } action = getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT); if (action != null && action.isEnabled()) { submenu.add(action); } submenu.add(new Separator()); action = getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP); if (action != null && action.isEnabled()) { submenu.add(action); } action = getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE); if (action != null && action.isEnabled()) { submenu.add(action); } action = getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM); if (action != null && action.isEnabled()) { submenu.add(action); } if (!submenu.isEmpty()) { menu.appendToGroup(GEFActionConstants.GROUP_VIEW, new Separator()); menu.appendToGroup(GEFActionConstants.GROUP_VIEW, submenu); } // Sizing Actions action = getActionRegistry().getAction(GEFActionConstants.MATCH_WIDTH); if (action != null && action.isEnabled()) { menu.appendToGroup(GEFActionConstants.GROUP_VIEW, new Separator()); menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action); action = getActionRegistry().getAction(GEFActionConstants.MATCH_HEIGHT); if (action != null && action.isEnabled()) { menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action); } } else { action = getActionRegistry().getAction(GEFActionConstants.MATCH_HEIGHT); if (action != null && action.isEnabled()) { menu.appendToGroup(GEFActionConstants.GROUP_VIEW, new Separator()); menu.appendToGroup(GEFActionConstants.GROUP_VIEW, action); } } }
From source file:ext.org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.EditorBreadcrumb.java
License:Open Source License
public Control createContent(Composite parent) { Assert.isTrue(fComposite == null, "Content must only be created once."); //$NON-NLS-1$ boolean rtl = (getTextEditor().getSite().getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0; fComposite = new Composite(parent, rtl ? SWT.RIGHT_TO_LEFT : SWT.NONE); GridData data = new GridData(SWT.FILL, SWT.TOP, true, false); fComposite.setLayoutData(data);/* w w w . java 2s . c o m*/ GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.verticalSpacing = 0; gridLayout.horizontalSpacing = 0; fComposite.setLayout(gridLayout); fDisplayFocusListener = new Listener() { public void handleEvent(Event event) { if (isBreadcrumbEvent(event)) { if (fHasFocus) return; fIsActive = true; focusGained(); } else { if (!fIsActive) return; boolean hasTextFocus = fTextViewer.getTextWidget().isFocusControl(); if (hasTextFocus) { fIsActive = false; } if (!fHasFocus) return; focusLost(); } } }; Display.getCurrent().addFilter(SWT.FocusIn, fDisplayFocusListener); fBreadcrumbViewer = createViewer(fComposite); fBreadcrumbViewer.getControl().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); fBreadcrumbViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { Object element = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (element == null) return; BreadcrumbItem item = (BreadcrumbItem) fBreadcrumbViewer.doFindItem(element); if (item == null) return; int index = fBreadcrumbViewer.getIndexOfItem(item); BreadcrumbItem parentItem = fBreadcrumbViewer.getItem(index - 1); parentItem.openDropDownMenu(); } }); fBreadcrumbViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { doRevealOrOpen(event.getSelection()); } }); fBreadcrumbViewer.addMenuDetectListener(new MenuDetectListener() { public void menuDetected(MenuDetectEvent event) { ISelectionProvider selectionProvider; if (fBreadcrumbViewer.isDropDownOpen()) { selectionProvider = fBreadcrumbViewer.getDropDownSelectionProvider(); } else { selectionProvider = fBreadcrumbViewer; } ActionGroup actionGroup = createContextMenuActionGroup(selectionProvider); if (actionGroup == null) return; try { MenuManager manager = new MenuManager(); actionGroup.setContext(new ActionContext(selectionProvider.getSelection())); actionGroup.fillContextMenu(manager); getTextEditor().getEditorSite().registerContextMenu(manager, selectionProvider, false); if (manager.isEmpty()) return; Menu menu = manager.createContextMenu(fBreadcrumbViewer.getControl()); menu.setLocation(event.x + 10, event.y + 10); menu.setVisible(true); while (!menu.isDisposed() && menu.isVisible()) { if (!menu.getDisplay().readAndDispatch()) menu.getDisplay().sleep(); } } finally { actionGroup.dispose(); } } }); fPropertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (ACTIVE_TAB_BG_END.equals(event.getProperty())) { if (fComposite.isFocusControl()) { fComposite.setBackground(JFaceResources.getColorRegistry().get(ACTIVE_TAB_BG_END)); } } } }; JFaceResources.getColorRegistry().addListener(fPropertyChangeListener); return fComposite; }
From source file:fr.isima.ponge.wsprotocol.gefeditor.uiparts.ProtocolEditorContextMenuProvider.java
License:Open Source License
public void buildContextMenu(IMenuManager menu) { // Add standard action groups to the menu GEFActionConstants.addStandardActionGroups(menu); IAction action;/*w w w .j av a 2 s. c o m*/ action = getAction(ActionFactory.UNDO.getId()); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); action = getAction(ActionFactory.REDO.getId()); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); action = getAction(ActionFactory.DELETE.getId()); if (action.isEnabled()) menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); // Alignment actions MenuManager submenu = new MenuManager(Messages.alignMenuEntry); action = getAction(GEFActionConstants.ALIGN_LEFT); if (action.isEnabled()) submenu.add(action); action = getAction(GEFActionConstants.ALIGN_CENTER); if (action.isEnabled()) submenu.add(action); action = getAction(GEFActionConstants.ALIGN_RIGHT); if (action.isEnabled()) submenu.add(action); submenu.add(new Separator()); action = getAction(GEFActionConstants.ALIGN_TOP); if (action.isEnabled()) submenu.add(action); action = getAction(GEFActionConstants.ALIGN_MIDDLE); if (action.isEnabled()) submenu.add(action); action = getAction(GEFActionConstants.ALIGN_BOTTOM); if (action.isEnabled()) submenu.add(action); if (!submenu.isEmpty()) menu.appendToGroup(GEFActionConstants.GROUP_REST, submenu); action = getAction(ActionFactory.SAVE.getId()); menu.appendToGroup(GEFActionConstants.GROUP_SAVE, action); }
From source file:genericUMLDiagramEditor.editor.GenericDiagramContextMenuProvider.java
License:Open Source License
public void buildContextMenu(IMenuManager manager) { GEFActionConstants.addStandardActionGroups(manager); IAction action;/* w w w .j a v a 2 s. c om*/ action = actionRegistry.getAction(GEFActionConstants.ZOOM_IN); manager.appendToGroup(GEFActionConstants.GROUP_VIEW, action); action = actionRegistry.getAction(GEFActionConstants.ZOOM_OUT); manager.appendToGroup(GEFActionConstants.GROUP_VIEW, action); action = actionRegistry.getAction(RefreshAction.ID); if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_VIEW, action); action = actionRegistry.getAction(VisibilityAction.ID); if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action); action = actionRegistry.getAction(ShowAllAction.ID); manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action); addAlignmentAction(manager); MenuManager submenu = new MenuManager("Match"); action = actionRegistry.getAction(GEFActionConstants.MATCH_WIDTH); if (action.isEnabled()) submenu.add(action); action = actionRegistry.getAction(GEFActionConstants.MATCH_HEIGHT); if (action.isEnabled()) submenu.add(action); if (!submenu.isEmpty()) manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); String id = ActionFactory.UNDO.getId(); action = actionRegistry.getAction(id); manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action); id = ActionFactory.REDO.getId(); action = actionRegistry.getAction(id); manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action); id = ActionFactory.COPY.getId(); action = actionRegistry.getAction(id); manager.appendToGroup(GEFActionConstants.GROUP_COPY, action); id = ActionFactory.PASTE.getId(); action = actionRegistry.getAction(id); manager.appendToGroup(GEFActionConstants.GROUP_COPY, action); id = ActionFactory.DELETE.getId(); action = actionRegistry.getAction(id); if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_REST, action); MenuManager submenuExport = new MenuManager("Export"); action = actionRegistry.getAction(ExportSelectionAction.ID); submenuExport.add(action); action = actionRegistry.getAction(ExportAction.ID); submenuExport.add(action); manager.appendToGroup(GEFActionConstants.GROUP_PRINT, submenuExport); }
From source file:genericUMLDiagramEditor.editor.GenericDiagramContextMenuProvider.java
License:Open Source License
/** * Build the submen for the alignment actions * //from w w w.j a v a2 s. c om * @param manager the IMenuManager */ protected void addAlignmentAction(IMenuManager manager) { // Alignment Actions MenuManager submenu = new MenuManager("Align"); IAction action; action = actionRegistry.getAction(GEFActionConstants.ALIGN_TOP); if (action.isEnabled()) submenu.add(action); action = actionRegistry.getAction(GEFActionConstants.ALIGN_BOTTOM); if (action.isEnabled()) submenu.add(action); action = actionRegistry.getAction(GEFActionConstants.ALIGN_MIDDLE); if (action.isEnabled()) submenu.add(action); submenu.add(new Separator()); action = actionRegistry.getAction(GEFActionConstants.ALIGN_LEFT); if (action.isEnabled()) submenu.add(action); action = actionRegistry.getAction(GEFActionConstants.ALIGN_RIGHT); if (action.isEnabled()) submenu.add(action); action = actionRegistry.getAction(GEFActionConstants.ALIGN_CENTER); if (action.isEnabled()) submenu.add(action); if (!submenu.isEmpty()) manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); }
From source file:info.vancauwenberge.designer.enhtrace.viewer.outline.page.DetailedPolicyFlowPage.java
License:Mozilla Public License
private void createPolicysetSubmenu(IMenuManager manager, IPolicySetLogMessage iPolicySetLogMessage) { if (iPolicySetLogMessage.hasChildren()) { List<ILogMessage> children = iPolicySetLogMessage.getChildren(); MenuManager subMenu = null; if (iPolicySetLogMessage.getPolicySet().isSubflowRoot()) { //Only list the policySets subMenu = new MenuManager("Policy Set", null); for (final ILogMessage iLogMessage : children) { if (iLogMessage instanceof IPolicySetLogMessage) { String message = iLogMessage.getMessage(); /*//w w w.ja va 2 s . c o m Matcher matcher = applyingPolicySetPattern.matcher(message); if (matcher.find()){ message = message.substring(matcher.end()); }*/ subMenu.add(new GotoLogmessageAction(Util.elipsisLabelEnd(message, Util.MAX_LABEL_SIZE), iLogMessage)); } } } else { subMenu = new MenuManager("Policy", null); for (final ILogMessage iLogMessage : children) { if (iLogMessage.getMessage().startsWith("Applying policy:")) { //We need to create a submenu String message = iLogMessage.getMessage(); Matcher matcher = applyingPolicyPattern.matcher(message); if (matcher.find()) { message = message.substring(matcher.start() + 4, matcher.end() - 3); } subMenu.add(new GotoLogmessageAction(Util.elipsisLabelEnd(message, Util.MAX_LABEL_SIZE), iLogMessage)); } } } if (!subMenu.isEmpty()) manager.add(subMenu); } }
From source file:net.sf.eclipsensis.installoptions.editor.InstallOptionsDesignMenuProvider.java
License:Open Source License
@Override public void buildContextMenu(IMenuManager manager) { GEFActionConstants.addStandardActionGroups(manager); IAction action;/*from www .j a v a 2 s .c om*/ addContextMenu(manager, ActionFactory.UNDO.getId(), GEFActionConstants.GROUP_UNDO); addContextMenu(manager, ActionFactory.REDO.getId(), GEFActionConstants.GROUP_UNDO); addContextMenu(manager, ActionFactory.CUT.getId(), GEFActionConstants.GROUP_EDIT); addContextMenu(manager, ActionFactory.COPY.getId(), GEFActionConstants.GROUP_EDIT); addContextMenu(manager, ActionFactory.PASTE.getId(), GEFActionConstants.GROUP_EDIT); addContextMenu(manager, ActionFactory.DELETE.getId(), GEFActionConstants.GROUP_EDIT); addContextMenu(manager, ToggleEnablementAction.ID, GEFActionConstants.GROUP_EDIT); addContextMenu(manager, ToggleLockAction.ID, GEFActionConstants.GROUP_EDIT); List<?> selected = getViewer().getSelectedEditParts(); if (selected.size() == 1) { EditPart editPart = (EditPart) selected.get(0); if (editPart instanceof InstallOptionsWidgetEditPart) { action = getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT); if (action != null && action.isEnabled()) { IDirectEditLabelProvider labelProvider = (IDirectEditLabelProvider) ((InstallOptionsWidgetEditPart) editPart) .getAdapter(IDirectEditLabelProvider.class); String label; if (labelProvider != null) { label = labelProvider.getDirectEditLabel(); } else { label = InstallOptionsPlugin.getResourceString("direct.edit.label"); //$NON-NLS-1$ } if (!Common.isEmpty(label)) { action.setText(label); action.setToolTipText(label); manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action); } } action = getActionRegistry().getAction(ExtendedEditAction.ID); if (action != null && action.isEnabled()) { IExtendedEditLabelProvider labelProvider = (IExtendedEditLabelProvider) ((InstallOptionsWidgetEditPart) editPart) .getAdapter(IExtendedEditLabelProvider.class); String label; if (labelProvider != null) { label = labelProvider.getExtendedEditLabel(); } else { label = InstallOptionsPlugin.getResourceString("extended.edit.label"); //$NON-NLS-1$ } if (!Common.isEmpty(label)) { action.setText(label); action.setToolTipText(label); manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action); } } } } // Alignment Actions MenuManager submenu = new MenuManager(InstallOptionsPlugin.getResourceString("align.submenu.name")); //$NON-NLS-1$ addContextMenu(submenu, GEFActionConstants.ALIGN_LEFT, null); addContextMenu(submenu, GEFActionConstants.ALIGN_CENTER, null); addContextMenu(submenu, GEFActionConstants.ALIGN_RIGHT, null); if (!submenu.isEmpty()) { submenu.add(new Separator()); } addContextMenu(submenu, GEFActionConstants.ALIGN_TOP, null); addContextMenu(submenu, GEFActionConstants.ALIGN_MIDDLE, null); addContextMenu(submenu, GEFActionConstants.ALIGN_BOTTOM, null); if (!submenu.isEmpty()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); } submenu = new MenuManager(InstallOptionsPlugin.getResourceString("match.size.submenu.name")); //$NON-NLS-1$ addContextMenu(submenu, GEFActionConstants.MATCH_WIDTH, null); addContextMenu(submenu, GEFActionConstants.MATCH_HEIGHT, null); addContextMenu(submenu, MatchSizeAction.ID, null); if (!submenu.isEmpty()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); } submenu = new MenuManager(InstallOptionsPlugin.getResourceString("distribute.submenu.name")); //$NON-NLS-1$ addContextMenu(submenu, DistributeAction.HORIZONTAL_BETWEEN_ID, null); addContextMenu(submenu, DistributeAction.HORIZONTAL_LEFT_EDGE_ID, null); addContextMenu(submenu, DistributeAction.HORIZONTAL_CENTER_ID, null); addContextMenu(submenu, DistributeAction.HORIZONTAL_RIGHT_EDGE_ID, null); if (!submenu.isEmpty()) { submenu.add(new Separator()); } addContextMenu(submenu, DistributeAction.VERTICAL_BETWEEN_ID, null); addContextMenu(submenu, DistributeAction.VERTICAL_TOP_EDGE_ID, null); addContextMenu(submenu, DistributeAction.VERTICAL_CENTER_ID, null); addContextMenu(submenu, DistributeAction.VERTICAL_BOTTOM_EDGE_ID, null); if (!submenu.isEmpty()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); } submenu = new MenuManager(InstallOptionsPlugin.getResourceString("arrange.submenu.name")); //$NON-NLS-1$ addContextMenu(submenu, ArrangeAction.SEND_BACKWARD_ID, null); addContextMenu(submenu, ArrangeAction.SEND_TO_BACK_ID, null); addContextMenu(submenu, ArrangeAction.BRING_FORWARD_ID, null); addContextMenu(submenu, ArrangeAction.BRING_TO_FRONT_ID, null); if (!submenu.isEmpty()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); } if (mEditor != null && selected.size() == 0) { if (mSetDialogSizeMenu == null) { mSetDialogSizeMenu = new SetDialogSizeMenuManager(manager); mSetDialogSizeMenu.setEditor(mEditor); } mSetDialogSizeMenu.rebuild(); if (!mSetDialogSizeMenu.isEmpty()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, mSetDialogSizeMenu); } } addContextMenu(manager, CreateTemplateAction.ID, GEFActionConstants.GROUP_EDIT); addContextMenu(manager, RefreshDiagramAction.ID, GEFActionConstants.GROUP_EDIT); submenu = new MenuManager(InstallOptionsPlugin.getResourceString("preview.submenu.name")); //$NON-NLS-1$ addContextMenu(submenu, PreviewAction.PREVIEW_CLASSIC_ID, null); addContextMenu(submenu, PreviewAction.PREVIEW_MUI_ID, null); if (!submenu.isEmpty()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); } addContextMenu(manager, "net.sf.eclipsensis.installoptions.design_editor_prefs", //$NON-NLS-1$ GEFActionConstants.GROUP_REST); addContextMenu(manager, ActionFactory.SAVE.getId(), GEFActionConstants.GROUP_SAVE); }
From source file:org.cubictest.ui.gef.actions.TestContextMenuProvider.java
License:Open Source License
public void buildContextMenu(IMenuManager menu) { GEFActionConstants.addStandardActionGroups(menu); IAction action;// w w w . j a v a2s . c om MenuManager addElementMenu = new MenuManager("Add page element", "cubicTestPlugin.action.addPageElement"); for (Class<? extends PageElement> elementClass : AddElementContextMenuList.getList()) { action = actionRegistry.getAction(AddPageElementAction.getActionId(elementClass)); if (action.isEnabled()) { addElementMenu.add(action); } } if (!addElementMenu.isEmpty()) { menu.insertBefore(GEFActionConstants.GROUP_UNDO, addElementMenu); } MenuManager refactorMenu = new MenuManager("Refactor", "cubicTestPlugin.action.refactor"); action = actionRegistry.getAction(RefactorToSubTestAction.ACTION_ID); if (action.isEnabled()) { refactorMenu.add(action); } if (!refactorMenu.isEmpty()) { menu.insertBefore(GEFActionConstants.GROUP_REST, refactorMenu); } action = actionRegistry.getAction(AddUserInteractionTransitionAction.ACTION_ID); if (action.isEnabled()) menu.insertBefore(GEFActionConstants.GROUP_UNDO, action); action = actionRegistry.getAction(AddExtensionPointAction.ACTION_ID); if (action.isEnabled()) menu.insertBefore(GEFActionConstants.GROUP_UNDO, action); action = actionRegistry.getAction(UpdateTestStartPointAction.ACTION_ID); if (action.isEnabled()) menu.insertBefore(GEFActionConstants.GROUP_REST, action); action = actionRegistry.getAction(PresentAction.ACTION_ID); if (action.isEnabled()) menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); action = actionRegistry.getAction(ActionFactory.CUT.getId()); menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); action = actionRegistry.getAction(ActionFactory.COPY.getId()); menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); action = actionRegistry.getAction(ActionFactory.PASTE.getId()); menu.appendToGroup(GEFActionConstants.GROUP_COPY, action); action = actionRegistry.getAction(PopulateCommonAction.ID); if (action.isEnabled()) menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); action = actionRegistry.getAction(ResetTestAction.ACTION_ID); menu.appendToGroup(GEFActionConstants.GROUP_REST, action); action = actionRegistry.getAction(AutoLayoutAction.ACTION_ID); menu.appendToGroup(GEFActionConstants.GROUP_REST, action); }