Java Code Examples for org.eclipse.jface.action.MenuManager#add()
The following examples show how to use
org.eclipse.jface.action.MenuManager#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemoryEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor ( StructuredViewer viewer ) { MenuManager contextMenu = new MenuManager ( "#PopUp" ); contextMenu.add ( new Separator ( "additions" ) ); contextMenu.setRemoveAllWhenShown ( true ); contextMenu.addMenuListener ( this ); Menu menu = contextMenu.createContextMenu ( viewer.getControl () ); viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) ); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () }; viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) ); viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) ); }
Example 2
Source File: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor ( StructuredViewer viewer ) { MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$ contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$ contextMenu.setRemoveAllWhenShown ( true ); contextMenu.addMenuListener ( this ); Menu menu = contextMenu.createContextMenu ( viewer.getControl () ); viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) ); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () }; viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) ); viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) ); }
Example 3
Source File: ApplicationActionBarAdvisor.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 创建工具菜单 * @return 返回工具菜单的 menu manager; */ private MenuManager createToolMenu() { MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.tool"), "net.heartsome.cat.ts.ui.menu.tool") { @Override public boolean isVisible() { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (workbenchWindow == null) return false; IWorkbenchPage activePage = workbenchWindow.getActivePage(); if (activePage == null) return false; if (activePage.getPerspective().getId().contains("net.heartsome.cat.ts.perspective")) return true; return false; } }; // &Tool menu.add(new GroupMarker("pluginConfigure")); menu.add(new GroupMarker("preference.groupMarker")); // menu.add(preferenceAction); return menu; }
Example 4
Source File: ReadReferencesSearchGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void fillContextMenu(IMenuManager manager) { MenuManager javaSearchMM= new MenuManager(MENU_TEXT, IContextMenuConstants.GROUP_SEARCH); addAction(fFindReadReferencesAction, javaSearchMM); addAction(fFindReadReferencesInProjectAction, javaSearchMM); addAction(fFindReadReferencesInHierarchyAction, javaSearchMM); javaSearchMM.add(new Separator()); Iterator<IWorkingSet[]> iter= SearchUtil.getLRUWorkingSets().sortedIterator(); while (iter.hasNext()) { addWorkingSetAction(iter.next(), javaSearchMM); } addAction(fFindReadReferencesInWorkingSetAction, javaSearchMM); if (!javaSearchMM.isEmpty()) manager.appendToGroup(fGroupId, javaSearchMM); }
Example 5
Source File: PluginConfigManage.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void addPluginMenu(final PluginConfigBean bean) { for (int i = 0; i < parentManager.getItems().length; i++) { if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) { MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i]; // 开始添加新的菜单 Action action = new Action() { @Override public void run() { executePlugin(bean); } }; action.setText(bean.getName()); action.setId(bean.getId()); if (!"".equals(bean.getShortcutKey())) { action.setText(bean.getName() + "\t" + bean.getShortcutKey()); } pluginMenu.add(action); pluginMenu.update(); } } }
Example 6
Source File: RcpActionBarAdvisor.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void fillFileMenu(IMenuManager menuBar) { MenuManager menu = new MenuManager( M.File, IWorkbenchActionConstants.M_FILE); menu.add(saveAction); menu.add(saveAsAction); menu.add(saveAllAction); menu.add(new Separator()); menu.add(closeAction); menu.add(closeAllAction); menu.add(new Separator()); menu.add(preferencesAction); menu.add(new Separator()); menu.add(new ImportAction()); menu.add(new ExportAction()); menu.add(new Separator()); menu.add(exitAction); menuBar.add(menu); }
Example 7
Source File: GamaActionBarAdvisor.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Creates and returns the Help menu. */ private MenuManager createHelpMenu() { final MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_help, IWorkbenchActionConstants.M_HELP); addSeparatorOrGroupMarker(menu, "group.intro"); //$NON-NLS-1$ menu.add(new GroupMarker("group.intro.ext")); //$NON-NLS-1$ addSeparatorOrGroupMarker(menu, "group.main"); //$NON-NLS-1$ menu.add(helpContentsAction); addSeparatorOrGroupMarker(menu, "group.assist"); //$NON-NLS-1$ menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); menu.add(new GroupMarker("group.main.ext")); //$NON-NLS-1$ addSeparatorOrGroupMarker(menu, "group.tutorials"); //$NON-NLS-1$ addSeparatorOrGroupMarker(menu, "group.tools"); //$NON-NLS-1$ addSeparatorOrGroupMarker(menu, "group.updates"); //$NON-NLS-1$ menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); addSeparatorOrGroupMarker(menu, IWorkbenchActionConstants.MB_ADDITIONS); // about should always be at the bottom menu.add(new Separator("group.about")); //$NON-NLS-1$ final ActionContributionItem aboutItem = new ActionContributionItem(aboutAction); aboutItem.setVisible(!Util.isMac()); menu.add(aboutItem); menu.add(new GroupMarker("group.about.ext")); //$NON-NLS-1$ menu.add(openPreferencesAction); return menu; }
Example 8
Source File: VisualInterfaceEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void createContextMenuFor ( StructuredViewer viewer ) { MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$ contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$ contextMenu.setRemoveAllWhenShown ( true ); contextMenu.addMenuListener ( this ); Menu menu = contextMenu.createContextMenu ( viewer.getControl () ); viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) ); int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () }; viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) ); viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) ); }
Example 9
Source File: ApplicationActionBarAdvisor.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 创建帮助菜单 * @return 返回帮助菜单的 menu manager; */ private MenuManager createHelpMenu() { MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.help"), IWorkbenchActionConstants.M_HELP); menu.add(helpAction); menu.add(new GroupMarker("help.keyAssist")); menu.add(new Separator()); menu.add(new GroupMarker("help.updatePlugin")); menu.add(new Separator()); menu.add(new GroupMarker("help.license")); // 关于菜单需要始终显示在最底端 menu.add(new GroupMarker("group.about")); return menu; }
Example 10
Source File: JUnitStatusContributionItem.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
private void attachContextMenu( Control control ) { MenuManager menuManager = new MenuManager(); menuManager.add( new ActivateJUnitViewOnFailureAction() ); menuManager.add( new Separator() ); menuManager.add( new CloseJUnitStatusAction( getWorkbenchWindow().getWorkbench() ) ); Menu contextMenu = menuManager.createContextMenu( control ); control.setMenu( contextMenu ); }
Example 11
Source File: RcpActionBarAdvisor.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void fillHelpMenu(IMenuManager menuBar) { MenuManager helpMenu = new MenuManager( M.Help, IWorkbenchActionConstants.M_HELP); helpMenu.add(Actions.create( M.OnlineHelp, Icon.HELP.descriptor(), () -> Desktop.browse(Config.HELP_URL))); helpMenu.add(new Separator()); helpMenu.add(Actions.create( M.OpenLogFile, Icon.FILE.descriptor(), LogFileEditor::open)); helpMenu.add(aboutAction); menuBar.add(helpMenu); }
Example 12
Source File: ApplicationActionBarAdvisor.java From tlaplus with MIT License | 5 votes |
protected void fillMenuBar(final IMenuManager menuBar) { // File menu final MenuManager fileMenu = new MenuManager("&File", "toolbox.file.menu"); fileMenu.add(new Separator("toolbox.file.spec.separator")); fileMenu.add(new Separator("toolbox.file.module.separator")); fileMenu.add(new Separator("toolbox.file.translation.separator")); fileMenu.add(new Separator("toolbox.file.save.separator")); fileMenu.add(saveAction); fileMenu.add(saveAsAction); fileMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); fileMenu.add(preferencesAction); fileMenu.add(new Separator()); fileMenu.add(quitAction); // Window Menu final MenuManager windowMenu = new MenuManager("&Window", "toolbox.window.menu"); windowMenu.add(new Separator("toolbox.window.open.separator")); windowMenu.add(new Separator()); windowMenu.add(new Separator("toolbox.window.tools.separator")); windowMenu.add(new Separator()); windowMenu.add(new Separator("toolbox.window.view.separator")); windowMenu.add(new Separator()); windowMenu.add(backwardHistoryAction); windowMenu.add(forwardHistoryAction); // Menu bar contributions via plugin.xmls final Separator separator = new Separator("toolbox.tools.separator"); separator.setVisible(false); // @see Bug #27 in general/bugzilla/index.html // finally add to menu bar menuBar.add(fileMenu); menuBar.add(windowMenu); menuBar.add(separator); }
Example 13
Source File: DesignerActionBarAdvisor.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Adds the perspective actions to the specified menu. */ private void addPerspectiveActions( MenuManager menu ) { { MenuManager showViewMenuMgr = new MenuManager( DesignerWorkbenchMessages.Workbench_showView, "showView" ); //$NON-NLS-1$ IContributionItem showViewMenu = ContributionItemFactory.VIEWS_SHORTLIST.create( getWindow( ) ); showViewMenuMgr.add( showViewMenu ); menu.add( showViewMenuMgr ); } }
Example 14
Source File: Actions.java From olca-app with Mozilla Public License 2.0 | 5 votes |
/** * Creates a context menu with the given actions on the tree viewer. */ public static void bind(TreeViewer viewer, Action... actions) { Tree tree = viewer.getTree(); if (tree == null) return; MenuManager menu = new MenuManager(); for (Action action : actions) menu.add(action); tree.setMenu(menu.createContextMenu(tree)); }
Example 15
Source File: AnnotationEditor.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override protected void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); // Add Annotate action menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new Separator()); menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, getAction(SmartAnnotateAction.ID)); menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, getAction(QuickAnnotateAction.ID)); menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, getAction(IWorkbenchActionDefinitionIds.DELETE)); TypeSystem typeSystem = getDocument().getCAS().getTypeSystem(); // mode menu MenuManager modeMenuManager = new MenuManager("Mode"); menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, modeMenuManager); ModeMenu modeMenu = new ModeMenu(typeSystem, this); modeMenu.addListener(new IModeMenuListener(){ @Override public void modeChanged(Type newMode) { IAction actionToExecute = new ChangeModeAction(newMode, newMode.getShortName(), AnnotationEditor.this); actionToExecute.run(); }}); modeMenuManager.add(modeMenu); // annotation menu MenuManager showAnnotationMenu = new MenuManager("Show Annotations"); menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, showAnnotationMenu); showAnnotationMenu.add(mShowAnnotationsMenu); // view menu MenuManager casViewMenuManager = new MenuManager("CAS Views"); menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, casViewMenuManager); CasViewMenu casViewMenu = new CasViewMenu(this); casViewMenuManager.add(casViewMenu); }
Example 16
Source File: ApplicationActionBarAdvisor.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
protected void fillMenuBar(IMenuManager menuBar) { MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); menuBar.add(fileMenu); fileMenu.add(exitAction); MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT); menuBar.add(editMenu); editMenu.add(preferenceAction); }
Example 17
Source File: Actions.java From olca-app with Mozilla Public License 2.0 | 5 votes |
/** * Creates a context menu with the given actions on the table viewer. */ public static void bind(TableViewer viewer, Action... actions) { Table table = viewer.getTable(); if (table == null) return; MenuManager menu = new MenuManager(); for (Action action : actions) menu.add(action); table.setMenu(menu.createContextMenu(table)); }
Example 18
Source File: XViewerCustomMenu.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void setupMenuForHeader(MenuManager menuManager) { menuManager.add(showColumn); menuManager.add(hideColumn); menuManager.add(addComputedColumn); menuManager.add(copySelectedColumnCells); menuManager.add(new Separator()); menuManager.add(filterBySelColumn); menuManager.add(filterByColumn); menuManager.add(clearAllFilters); menuManager.add(clearAllSorting); menuManager.add(new Separator()); menuManager.add(sumColumn); menuManager.add(averageColumn); menuManager.add(uniqueValues); }
Example 19
Source File: DocumentsMetaDataDialog.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
private void createUIDocumentReferences(Composite ret){ new Label(ret, SWT.NONE).setText(Messages.DocumentView_keywordsColumn); tKeywords = SWTHelper.createText(ret, 4, SWT.NONE); tKeywords.setText(Optional .ofNullable(Objects.toString(documentReference.getKeywords(), document.getKeywords())) .orElse("")); new Label(ret, SWT.NONE).setText(Messages.DocumentsView_Author); tAuthor = SWTHelper.createText(ret, 1, SWT.NONE); AutoCompleteTextUtil.addAutoCompleteSupport(tAuthor, new AuthorContentProposalProvider(), Optional.ofNullable(documentReference.getAuthorId()) .map(o -> CoreModelServiceHolder.get().load(o, IContact.class).orElse(null)) .orElse(document.getAuthor())); MenuManager menuManager = new MenuManager(); menuManager.add(new Action(ch.elexis.core.l10n.Messages.KontaktDetailDialog_newContact) { { setImageDescriptor(Images.IMG_NEW.getImageDescriptor()); } @Override public void run(){ KontaktErfassenDialog dlg = new KontaktErfassenDialog(UiDesk.getTopShell(), ContactLabelUtil.getContactHints(tAuthor.getText())); if (dlg.open() == Window.OK) { if (dlg.getContact().isPresent()) { AutoCompleteTextUtil.setValue(tAuthor, dlg.getContact().get()); } else { MessageDialog.openWarning(getParentShell(), "", "Der Kontakt konnte nicht angelegt werden."); } } } @Override public boolean isEnabled(){ return !(AutoCompleteTextUtil.getData(tAuthor) instanceof IContact); } }); menuManager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager){ IContributionItem[] items = manager.getItems(); for (IContributionItem iContributionItem : items) { iContributionItem.update(); } } }); tAuthor.setMenu(menuManager.createContextMenu(tAuthor)); new Label(ret, SWT.NONE).setText(Messages.DocumentsView_DocumentClass); tDocumentClass = SWTHelper.createText(ret, 1, SWT.NONE); AutoCompleteTextUtil.addAutoCompleteSupport(tDocumentClass, new ValueSetProposalProvider(ValueSetProposalProvider.EPRDOCUMENT_CLASSCODE), documentReference.getDocumentClass()); new Label(ret, SWT.NONE).setText(Messages.DocumentsView_PracticeSetting); tPracticeSetting = SWTHelper.createText(ret, 1, SWT.NONE); AutoCompleteTextUtil.addAutoCompleteSupport(tPracticeSetting, new ValueSetProposalProvider(ValueSetProposalProvider.EPRDOCUMENT_PRACTICESETTINGCODE), documentReference.getPracticeSetting()); }
Example 20
Source File: GamaActionBarAdvisor.java From gama with GNU General Public License v3.0 | 3 votes |
/** * Adds a <code>GroupMarker</code> or <code>Separator</code> to a menu. * The test for whether a separator should be added is done by checking for * the existence of a preference matching the string * useSeparator.MENUID.GROUPID that is set to <code>true</code>. * * @param menu * the menu to add to * @param groupId * the group id for the added separator or group marker */ private void addSeparatorOrGroupMarker(final MenuManager menu, final String groupId) { final String prefId = "useSeparator." + menu.getId() + "." + groupId; //$NON-NLS-1$ //$NON-NLS-2$ final boolean addExtraSeparators = IDEWorkbenchPlugin.getDefault().getPreferenceStore().getBoolean(prefId); if ( addExtraSeparators ) { menu.add(new Separator(groupId)); } else { menu.add(new GroupMarker(groupId)); } }