List of usage examples for org.eclipse.jface.action IToolBarManager getItems
IContributionItem[] getItems();
From source file:org.eclipse.debug.ui.AbstractDebugView.java
License:Open Source License
/** * Saves the checked state for all actions contributed to the toolbar * manager that function as a toggle action. The states are saved in * the Debug UI plugin's preference store. * //w ww . j av a 2s. c om * @since 2.1 */ protected void saveAllCheckedActionStates() { IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); IContributionItem[] items = tbm.getItems(); for (int i = 0; i < items.length; i++) { IContributionItem iContributionItem = items[i]; if (iContributionItem instanceof ActionContributionItem) { ActionContributionItem item = (ActionContributionItem) iContributionItem; IAction action = item.getAction(); if (action.getStyle() == IAction.AS_CHECK_BOX && action.isEnabled()) { saveCheckedActionState(action); } } } }
From source file:org.eclipse.debug.ui.AbstractDebugView.java
License:Open Source License
/** * Configures this view's toolbar. Subclasses implement * <code>#configureToolBar(IToolBarManager)</code> to * contribute actions to the toolbar./*from ww w.j a va 2s .com*/ * <p> * To properly initialize toggle actions that are contributed * to this view, state is restored for toggle actions that have * a persisted state in the Debug UI plugin's preferences. As well, any * toggle actions that have an initial state of 'checked' are invoked. The * actions' states are restored and the actions are invoked in a runnable, * after the view is created. * </p> */ protected void initializeToolBar() { final IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager(); configureToolBar(tbm); getViewSite().getActionBars().updateActionBars(); // This is done in a runnable to be run after this view's pane // is created Runnable r = new Runnable() { public void run() { if (!isAvailable()) { return; } IContributionItem[] items = tbm.getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { if (items[i] instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) items[i]).getAction(); if (!SkipAllBreakpointsAction.ACTION_ID.equals(action.getId())) { if (action.getStyle() == IAction.AS_CHECK_BOX) { initActionState(action); if (action.isChecked()) { action.run(); } } } } } setMemento(null); } updateObjects(); } }; asyncExec(r); }
From source file:org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java
License:Open Source License
public void reconcileManagerToModel(IToolBarManager menuManager, MToolBar toolBar) { List<MToolBarElement> modelChildren = toolBar.getChildren(); HashSet<MOpaqueToolItem> oldModelItems = new HashSet<MOpaqueToolItem>(); for (MToolBarElement itemModel : modelChildren) { if (itemModel instanceof MOpaqueToolItem) { oldModelItems.add((MOpaqueToolItem) itemModel); }//from www .j av a2s . co m } IContributionItem[] items = menuManager.getItems(); for (int src = 0, dest = 0; src < items.length; src++, dest++) { IContributionItem item = items[src]; MToolBarElement element = getToolElement(item); if (element == null) { MOpaqueToolItem legacyItem = MenuFactoryImpl.eINSTANCE.createOpaqueToolItem(); legacyItem.setElementId(item.getId()); legacyItem.setVisible(item.isVisible()); legacyItem.setOpaqueItem(item); linkModelToContribution(legacyItem, item); modelChildren.add(dest, legacyItem); } else if (element instanceof MOpaqueToolItem) { MOpaqueToolItem legacyItem = (MOpaqueToolItem) element; oldModelItems.remove(legacyItem); if (modelChildren.size() > dest) { if (modelChildren.get(dest) != legacyItem) { modelChildren.remove(legacyItem); modelChildren.add(dest, legacyItem); } } else { modelChildren.add(legacyItem); } } } if (!oldModelItems.isEmpty()) { modelChildren.removeAll(oldModelItems); for (MOpaqueToolItem model : oldModelItems) { clearModelToContribution(model, (IContributionItem) model.getOpaqueItem()); } } }
From source file:org.eclipse.eclipsemonkey.actions.RecreateMonkeyCoolbarAction.java
License:Open Source License
private void clearTheToolbar() { CoolBarManager manager = ((WorkbenchWindow) window).getCoolBarManager(); if (manager != null) { for (Iterator iter = toolbars.values().iterator(); iter.hasNext();) { IToolBarManager element = (IToolBarManager) iter.next(); IContributionItem[] items = element.getItems(); for (int i = 0; i < items.length; i++) { element.remove(items[i]); }/*from ww w .ja va 2 s.com*/ } } }
From source file:org.eclipse.edt.ide.rui.visualeditor.internal.editor.EvEditorOutlinePage.java
License:Open Source License
/** * Called by the editor to show the outline page denoted by the static constant as defined above. *///from w w w . j av a2s .c om public void showPage(int iPage) { if (_pageBook != null) { switch (iPage) { case DESIGN_PAGE: _pageBook.showPage(_controlDesign); break; case SOURCE_PAGE: _pageBook.showPage(_controlSource); break; case PREVIEW_PAGE: _pageBook.showPage(_controlPrevew); break; } } // Set the visibility of the source page's outline view tool bar controls // based on the page that is about to be shown //----------------------------------------------------------------------- IActionBars actionBars = getSite().getActionBars(); if (actionBars == null) return; IToolBarManager toolBarManager = actionBars.getToolBarManager(); if (toolBarManager == null) return; IContributionItem[] items = toolBarManager.getItems(); if (items == null) return; for (int i = 0; i < items.length; ++i) items[i].setVisible(iPage == SOURCE_PAGE); toolBarManager.update(true); }
From source file:org.eclipse.epf.library.ui.LibraryUIManager.java
License:Open Source License
/** * Displays the method configuration combobox in the system toolbar. */// w ww .j a va 2 s . c o m private void showConfigurationContribution(ICoolBarManager coolBarMgr) throws Exception { // Check for the method configuration combobox toolbar. IContributionItem configToolBar = coolBarMgr.find(TOOLBAR_CONFIG_CONTRIBUTION_ID); if (configToolBar != null) { // Make sure the toolbar has the method configuration combobox // contribution. if (configToolBar instanceof ToolBarContributionItem) { IToolBarManager toolBarMgr = ((ToolBarContributionItem) configToolBar).getToolBarManager(); if (toolBarMgr != null) { IContributionItem[] toolBarItems = toolBarMgr.getItems(); if (toolBarItems != null && toolBarItems.length > 0) { for (int i = 0; i < toolBarItems.length; i++) { toolBarItems[i].setVisible(true); } configToolBar.setVisible(true); updateSystemToolBar(coolBarMgr); return; } } // The method configuration combobox toolbar has been restored // via a saved perspective, add the method configuration // combobox contribution. configCombo = new ConfigurationContributionItem(null); if (DebugUtil.uiDebug) { DebugUtil.print("showConfigurationContribution, configCombo 1: " + configCombo);//$NON-NLS-1$ DebugUtil.print(); } configCombo.setId(ConfigurationContributionItem.class.getName()); toolBarMgr.add(configCombo); configToolBar.setVisible(true); updateSystemToolBar(coolBarMgr); return; } } IToolBarManager toolBarMgr = new ToolBarManager(SWT.FLAT | SWT.LEFT); configCombo = new ConfigurationContributionItem(null); if (DebugUtil.uiDebug) { DebugUtil.print("showConfigurationContribution, configCombo 2: " + configCombo);//$NON-NLS-1$ DebugUtil.print(); } configCombo.setId(ConfigurationContributionItem.class.getName()); toolBarMgr.add(configCombo); ToolBarContributionItem configComboToolBar = new ToolBarContributionItem(toolBarMgr, TOOLBAR_CONFIG_CONTRIBUTION_ID); coolBarMgr.add(configComboToolBar); }
From source file:org.eclipse.epf.library.ui.LibraryUIManager.java
License:Open Source License
/** * Hides the method configuration combobox from the system toolbar. *//*from w w w. j a v a 2s . c om*/ private void hideConfigurationContribution(ICoolBarManager coolBarMgr) throws Exception { // Check for the method configuration combobox toolbar. IContributionItem configToolBar = coolBarMgr.find(TOOLBAR_CONFIG_CONTRIBUTION_ID); if (configToolBar == null) { return; } // Hide the method configuration combobox contribution from the toolbar. if (configToolBar instanceof ToolBarContributionItem) { IToolBarManager toolBarMgr = ((ToolBarContributionItem) configToolBar).getToolBarManager(); IContributionItem[] toolBarItems = toolBarMgr.getItems(); for (int i = 0; i < toolBarItems.length; i++) { toolBarItems[i].setVisible(false); } } // Hide the method configuration combobox toolbar contribution. configToolBar.setVisible(false); // Update the the system tool bar. updateSystemToolBar(coolBarMgr); }
From source file:org.eclipse.gef4.dot.internal.ui.DotGraphView.java
License:Open Source License
private boolean toggle(Action action, boolean input) { action.setChecked(!action.isChecked()); IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); for (IContributionItem item : mgr.getItems()) { if (item instanceof ActionContributionItem && ((ActionContributionItem) item).getAction() == action) { action.setChecked(!action.isChecked()); return !input; }// w w w.j a v a 2s . c o m } return input; }
From source file:org.eclipse.gef4.graph.internal.dot.ZestGraphView.java
License:Open Source License
private boolean toggle(Action action, boolean input) { action.setChecked(!action.isChecked()); IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); for (IContributionItem item : mgr.getItems()) { if (item.getId() != null && item.getId().equals(action.getText())) { ActionContributionItem i = (ActionContributionItem) item; i.getAction().setChecked(!i.getAction().isChecked()); return !input; }/* www .j a v a 2s .com*/ } return input; }
From source file:org.eclipse.libra.framework.editor.ui.internal.AbstractBundleEditorPage.java
License:Open Source License
public final void createPartControl(Composite parent) { createBundleContent(parent);//from w w w . j a v a2 s. com IToolBarManager toolBarManager = sform.getToolBarManager(); if (toolBarManager.getItems().length > 0) { toolBarManager.add(new Separator()); } debugAction = new StartServerAction(ILaunchManager.DEBUG_MODE); toolBarManager.add(debugAction); runAction = new StartServerAction(ILaunchManager.RUN_MODE); toolBarManager.add(runAction); stopAction = new StopServerAction(); toolBarManager.add(stopAction); toolBarManager.update(true); if (server.getOriginal().getServerState() != IServer.STATE_STARTED) { disablePage(); } else { enablePage(); } }