List of usage examples for org.eclipse.jface.action IToolBarManager removeAll
void removeAll();
From source file:org.eclipse.viatra.addon.viewers.runtime.zest.extensions.IncQueryViewersZestViewSupport.java
License:Open Source License
public void createToolbar() { refreshGraph.setImageDescriptor(/*from w w w. j av a 2s. c om*/ ViewersZestPlugin.imageDescriptorFromPlugin(ViewersZestPlugin.PLUGIN_ID, "icons/refresh.gif")); clearGraph.setImageDescriptor( ViewersZestPlugin.imageDescriptorFromPlugin(ViewersZestPlugin.PLUGIN_ID, "icons/clear.gif")); IToolBarManager toolBarManager = getOwner().getViewSite().getActionBars().getToolBarManager(); toolBarManager.removeAll(); toolBarManager.add(refreshGraph); toolBarManager.add(clearGraph); if (owner instanceof IZoomableWorkbenchPart) { ZoomContributionViewItem toolbarZoomContributionViewItem = new ZoomContributionViewItem( (IZoomableWorkbenchPart) owner); toolBarManager.add(toolbarZoomContributionViewItem); toolBarManager.update(true); } IMenuManager menuManager = getOwner().getViewSite().getActionBars().getMenuManager(); menuManager.removeAll(); menuManager.add(createLayoutMenu()); }
From source file:org.eclipse.wst.server.ui.internal.editor.ServerEditorActionBarContributor.java
License:Open Source License
/** * Sets the active editor for the contributor. * <p>/*from w w w . j a v a2 s. com*/ * The <code>EditorActionBarContributor</code> implementation of this method does * nothing. Subclasses may reimplement. This generally entails disconnecting * from the old editor, connecting to the new editor, and updating the actions * to reflect the new editor. * </p> * * @param targetEditor the new target editor */ public void setActiveEditor(IEditorPart targetEditor) { super.setActiveEditor(targetEditor); if (targetEditor != null && targetEditor.equals(editor)) return; IActionBars actionBars = getActionBars(); boolean actionBarsUpdated = false; if (editor != null) { editor.setStatus(null, null); IStatusLineManager status = actionBars.getStatusLineManager(); status.removeAll(); IToolBarManager tbm = actionBars.getToolBarManager(); tbm.removeAll(); actionBarsUpdated = true; } if (targetEditor instanceof ServerEditor) { editor = (ServerEditor) targetEditor; if (Trace.FINEST) { Trace.trace(Trace.STRING_FINEST, "Editor action bar contributor for: " + editor); } editor.updateUndoAction(); editor.updateRedoAction(); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), editor.getUndoAction()); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), editor.getRedoAction()); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), editor.getCopyAction()); actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), editor.getCutAction()); actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), editor.getPasteAction()); IStatusLineManager status = actionBars.getStatusLineManager(); StatusLineContributionItem item = new StatusLineContributionItem("id"); status.add(item); editor.setStatus(status, item); editor.updateStatusLine(); IAction[] actions = editor.getEditorActions(); IToolBarManager tbm = actionBars.getToolBarManager(); tbm.add(new Separator(SERVER_EDITOR_SEPARATOR)); boolean modified = false; if (actions != null) { int size = actions.length; if (Trace.FINEST) { Trace.trace(Trace.STRING_FINEST, "Attempting to add editor actions: " + size); } for (int i = 0; i < size; i++) { if (Trace.FINEST) { Trace.trace(Trace.STRING_FINEST, "action: " + actions[i]); } tbm.appendToGroup(SERVER_EDITOR_SEPARATOR, actions[i]); modified = true; } } if (modified) tbm.update(false); actionBarsUpdated = true; } else editor = null; if (actionBarsUpdated) actionBars.updateActionBars(); }
From source file:org.jboss.tools.central.editors.JBossCentralEditor.java
License:Open Source License
@Override protected void createHeaderContents(IManagedForm headerForm) { final ScrolledForm form = headerForm.getForm(); //form.setText(JBOSS_CENTRAL); new HeaderText(form); form.setToolTipText(JBOSS_CENTRAL);// ww w . jav a2 s. c om form.setImage(getHeaderImage()); getToolkit().decorateFormHeading(form.getForm()); final IToolBarManager toolbar = form.getToolBarManager(); ControlContribution searchControl = new ControlContribution("Search") { @Override protected Control createControl(Composite parent) { return createSearchControl(parent); } }; toolbar.add(searchControl); toolbar.add(new GroupMarker(COMMANDS_GROUP)); String[] commandIds = ProjectExamplesActivator.getDefault().getConfigurator().getMainToolbarCommandIds(); for (String commandId : commandIds) { CommandContributionItem item = JBossCentralActivator.createContributionItem(getSite(), commandId); toolbar.appendToGroup(COMMANDS_GROUP, item); } toolbar.update(true); form.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (toolbar instanceof ToolBarManager) { ((ToolBarManager) toolbar).dispose(); } else { toolbar.removeAll(); } form.removeDisposeListener(this); } }); form.layout(true, true); }
From source file:org.mwc.cmap.TimeController.views.TimeController.java
License:Open Source License
/** * ok - put in the stepper mode buttons - and any others we think of. */// w w w . ja v a 2 s .co m void populateDropDownList(final LayerPainterManager myLayerPainterManager) { // clear the list final IMenuManager menuManager = getViewSite().getActionBars().getMenuManager(); final IToolBarManager toolManager = getViewSite().getActionBars().getToolBarManager(); // ok, remove the existing items menuManager.removeAll(); toolManager.removeAll(); // create a host for when we're populating the properties window final ISelectionProvider provider = this; // right, do we have something with editable layer details? if (myLayerPainterManager != null) { // ok - add the painter selectors/editors createPainterOptions(myLayerPainterManager, menuManager, toolManager, provider); // ok, let's have a separator toolManager.add(new Separator()); // now add the highlighter options/editors createHighlighterOptions(myLayerPainterManager, menuManager, provider); // and another separator menuManager.add(new Separator()); } // add the list of DTG formats for the DTG slider addDateFormats(menuManager); // add the list of DTG formats for the DTG slider addBiSliderResolution(menuManager); // and another separator menuManager.add(new Separator()); // and another separator toolManager.add(new Separator()); // let user indicate whether we should be filtering to window _filterToSelectionAction = new Action("Filter to period", Action.AS_CHECK_BOX) { @Override public void run() { super.run(); if (isChecked()) { final HiResDate tNow = _myTemporalDataset.getTime(); if (tNow != null) { TimePeriod period = _controllablePeriod.getPeriod(); if (period != null) { if (!period.contains(tNow)) { if (tNow.greaterThan(period.getEndDTG())) { fireNewTime(period.getEndDTG()); } else { fireNewTime(period.getStartDTG()); } } stopPlayingTimer(); } } } } }; _filterToSelectionAction.setImageDescriptor(CorePlugin.getImageDescriptor(ICON_FILTER_TO_PERIOD)); _filterToSelectionAction.setToolTipText("Filter plot data to selected time period"); menuManager.add(_filterToSelectionAction); toolManager.add(_filterToSelectionAction); // and another separator menuManager.add(new Separator()); // now the add-bookmark item final Action _setAsBookmarkAction = new Action("Add DTG as bookmark", Action.AS_PUSH_BUTTON) { public void runWithEvent(final Event event) { addMarker(); } }; _setAsBookmarkAction.setImageDescriptor(CorePlugin.getImageDescriptor(ICON_BKMRK_NAV)); _setAsBookmarkAction.setToolTipText("Add this DTG to the list of bookmarks"); _setAsBookmarkAction.setId(OP_LIST_MARKER_ID); // give it an id, so we can menuManager.add(_setAsBookmarkAction); // refer to this later on. // and another separator menuManager.add(new Separator()); // now our own menu editor final Action toolboxProperties = new Action("Edit Time controller properties", Action.AS_PUSH_BUTTON) { public void runWithEvent(final Event event) { editMeInProperties(_myStepperProperties); } }; toolboxProperties.setToolTipText("Edit Time Controller properties"); toolboxProperties.setImageDescriptor(CorePlugin.getImageDescriptor(ICON_PROPERTIES)); menuManager.add(toolboxProperties); toolManager.add(toolboxProperties); // and sort out our specific items refreshTimeOperations(); // and the help link menuManager.add(new Separator()); menuManager.add(CorePlugin.createOpenHelpAction("org.mwc.debrief.help.TimeController", null, this)); // ok - get the action bars to re-populate themselves, otherwise we // don't // see our changes getViewSite().getActionBars().updateActionBars(); }
From source file:org.nightlabs.base.ui.action.registry.AbstractActionRegistry.java
License:Open Source License
/** * @param coolBarManager// w ww . ja v a 2 s. c om * @return Returns the number of visible items (i.e. actions) that have been added (because some * might be invisible and therefore not added). */ public Map<Class<? extends ItemDescriptor>, List<ItemDescriptor>> contributeToCoolBar( ICoolBarManager coolBarManager) { if (coolBarManager instanceof SubContributionManager) ((SubCoolBarManager) coolBarManager).setVisible(true); String baseID = this.getClass().getName(); String orphanageToolbarID = baseID + '.' + ORPHANAGE_TOOLBAR_ID; // We use a temporary MenuManager which will be translated into the real // coolbar afterwards. MenuManager tmpMenu = new MenuManager(); Map<Class<? extends ItemDescriptor>, List<ItemDescriptor>> res = contribute(tmpMenu, ContributionManagerKind.coolBar); // all contributionItems with these IDs must not be added to the orphanage menu but directly // to the coolbar // TODO this should be somehow cached Set<String> additions_contributionItemIDs = new HashSet<String>(); additions_contributionItemIDs.add("additions"); // additions itself must not end up in orphanage menu //$NON-NLS-1$ for (ActionDescriptor actionDescriptor : getActionDescriptors()) { if ("additions".equals(actionDescriptor.getToolbarPath())) //$NON-NLS-1$ additions_contributionItemIDs.add(actionDescriptor.getID()); } // convert the existing items of the real coolbar-manager into a Map - the new items might // already exist because of Eclipse's workspace memory (and then the old ones need to be // manipulated - new ones would be ignored because of a bug/feature in the EclipseRCP) IContributionItem[] coolBarItems = null; if (coolBarManager instanceof SubCoolBarManager) { coolBarItems = ((SubCoolBarManager) coolBarManager).getParent().getItems(); } else if (coolBarManager instanceof IContributionManager) { coolBarItems = ((IContributionManager) coolBarManager).getItems(); } // IContributionItem[] coolBarItems = ((SubCoolBarManager)coolBarManager).getParent().getItems(); // key: String itemId // value: IXContributionItem Map<String, IContributionItem> coolBarItemMap = new HashMap<String, IContributionItem>(coolBarItems.length); for (int i = 0; i < coolBarItems.length; ++i) { IContributionItem coolBarItem = coolBarItems[i]; coolBarItemMap.put(coolBarItem.getId(), coolBarItem); } // Clean the "orphanage" toolbar which holds all those actions, that are not wrapped by a menu. // This toolbar does only exist, if it is needed. ToolBarContributionItem orphanageToolBarContributionItem = getToolBarContributionItem( coolBarItemMap.get(orphanageToolbarID)); if (orphanageToolBarContributionItem != null) orphanageToolBarContributionItem.getToolBarManager().removeAll(); // We need to collect all the "orphaned" actions in a menu first and at them after all the other menus. MenuManager orphanageMenu = new MenuManager(); List<IContributionItem> additionsToBeAddedDirectlyToCoolBar = new ArrayList<IContributionItem>(); // Now, we iterate all the "precompiled" items and contribute them to the coolbar IContributionItem[] tmpItems = tmpMenu.getItems(); for (int i = 0; i < tmpItems.length; ++i) { IContributionItem tmpItem = tmpItems[i]; // Either, we've hit a menu or an "orphaned" item if (tmpItem instanceof IMenuManager) { IMenuManager tmpSubMenu = (IMenuManager) tmpItem; String tmpSubMenuID = baseID + '.' + tmpSubMenu.getId(); // find the previously existing ToolBarManager or create a new one. IToolBarManager toolBarManager; ToolBarContributionItem toolBarContributionItem = getToolBarContributionItem( coolBarItemMap.get(tmpSubMenuID)); if (toolBarContributionItem != null) toolBarManager = toolBarContributionItem.getToolBarManager(); else { toolBarManager = new ToolBarManager(); toolBarContributionItem = new ToolBarContributionItem(toolBarManager, tmpSubMenuID); toolBarContributionItem.setUseChevron(false); coolBarManager.add(toolBarContributionItem); } toolBarManager.removeAll(); addFlattenedMenu(toolBarManager, tmpSubMenuID + ".separator", tmpSubMenu); //$NON-NLS-1$ } else { if (additions_contributionItemIDs.contains(tmpItem.getId())) additionsToBeAddedDirectlyToCoolBar.add(tmpItem); else orphanageMenu.add(tmpItem); } } // for (int i = 0; i < tmpItems.length; ++i) { // If we have actions without menus, populate a toolbar with them. if (!orphanageMenu.isEmpty()) { IToolBarManager toolBarManager; orphanageToolBarContributionItem = getToolBarContributionItem(coolBarItemMap.get(orphanageToolbarID)); if (orphanageToolBarContributionItem != null) toolBarManager = orphanageToolBarContributionItem.getToolBarManager(); else { toolBarManager = new ToolBarManager(); orphanageToolBarContributionItem = new ToolBarContributionItem(toolBarManager, orphanageToolbarID); orphanageToolBarContributionItem.setUseChevron(false); coolBarManager.add(orphanageToolBarContributionItem); } toolBarManager.removeAll(); addFlattenedMenu(toolBarManager, orphanageToolbarID + ".separator", orphanageMenu); //$NON-NLS-1$ } // contribute this stuff directly into the CoolBar (not a nested ToolBar). for (IContributionItem contributionItem : additionsToBeAddedDirectlyToCoolBar) { coolBarManager.add(contributionItem); } try { coolBarManager.update(true); } catch (Exception e) { // TODO WORKAROUND // sometimes at first startup an ArrayIndexOutOfBounds occurs, because // CoolBarManager.adjustContributionList removes first an separator and // afterwards also the first element, of an now empty list // this is an workaround for this bug logger.warn("Eclipse bug in coolBarManager.update(true) occured", e); //$NON-NLS-1$ } // if (coolBarManager instanceof CoolBarManager) // ((CoolBarManager)coolBarManager).refresh(); return res; }
From source file:org.nightlabs.jfire.reporting.ui.layout.action.ReportRegistryItemActionMenuManager.java
License:Open Source License
private void fillToolBar(IViewPart viewPart) { IToolBarManager toolBarManager = viewPart.getViewSite().getActionBars().getToolBarManager(); toolBarManager.removeAll(); actionRegistry.contributeToToolBar(toolBarManager); }
From source file:org.nightlabs.jfire.scripting.admin.ui.script.ScriptRegistryItemTreeMenuManager.java
License:Open Source License
private void fillToolBar(IViewPart viewPart) { IToolBarManager toolBarManager = viewPart.getViewSite().getActionBars().getToolBarManager(); try {//from w w w. j a v a 2 s . c om toolBarManager.removeAll(); ScriptRegistryItemActionRegistry.sharedInstance().contributeToToolBar(toolBarManager); } catch (EPProcessorException e) { throw new RuntimeException(e); } }
From source file:org.nightlabs.jfire.scripting.ui.admin.parameter.ScriptParameterSetTableMenuManager.java
License:Open Source License
public void fillToolBar(IToolBarManager toolBarManager) { try {//from ww w .j a va 2s .c o m toolBarManager.removeAll(); ScriptParameterSetActionRegistry.sharedInstance().contributeToToolBar(toolBarManager); } catch (EPProcessorException e) { throw new RuntimeException(e); } }
From source file:org.nightlabs.jfire.trade.ui.legalentity.view.LegalEntityEditorView.java
License:Open Source License
public void createPartContents(Composite parent) { selectionComposite = new LegalEntitySelectionComposite(parent, SWT.NONE, LayoutMode.TIGHT_WRAPPER); selectionComposite.addDisposeListener(new DisposeListener() { @Override// w ww .j av a2s.c o m public void widgetDisposed(DisposeEvent e) { IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager(); toolBarManager.removeAll(); } }); contributeToActionBars(); selectionComposite.setSearchAction(searchLegalEntityAction); SelectionManager.sharedInstance().addNotificationListener(LegalEntity.class, selectionListener); selectionComposite.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { SelectionManager.sharedInstance().removeNotificationListener(LegalEntity.class, selectionListener); } }); setSelectedLegalEntityID(null, true); }
From source file:org.pnml.tools.epnk.applications.hlpng.simulator.views.SimulationView.java
License:Open Source License
private static void contributeToActionBars(IViewSite viewSite, ISimulationViewController controller) { IActionBars bars = viewSite.getActionBars(); IToolBarManager manager = bars.getToolBarManager(); manager.removeAll(); if (controller != null) { for (Action action : controller.getActions()) { manager.add(action);/*from w w w . j a v a 2 s.c o m*/ } } bars.updateActionBars(); }