List of usage examples for org.eclipse.jface.action IContributionItem getId
String getId();
From source file:ca.mcgill.cs.swevo.qualyzer.editors.RTFEditor.java
License:Open Source License
@Override protected void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); menu.remove(ITextEditorActionConstants.GROUP_OPEN); menu.remove(ITextEditorActionConstants.GROUP_PRINT); menu.remove(ITextEditorActionConstants.GROUP_ADD); menu.remove(ITextEditorActionConstants.GROUP_REST); menu.remove(ITextEditorActionConstants.SHIFT_RIGHT); menu.remove(ITextEditorActionConstants.SHIFT_LEFT); menu.remove(ITextEditorActionConstants.GROUP_FIND); menu.remove(IWorkbenchActionConstants.MB_ADDITIONS); menu.remove(ITextEditorActionConstants.GROUP_SETTINGS); menu.remove(ITextEditorActionConstants.CONTEXT_PREFERENCES); for (IContributionItem item : menu.getItems()) { if (item.getId() == null) { menu.remove(item);/*from w ww .j a v a 2s .c o m*/ } } addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.BOLD_ACTION_ID); addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.ITALIC_ACTION_ID); addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.UNDERLINE_ACTION_ID); addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.FRAGMENT_ACTION_ID); if (isRemoveVisible()) { addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.VIEW_FRAGMENTS_ACTION_ID); addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.REMOVE_CODE_ACTION_ID); addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.REMOVE_ALL_CODES_ACTION_ID); } //check according to selection fBoldAction.setChecked(isBoldChecked()); fItalicAction.setChecked(isItalicChecked()); fUnderlineAction.setChecked(isUnderlineChecked()); }
From source file:com.amazonaws.eclipse.explorer.actions.ConfigurationActionProvider.java
License:Apache License
/** * This method is invoked whenever the selection in the viewer changes, so * we need to make sure not to add our action more than once. *///from w w w . j a v a2s . c o m @Override public void fillActionBars(IActionBars actionBars) { for (IContributionItem item : actionBars.getToolBarManager().getItems()) { if (item.getId() == regionSelectionAction.getId()) return; } actionBars.getToolBarManager().add(new Separator()); actionBars.getToolBarManager().add(refreshAction); actionBars.getToolBarManager().add(new Separator()); actionBars.getToolBarManager().add(regionSelectionAction); MenuManager menuMgr = new MenuManager("AWS Account", AwsToolkitCore.getDefault().getImageRegistry().getDescriptor(AwsToolkitCore.IMAGE_AWS_ICON), ""); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { String currentAccountId = AwsToolkitCore.getDefault().getCurrentAccountId(); Map<String, String> accounts = AwsToolkitCore.getDefault().getAccounts(); for (Entry<String, String> entry : accounts.entrySet()) { manager.add(new SwitchAccountAction(entry.getKey(), entry.getValue(), currentAccountId.equals(entry.getKey()))); } manager.add(new Separator()); manager.add(new AccountPreferencesAction()); } }); actionBars.getMenuManager().add(menuMgr); actionBars.getToolBarManager().update(true); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas.java
License:Open Source License
/** * Returns the action for the context menu corresponding to the given action id. * <p/>/*from w w w.j av a 2 s .c o m*/ * For global actions such as copy or paste, the action id must be composed of * the {@link #PREFIX_CANVAS_ACTION} followed by one of {@link ActionFactory}'s * action ids. * <p/> * Returns null if there's no action for the given id. */ IAction getAction(String actionId) { String prefix = PREFIX_CANVAS_ACTION; if (mMenuManager == null || actionId == null || !actionId.startsWith(prefix)) { return null; } actionId = actionId.substring(prefix.length()); for (IContributionItem contrib : mMenuManager.getItems()) { if (contrib instanceof ActionContributionItem && actionId.equals(contrib.getId())) { return ((ActionContributionItem) contrib).getAction(); } } return null; }
From source file:com.android.ide.eclipse.auidt.internal.editors.layout.gle2.LayoutCanvas.java
License:Open Source License
/** * Returns the action for the context menu corresponding to the given action id. * <p/>//from w w w. j a v a2s .c o m * For global actions such as copy or paste, the action id must be composed of * the {@link #PREFIX_CANVAS_ACTION} followed by one of {@link ActionFactory}'s * action ids. * <p/> * Returns null if there's no action for the given id. */ /* package */ IAction getAction(String actionId) { String prefix = PREFIX_CANVAS_ACTION; if (mMenuManager == null || actionId == null || !actionId.startsWith(prefix)) { return null; } actionId = actionId.substring(prefix.length()); for (IContributionItem contrib : mMenuManager.getItems()) { if (contrib instanceof ActionContributionItem && actionId.equals(contrib.getId())) { return ((ActionContributionItem) contrib).getAction(); } } return null; }
From source file:com.aptana.editor.common.CommonTextEditorActionContributor.java
License:Open Source License
@Override public void contributeToStatusLine(IStatusLineManager statusLineManager) { commandsMenuContributionItem = new CommandsMenuContributionItem(); statusLineManager.add(commandsMenuContributionItem); super.contributeToStatusLine(statusLineManager); inputPositionStatsContributionItem = new StatusLineContributionItem( ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION, true, 24); IContributionItem[] contributionItems = statusLineManager.getItems(); for (IContributionItem contributionItem : contributionItems) { String id = contributionItem.getId(); if (ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION.equals(id)) { statusLineManager.remove(contributionItem); statusLineManager.add(inputPositionStatsContributionItem); }//from www . jav a2 s . com } }
From source file:com.aptana.explorer.internal.ui.GitProjectView.java
License:Open Source License
@Override protected void mangleContextMenu(Menu menu) { GitRepository repo = getGitRepositoryManager().getAttached(selectedProject); // Remove Team menu if project is attached to our git provider. if (repo != null || selectedProject == null || !selectedProject.isAccessible()) { Set<String> toRemove = new HashSet<String>(); toRemove.add(TEAM_MAIN);/*from w ww .j av a 2s .c om*/ removeMenuItems(menu, toRemove); } else { RepositoryProvider provider = RepositoryProvider.getProvider(selectedProject); if (provider == null) { // no other provider, keep Team menu, but modify it's submenu MenuItem[] menuItems = menu.getItems(); for (int i = 0; i < menuItems.length; i++) { MenuItem menuItem = menuItems[i]; Object data = menuItem.getData(); if (data instanceof IContributionItem) { IContributionItem contrib = (IContributionItem) data; // Just replace team with initialize git repo if (TEAM_MAIN.equals(contrib.getId())) { addAttachItem(menu, i + 1); break; } } } Set<String> toRemove = new HashSet<String>(); toRemove.add(TEAM_MAIN); removeMenuItems(menu, toRemove); } } // Remove all the other stuff we normally do... super.mangleContextMenu(menu); }
From source file:com.aptana.explorer.internal.ui.SingleProjectView.java
License:Open Source License
private void forceOurNewFileWizard(Menu menu) { // Hack the New > File entry for (MenuItem menuItem : menu.getItems()) { Object data = menuItem.getData(); if (data instanceof IContributionItem) { IContributionItem contrib = (IContributionItem) data; if ("common.new.menu".equals(contrib.getId())) //$NON-NLS-1$ {/*from w w w.j av a 2 s . c om*/ MenuManager manager = (MenuManager) contrib; // force an entry for our special template New File wizard! IWizardRegistry registry = PlatformUI.getWorkbench().getNewWizardRegistry(); IWizardDescriptor desc = registry.findWizard("com.aptana.ui.wizards.new.file"); //$NON-NLS-1$ manager.insertAfter("new", new WizardShortcutAction(PlatformUI.getWorkbench() //$NON-NLS-1$ .getActiveWorkbenchWindow(), desc)); manager.remove("new"); //$NON-NLS-1$ break; } } } }
From source file:com.aptana.explorer.internal.ui.SingleProjectView.java
License:Open Source License
protected void removeMenuItems(Menu menu, Set<String> idsToRemove) { if (idsToRemove == null || idsToRemove.isEmpty()) { return;//from w w w .j a v a 2 s.c o m } for (MenuItem menuItem : menu.getItems()) { Object data = menuItem.getData(); if (data instanceof IContributionItem) { IContributionItem contrib = (IContributionItem) data; if (idsToRemove.contains(contrib.getId())) { menuItem.dispose(); } } } }
From source file:com.aptana.ide.core.ui.actions.AbstractWorkbenchWindowPulldownDelegate.java
License:Open Source License
/** * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) *///from w w w .ja v a2s.c o m public void run(IAction action) { String id = action.getId(); ToolItem widget = null; WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow(); CoolBarManager manager = window.getCoolBarManager(); CoolBar parent = manager.getControl(); // this returns the list of actionSets groups IContributionItem[] items = manager.getItems(); for (IContributionItem item : items) { if (item instanceof IToolBarContributionItem) { IToolBarContributionItem toolbarItem = (IToolBarContributionItem) item; // this returns the list of actual items for the actions IContributionItem[] children = toolbarItem.getToolBarManager().getItems(); for (IContributionItem child : children) { if (child.getId().equals(id)) { // found the toolbar item that corresponds to the action ActionContributionItem actionItem = (ActionContributionItem) child; if (CoreUIUtils.inEclipse34orHigher) { // uses the 3.4 API widget = (ToolItem) actionItem.getWidget(); } break; } } } } Menu menu = getMenu(parent); if (widget != null) { // sets the location of where the menu is displayed to be the same // as when the dropdown arrow is clicked Rectangle bounds = widget.getBounds(); Point point = widget.getParent().toDisplay(bounds.x, bounds.y + bounds.height); menu.setLocation(point); } menu.setVisible(true); }
From source file:com.centurylink.mdw.plugin.actions.MdwMenuManager.java
License:Apache License
@Override public IContributionItem[] getItems() { IContributionItem[] items = super.getItems(); List<IContributionItem> mdwItems = null; if (items != null) { mdwItems = new ArrayList<IContributionItem>(); for (IContributionItem item : items) { if (item != null && item.getId() != null && item.getId().startsWith(MDW_MENU_PREFIX)) mdwItems.add(item);//from w w w . j ava 2s .co m } } return mdwItems == null ? null : mdwItems.toArray(new IContributionItem[0]); }