List of usage examples for org.eclipse.jface.action IToolBarManager remove
IContributionItem remove(String id);
From source file:org.eclipse.ui.tests.api.MockViewPart.java
License:Open Source License
public void createPartControl(Composite parent) { super.createPartControl(parent); Button addAction = new Button(parent, SWT.PUSH); addAction.setText("Add Action to Tool Bar"); addAction.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IActionBars bars = getViewSite().getActionBars(); bars.getToolBarManager().add(new DummyAction()); bars.updateActionBars();//from w w w . j a v a 2 s. com } }); Button removeAction = new Button(parent, SWT.PUSH); removeAction.setText("Remove Action from Tool Bar"); removeAction.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IActionBars bars = getViewSite().getActionBars(); IToolBarManager tbm = bars.getToolBarManager(); IContributionItem[] items = tbm.getItems(); if (items.length > 0) { IContributionItem item = items[items.length - 1]; if (item instanceof ActionContributionItem) { if (((ActionContributionItem) item).getAction() instanceof DummyAction) { tbm.remove(item); bars.updateActionBars(); } } } } }); }
From source file:org.eclipse.wst.sse.ui.internal.ExtendedEditorActionBuilder.java
License:Open Source License
/** * Contributes action from the action descriptor into the provided tool * bar manager./*w w w. j a v a2s . co m*/ */ protected boolean contributeToolbarAction(ActionDescriptor ad, IToolBarManager toolbar, boolean appendIfMissing) { if (ad.getContributionItem() == null || ad.getAction() == null) return false; // Get config data. String tpath = ad.getToolbarPath(); String tgroup = ad.getToolbarGroup(); if (tpath == null && tgroup == null) return false; // First remove existing toolbar item IContributionItem item = toolbar.find(ad.getId()); if (item != null) { toolbar.remove(ad.getId()); } // Find reference group. if (tgroup == null) tgroup = IWorkbenchActionConstants.MB_ADDITIONS; IContributionItem sep = toolbar.find(tgroup); if (sep == null) { if (appendIfMissing) toolbar.add(new Separator(tgroup)); else { Logger.log(Logger.ERROR, "Invalid Toolbar Extension (Group is invalid): " + ad.getId()); //$NON-NLS-1$ return false; } } // Add action to tool bar. try { if (sep != null && sep.isGroupMarker()) toolbar.appendToGroup(sep.getId(), ad.getAction()); else toolbar.insertAfter(tgroup, ad.getAction()); } catch (IllegalArgumentException e) { Logger.log(Logger.ERROR, "Invalid Toolbar Extension (Group is missing): " + ad.getId()); //$NON-NLS-1$ return false; } return true; }
From source file:org.eclipse.xtend.ide.highlighting.ShowWhitespaceCharactersActionContributor.java
License:Open Source License
@Override public void editorDisposed(XtextEditor editor) { IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager(); IContributionItem i = toolBarManager.remove(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS); if (i instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) i).getAction(); if (action instanceof ShowWhitespaceCharactersAction) { ((ShowWhitespaceCharactersAction) action).setEditor(null); }/*from w ww. ja va 2 s . co m*/ } }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.cpu.CpuSection.java
License:Open Source License
@Override protected void removeToolBarActions(IToolBarManager manager) { manager.remove(suspendCpuProfilingAction.getId()); manager.remove(resumeCpuProfilingAction.getId()); manager.remove(clearCpuProfilingDataAction.getId()); manager.remove(dumpCpuProfilingDataAction.getId()); manager.remove(separator);//from w ww. j a v a 2s .c o m }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.mbean.MBeansSection.java
License:Open Source License
@Override protected void removeToolBarActions(IToolBarManager manager) { manager.remove(separator); manager.remove(refreshAction.getId()); }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.memory.HeapHistogramPage.java
License:Open Source License
/** * Removes the tool bar actions.//from w w w . j a va2 s. c o m * * @param manager * The tool bar manager */ void removeToolBarActions(IToolBarManager manager) { manager.remove(separator); manager.remove(refreshAction.getId()); manager.remove(garbageCollectorAction.getId()); manager.remove(clearHeapDeltaAction.getId()); manager.remove(dumpHeapAction.getId()); manager.remove(dumpHprofAction.getId()); manager.update(true); }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.memory.SWTResourcesPage.java
License:Open Source License
/** * Removes the tool bar actions./* ww w. j a v a 2 s .c om*/ * * @param manager * The tool bar manager */ void removeToolBarActions(IToolBarManager manager) { manager.remove(separator); manager.remove(refreshAction.getId()); manager.remove(clearSWTResourceAction.getId()); manager.update(true); }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.thread.ThreadsSection.java
License:Open Source License
@Override protected void removeToolBarActions(IToolBarManager manager) { manager.remove(separator); manager.remove(refreshAction.getId()); manager.remove(dumpThreadsAction.getId()); }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.timeline.TimelineSection.java
License:Open Source License
@Override protected void removeToolBarActions(IToolBarManager manager) { manager.remove(separator); manager.remove(refreshAction.getId()); manager.remove(clearAction.getId()); manager.remove(newChartAction.getId()); }
From source file:org.fusesource.ide.zk.core.editors.DataModelFormEditor.java
License:Apache License
protected void addImageHyperlinkToolBarContribution(final IManagedForm headerForm, final IToolBarManager toolBarManager, final BaseControlContribution baseControlContribution, final DataModel<?, ?, ?> model) { final Separator separator = new Separator(); toolBarManager.add(separator);/*from w w w . j a v a2 s. co m*/ toolBarManager.add(baseControlContribution); baseControlContribution.addControlDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (!model.isDestroyed()) { // Only do this clean up when the model destruction caused the widget disposal // WARNING: toolBarManager.update(true); throws a NullPointer if called during app exit. return; } toolBarManager.remove(separator); separator.dispose(); toolBarManager.remove(baseControlContribution); toolBarManager.update(true); } }); }