List of usage examples for org.eclipse.jface.action IContributionManager add
void add(IContributionItem item);
From source file:org.eclipse.datatools.sqltools.plan.internal.ui.view.PlanView.java
License:Open Source License
public static void createStandardGroups(IContributionManager menu) { menu.add(new Separator(GROUP_NAVIGATE)); menu.add(new GroupMarker(GROUP_REMOVE)); menu.add(new Separator(GROUP_IO)); menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menu.add(new Separator(GROUP_HISTORY)); menu.add(new Separator(GROUP_MODE)); }
From source file:org.eclipse.dawnsci.slicing.api.AbstractSliceSystem.java
License:Open Source License
protected void createCustomActions(IContributionManager man) { if (customActions != null) { man.add(new Separator("group5")); for (IAction action : customActions) man.add(action);/* www .j ava 2 s . c o m*/ } }
From source file:org.eclipse.eatop.examples.explorer.ModelExampleActionProvider.java
License:Open Source License
@Override protected void populateManager(IContributionManager manager, Map<String, Collection<IAction>> submenuActions, String contributionId) {//ww w . jav a 2 s. co m if (submenuActions != null) { for (Map.Entry<String, Collection<IAction>> entry : submenuActions.entrySet()) { StringTokenizer st = new StringTokenizer(entry.getKey(), "|"); //$NON-NLS-1$ int count = st.countTokens(); IContributionManager lastManager = manager; for (int i = 0; i < count; i++) { MenuManager submenuManager = new MenuManager(st.nextToken()); if (contributionId != null) { lastManager.insertBefore(contributionId, submenuManager); } else { lastManager.add(submenuManager); } lastManager = submenuManager; if (i == count - 1) { populateManager(submenuManager, entry.getValue(), null); } } } } }
From source file:org.eclipse.emf.compare.examples.addressbook.addressbook.presentation.AddressbookActionBarContributor.java
License:Open Source License
/** * This populates the specified <code>manager</code> with * {@link org.eclipse.jface.action.ActionContributionItem}s based on the * {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, by * inserting them before the specified contribution item <code>contributionID</code>. If * <code>contributionID</code> is <code>null</code>, they are simply added. <!-- begin-user-doc --> <!-- * end-user-doc -->//from w w w. java2 s .c o m * * @generated */ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { if (actions != null) { for (final IAction action : actions) { if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } } }
From source file:org.eclipse.epf.authoring.ui.actions.LibraryActionBarContributor.java
License:Open Source License
/** * This populates the specified <code>manager</code> with * {@link org.eclipse.jface.action.ActionContributionItem}s based on the * {@link org.eclipse.jface.action.IAction}s contained in the * <code>actions</code> collection, by inserting them before the specified * contribution item <code>contributionID</code>. If <code>ID</code> is * <code>null</code>, they are simply added. */// ww w . j a va 2 s . co m protected void populateManager(IContributionManager manager, Collection actions, String contributionID) { if (actions != null) { for (Iterator i = actions.iterator(); i.hasNext();) { Object obj = i.next(); if (obj instanceof IAction) { IAction action = (IAction) obj; if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } else if (obj instanceof Separator) { manager.add((Separator) obj); } } } }
From source file:org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider.java
License:Open Source License
/** * Contributes the given item to the given manager in the given path/group. * //w w w . j ava2s . c om * @param contributionItem * The item to be contributed * @param contributionManager * The manager to be contributed to * @param path * The path of contribution within the manager * @param group * The group of contribution within the path */ private void contributeItem(IAdaptable contributionItemAdapter, IContributionManager contributionManager, String path, String group) { // Find parent menu. if (path == null) return; IContributionManager parent = contributionManager; if (path.length() > 1) { // if path is more than '/' parent = findMenuUsingPath(parent, path.substring(1)); if (parent == null) { Log.info(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionStatusCodes.SERVICE_FAILURE, "The contribution item path is invalid"); //$NON-NLS-1$ return; } } //if contributing a menu group if (contributionItemAdapter instanceof MenuGroupContributionItemAdapter) { IContributionItem contributionItem = (IContributionItem) contributionItemAdapter .getAdapter(IContributionItem.class); parent.add(contributionItem); return; } //if contributing an action group if (contributionItemAdapter instanceof ActionGroupContributionItemAdapter) { try { ActionGroup actionGroup = (ActionGroup) contributionItemAdapter.getAdapter(ActionGroup.class); if (parent instanceof IMenuManager) { actionGroup.fillContextMenu((IMenuManager) parent); } } catch (IllegalArgumentException e) { Trace.catching(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionDebugOptions.EXCEPTIONS_CATCHING, CommonUIServicesActionPlugin.getDefault().getClass(), "Error adding contribution item", e); //$NON-NLS-1$ Log.error(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionStatusCodes.SERVICE_FAILURE, "Error adding contribution item", e); //$NON-NLS-1$ } return; } // Find reference group. if (group == null) return; IContributionItem sep = parent.find(group); if (sep == null) { if (group.equals(ContributionItemConstants.GROUP_ADDITIONS)) { sep = new Separator(group); parent.add(sep); } if (sep == null) { Log.info(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionStatusCodes.SERVICE_FAILURE, "The contribution item group is invalid"); //$NON-NLS-1$ return; } } // Add contribution to group try { IContributionItem contributionItem = (IContributionItem) contributionItemAdapter .getAdapter(IContributionItem.class); if (contributionItem != null) { if (sep.isGroupMarker()) parent.appendToGroup(group, contributionItem); else parent.insertAfter(group, contributionItem); } else Log.info(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionStatusCodes.SERVICE_FAILURE, "Failed to create the contribution with id: " //$NON-NLS-1$ + (String) contributionItemAdapter.getAdapter(String.class)); } catch (IllegalArgumentException e) { Trace.catching(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionDebugOptions.EXCEPTIONS_CATCHING, CommonUIServicesActionPlugin.getDefault().getClass(), "Error adding contribution item", e); //$NON-NLS-1$ Log.error(CommonUIServicesActionPlugin.getDefault(), CommonUIServicesActionStatusCodes.SERVICE_FAILURE, "Error adding contribution item", e); //$NON-NLS-1$ } }
From source file:org.eclipse.handly.ui.outline.OutlineActionContribution.java
License:Open Source License
/** * Contributes the given action contribution item to the given manager. * <p>//from w ww . ja va 2 s . c om * Default implementation calls <code>manager.add(item)</code>. * Subclasses may override. * </p> * * @param item never <code>null</code> * @param manager never <code>null</code> */ protected void contribute(ActionContributionItem item, IContributionManager manager) { manager.add(item); }
From source file:org.eclipse.jst.jsp.ui.tests.viewer.ViewerTestJSP.java
License:Open Source License
protected void addActions(IContributionManager mgr) { if (mgr != null) { mgr.add(new Action() { public String getText() { return getToolTipText(); }// ww w. j a v a2 s . c o m public String getToolTipText() { return "New JSP"; } public void run() { super.run(); BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() { public void run() { setupViewerForNew(); fSourceViewer.setEditable(true); } }); } }); mgr.add(new Separator()); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Change Visibility"; } public void run() { super.run(); NumberInputDialog dlg = new NumberInputDialog(fSourceViewer.getControl().getShell()); int proceed = dlg.open(); if (proceed == Window.CANCEL) return; fSourceViewer.resetVisibleRegion(); fSourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue); } }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Show All"; } public void run() { super.run(); fSourceViewer.resetVisibleRegion(); } }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Change Visibility in Editor"; } public void run() { super.run(); StructuredTextViewer sourceViewer = null; IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor(); if (part != null && part instanceof StructuredTextEditor) { sourceViewer = ((StructuredTextEditor) part).getTextViewer(); } if (sourceViewer != null) { NumberInputDialog dlg = new NumberInputDialog(sourceViewer.getControl().getShell()); int proceed = dlg.open(); if (proceed == Window.CANCEL) return; sourceViewer.resetVisibleRegion(); sourceViewer.setVisibleRegion(dlg.startValue, dlg.lengthValue); } } }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Show All in Editor"; } public void run() { super.run(); StructuredTextViewer sourceViewer = null; IEditorPart part = getViewSite().getWorkbenchWindow().getActivePage().getActiveEditor(); if (part != null && part instanceof StructuredTextEditor) { sourceViewer = ((StructuredTextEditor) part).getTextViewer(); } if (sourceViewer != null) { sourceViewer.resetVisibleRegion(); } } }); mgr.add(new Separator()); // no longer able to set input to NULL // mgr.add(new Action() { // public String getText() { // return getToolTipText(); // } // // public String getToolTipText() { // return "Set Input to NULL"; // } // public void run() { // super.run(); // viewer.setInput(null); // } // }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Take Input from Active Editor"; } public void run() { super.run(); ITextEditor textEditor = getActiveEditor(); if (textEditor != null) { setupViewerForEditor(textEditor); fSourceViewer.setEditable(true); } } }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Take Input and Follow Selection"; } public void run() { super.run(); followSelection(); fSourceViewer.setEditable(true); } }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Take Input and Follow Selection As ReadOnly"; } public void run() { super.run(); followSelection(); fSourceViewer.setEditable(false); } }); mgr.add(new Action() { public String getText() { return getToolTipText(); } public String getToolTipText() { return "Stop Following Selection"; } public void run() { super.run(); stopFollowSelection(); } }); } }
From source file:org.eclipse.mylyn.internal.sandbox.ui.views.ActiveSearchView.java
License:Open Source License
private void fillActions(IContributionManager manager) { List<AbstractContextUiBridge> bridges = ContextUiPlugin.getDefault().getUiBridges(); for (AbstractContextUiBridge uiBridge : bridges) { Set<AbstractRelationProvider> providers = ContextCorePlugin.getDefault() .getRelationProviders(uiBridge.getContentType()); if (providers != null && providers.size() > 0) { ToggleRelationshipProviderAction action = new ToggleRelationshipProviderAction(this, providers, uiBridge);//from www. j a v a2 s . c om relationshipProviderActions.add(action); manager.add(action); } } }
From source file:org.eclipse.net4j.buddies.chat.internal.ui.ChatPane.java
License:Open Source License
@Override protected void fillCoolBar(IContributionManager manager) { manager.add(new SafeAction(Messages.getString("ChatPane.2"), Messages.getString("ChatPane.3"), SharedIcons //$NON-NLS-1$ //$NON-NLS-2$ .getDescriptor(SharedIcons.ETOOL_VERTICAL)) { @Override// ww w.j a v a 2 s . c om protected void safeRun() throws Exception { sashComposite.setVertical(true); } }); manager.add(new SafeAction(Messages.getString("ChatPane.4"), Messages.getString("ChatPane.5"), SharedIcons //$NON-NLS-1$ //$NON-NLS-2$ .getDescriptor(SharedIcons.ETOOL_HORIZONTAL)) { @Override protected void safeRun() throws Exception { sashComposite.setVertical(false); } }); }