List of usage examples for org.eclipse.jface.action MenuManager find
@Override
public IContributionItem find(String id)
From source file:com.aptana.explorer.navigator.actions.CommandsActionProvider.java
License:Open Source License
protected void fillMenu(MenuManager menuManager) { IContributionItem item = menuManager.find(IContextMenuConstants.GROUP_PROPERTIES); if (item == null) { menuManager.add(new GroupMarker(IContextMenuConstants.GROUP_PROPERTIES)); }/* www .j av a 2s . c o m*/ // Stick Delete in Properties area menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new ContributionItem() { @Override public void fill(Menu menu, int index) { final IProject selectedProject = getSelectedProject(); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText(Messages.SingleProjectView_DeleteProjectMenuItem_LBL); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DeleteResourceAction action = new DeleteResourceAction(getPartSite()); action.selectionChanged(new StructuredSelection(selectedProject)); action.run(); } }); boolean enabled = (selectedProject != null && selectedProject.exists()); ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); item.setImage(enabled ? images.getImage(ISharedImages.IMG_TOOL_DELETE) : images.getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED)); item.setEnabled(enabled); } @Override public boolean isDynamic() { return true; } }); }
From source file:com.nokia.tools.carbide.ui.productsupport.perspectivehack.CarbideMenuCustomizer.java
License:Open Source License
@Override protected void customizeMenu(MenuManager mgr) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (MENU_WINDOW.equals(mgr.getId())) { // Preference -filter replaceAction(mgr, MENU_WINDOW_PREFERENCES, new Runnable() { public void run() { PreferenceDialog prefdlg = PreferencesUtil.createPreferenceDialogOn( Display.getCurrent().getActiveShell(), GENERAL_PREFERENCES_ID, new String[] { GENERAL_PREFERENCES_ID, EXTERNALTOOLS_PREFERENCES_ID, THIRDPARTYICONS_PREFERENCES_ID, PLUGINHANDLING_PREFERENCES_ID, COMPONENTSTORE_PREFERENCES_ID, PATHHANDLING_PREFERENCES_ID, STARTUPTIPS_PREFERENCES_ID, EXAMPLETHEMES_PREFERENCES_ID /* * UPDATE_INSTALL_PREFERENCES_ID, * AUTOMATIC_UPDATES_PREFERENCES_ID *///from w w w.j a v a2 s . com }, null); PreferenceManager pManager = prefdlg.getPreferenceManager(); pManager.remove(PREFERENCES_ANT); pManager.remove(PREFERENCES_JAVA); pManager.remove(PREFERENCES_RUN_DEBUG); pManager.remove(PREFERENCES_TEAM); prefdlg.open(); } }); // // Remove Other -command under Show View in Window-menu // for (IContributionItem item2 : mgr.getItems()) { // if (SHOW_VIEW_ID.equals(item2.getId())) { // if (item2 instanceof MenuManager) { // MenuManager mgr2 = (MenuManager) item2; // mgr2.getMenu().addMenuListener( // new MenuAdapter() { // // /* // * (non-Javadoc) // * // * @see // org.eclipse.swt.events.MenuAdapter#menuShown(org.eclipse.swt.events.MenuEvent) // */ // @Override // public void menuShown(MenuEvent e) { // Menu menu = ((Menu) e.widget); // // removes show other and // // separator // MenuItem[] items = menu // .getItems(); // if (items.length > 2) { // items[items.length - 1] // .dispose(); // items[items.length - 2] // .dispose(); // } // } // // }); // } // } // } } else if (MENU_FILE.equals(mgr.getId())) { removePropertiesMenuItem(mgr); // Import replacement IContributionItem contrib = mgr.find(MENU_FILE_IMPORT); if (contrib instanceof ActionContributionItem) { mgr.replaceItem(MENU_FILE_IMPORT, new ActionContributionItem(new ImportAction(window))); } // Export replacement contrib = mgr.find(MENU_FILE_EXPORT); if (contrib instanceof ActionContributionItem) { mgr.replaceItem(MENU_FILE_EXPORT, new ActionContributionItem(new ExportAction(window))); } } else if (MENU_HELP.equals(mgr.getId())) { replaceAction(mgr, MENU_HELP_ABOUT, new Runnable() { public void run() { new CarbideAboutDialog(Display.getCurrent().getActiveShell()).open(); } }); } }
From source file:com.nokia.tools.s60.ide.ContributedActionsResolver.java
License:Open Source License
/** * Method adds to menu action by given path. * /*from w w w. j a va 2 s .com*/ * @param manager * main context menu * @param groupName * specifies path to menu ,where should be action added. * @param action */ private void createMenu(IContributionManager manager, String groupName, IAction action) { String[] path = groupName.trim().split("\\\\"); MenuManager menu = (MenuManager) manager; //Fix for Reference color so that it does not appear for the icons. if (groupName.contains(Messages.Colors_Reference2Color)) { if (menu.find(BrowseForFileAction.ID) != null) return; } if (path.length > 0) { for (int i = 1; i < path.length; i++) { IContributionItem hMenu = menu.find(path[i]); if (hMenu == null) { hMenu = new HideableMenuManager(path[i]); } menu.add(hMenu); createGroup(menu, path[i], hMenu); // if (action.getMenuCreator()!=null){ // Menu subM = action.getMenuCreator().getMenu(menu.getMenu()); // // } menu = (MenuManager) hMenu; } } // Create Group createGroup(menu, groupName, action); }
From source file:com.nokia.tools.s60.ide.ContributedActionsResolver.java
License:Open Source License
/** * Method adds to menu group action./*from w ww .j a v a 2 s. c om*/ * * @param manager * where should be action added. * @param groupName * @param menu */ private void createGroup(MenuManager manager, String groupName, IContributionItem menu) { IContributionItem find = manager.find(groupName); if (find == null || !(find instanceof GroupMarker)) { // manager.f // menu. // new MenuItem(menu,SWT.SEPARATOR); manager.add(new GroupMarker(groupName)); } manager.appendToGroup(groupName, menu); }
From source file:de.loskutov.anyedit.actions.internal.StartupHelper.java
License:Open Source License
private static void insert(IDirtyWorkaround myAction, MenuManager menu) { IContributionItem item;//from w w w . java 2 s . co m String id = myAction.getId(); // get "file->save" action item = menu.find(id); if (item != null) { // copy references to opened editor/part myAction.copyStateAndDispose(item); // remember position int controlIdx = menu.indexOf(id); // clean old one menu.remove(item); item = new ActionContributionItem(myAction); menu.insert(controlIdx, item); // refresh menu gui menu.update(true); } }
From source file:fr.inria.linuxtools.tmf.ui.views.uml2sd.SDView.java
License:Open Source License
/** * Activate or deactivate the short key command given in parameter (see plugin.xml) * * @param id the command id defined in the plugin.xml * @param value the state value/*from w ww .j ava 2 s . com*/ */ public void setEnableCommand(String id, boolean value) { IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager() .find("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$ MenuManager shortKeys = (MenuManager) shortKeysMenu; if (shortKeys == null) { return; } IContributionItem item = shortKeys.find(id); if ((item != null) && (item instanceof ActionContributionItem)) { IAction action = ((ActionContributionItem) item).getAction(); if (action != null) { action.setEnabled(value); } } }
From source file:org.ebayopensource.vjet.eclipse.core.test.bug.BugVerifyTests.java
License:Open Source License
/** * For V1.0, vjet not support js refactoring * /*from w w w. j a va 2 s . c om*/ * @throws Exception */ public void test7829() throws Exception { //modify by patrick for support eclipse 3.5 final String vjetJSPerspectiveId = "org.eclipse.dltk.mod.javascript.ui.JavascriptPerspective"; final String VIEW_ID = "org.eclipse.dltk.mod.ui.ScriptExplorer"; IWorkbench workbench = VjetUIPlugin.getDefault().getWorkbench(); IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage activePage = workbench.showPerspective(vjetJSPerspectiveId, activeWindow); IViewPart viewPart = activePage.showView(VIEW_ID); ScriptExplorerPart scriptExplorer = (ScriptExplorerPart) viewPart; MenuManager menuManager = new MenuManager(); scriptExplorer.menuAboutToShow(menuManager); IContributionItem newMenuContributionItem = menuManager.find(IContextMenuConstants.GROUP_NEW); assertNotNull("The menu should be registered!", newMenuContributionItem); IContributionItem reorgContributionItem = menuManager.find(RefactorActionGroup.MENU_ID); assertNull("The menu should not be registered!", reorgContributionItem); }
From source file:org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView.java
License:Open Source License
/** * Activate or deactivate the short key command given in parameter (see plugin.xml) * //from w w w . j a v a 2 s. c o m * @param id the command id defined in the plugin.xml * @param value the state value */ public void setEnableCommand(String id, boolean value) { IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager() .find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$ MenuManager shortKeys = (MenuManager) shortKeysMenu; if (shortKeys == null) return; IContributionItem item = shortKeys.find(id); if ((item != null) && (item instanceof ActionContributionItem)) { IAction action = ((ActionContributionItem) item).getAction(); if (action != null) action.setEnabled(value); } }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.menu.DiagramMenuUpdater.java
License:Open Source License
/** * Returns the Arrange Menu Manager (contained in the "Diagram" Menu). * /*from ww w . j a v a2s .co m*/ * @return the Arrange Menu Manager, containing all the items related to * arrange actions */ @SuppressWarnings("restriction") private Option<IMenuManager> getArrangeMenuManager() { Option<IMenuManager> arrangeMenuManagerOption = Options.newNone(); MenuManager menuManager = null; // Step 1 : we get the active workbench's window's menuManager IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null) { IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window instanceof WorkbenchWindow) { menuManager = ((WorkbenchWindow) window).getMenuManager(); } } if (menuManager == null) { return arrangeMenuManagerOption; } // Step 2 : we get the arrangeMenu Manager IContributionItem diagramMenu = menuManager.find(ActionIds.MENU_DIAGRAM); if (diagramMenu instanceof SubContributionItem) { IContributionItem diagramMenuContributionItem = ((SubContributionItem) diagramMenu).getInnerItem(); if (diagramMenuContributionItem instanceof IMenuManager) { IMenuManager diagMenuManager = (IMenuManager) diagramMenuContributionItem; IContributionItem arrangeMenu = diagMenuManager.find(ActionIds.MENU_ARRANGE); if (arrangeMenu instanceof SubContributionItem) { IContributionItem arrangeMenuContributionItem = ((SubContributionItem) arrangeMenu) .getInnerItem(); if (arrangeMenuContributionItem instanceof IMenuManager) { arrangeMenuManagerOption = Options.newSome((IMenuManager) arrangeMenuContributionItem); } } } } return arrangeMenuManagerOption; }
From source file:org.eclipse.sirius.tests.unit.diagram.navigation.OpenMenuTest.java
License:Open Source License
private List<ActionContributionItem> getOpenContributions() { // The "popupMenu" created below is just a mock of the real menu // structure we would have at runtime. It is created so that we can // ContributionItemService.getInstance().contributeToPopupMenu() and // then check the entries added to the open menu. MenuManager popupMenu = new MenuManager(); // We must override isGroupMarker() so that the two following menus // support the addition of elements, which may be defined in the VSM and // will be added by contributeToPopupMenu(). popupMenu.add(new MenuManager("additions", "additions") {//$NON-NLS-1$ //$NON-NLS-2$ @Override// w w w . j ava 2 s. co m public boolean isGroupMarker() { return true; } }); popupMenu.add(new MenuManager("popup.open", "popup.open") {//$NON-NLS-1$ //$NON-NLS-2$ @Override public boolean isGroupMarker() { return true; } }); ContributionItemService.getInstance().contributeToPopupMenu(popupMenu, EclipseUIUtil.getActivePage().getActivePart()); final IMenuManager openMenu = (IMenuManager) popupMenu.find("popup.open"); final IContributionItem[] items = openMenu.getItems(); final List<ActionContributionItem> actionContributions = Lists.newArrayList(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof ActionContributionItem) { actionContributions.add((ActionContributionItem) items[i]); } } return actionContributions; }