List of usage examples for org.eclipse.jface.action IToolBarManager find
IContributionItem find(String id);
From source file:org.rssowl.ui.internal.CoolBarAdvisor.java
License:Open Source License
private CoolBarActionContributionitem find(String id) { IContributionItem[] items = fManager.getItems(); for (IContributionItem item : items) { if (item instanceof ToolBarContributionItem) { IToolBarManager toolBarManager = ((ToolBarContributionItem) item).getToolBarManager(); if (toolBarManager != null) { IContributionItem result = toolBarManager.find(id); if (result != null && result instanceof CoolBarActionContributionitem) return (CoolBarActionContributionitem) result; }//ww w . j a va 2 s. c om } } return null; }
From source file:org.talend.designer.core.ui.editor.palette.TalendPaletteHelper.java
License:Open Source License
private static void updatePaletteActions(IActionBars actionBars, IAction action, boolean isTalendEditor) { IToolBarManager toolBarManager = actionBars.getToolBarManager(); IContributionItem cItem = toolBarManager.find(action.getClass().getCanonicalName()); if (cItem == null) { if (isTalendEditor) { toolBarManager.add(action);/* w w w . jav a2 s.co m*/ } } else { if (!isTalendEditor) { toolBarManager.remove(new ActionContributionItem(action)); } } }
From source file:org.talend.repository.viewer.filter.ActiveRepositoryFilterActionProvider.java
License:Open Source License
@Override protected void fillToolBar(IToolBarManager toolBarManager) { super.fillToolBar(toolBarManager); if (toolBarManager.find(ActionConstants.TALEND_GROUP_ID) == null) { toolBarManager.add(new Separator(ActionConstants.TALEND_GROUP_ID)); }// w w w . j av a2s . c o m if (toolBarManager.find(ActiveFilterAction.ACTION_ID) == null) { final ActiveFilterAction action = new ActiveFilterAction( Messages.getString("ActiveRepositoryFilterActionProvider.ActivateFilter")); //$NON-NLS-1$ toolBarManager.appendToGroup(ActionConstants.TALEND_GROUP_ID, action); } }
From source file:org.wesnoth.product.WorkbenchActionBuilder.java
License:Open Source License
/** * Update the build actions on the toolbar and menu bar based on the current * state of autobuild. This method can be called from any thread. * /* w w w . ja v a 2 s.c o m*/ * @param immediately * <code>true</code> to update the actions immediately, * <code>false</code> to queue the update to be run in the * event loop */ void updateBuildActions(boolean immediately) { // this can be triggered by property or resource change notifications Runnable update = new Runnable() { public void run() { if (isDisposed) { return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProject[] projects = workspace.getRoot().getProjects(); boolean enabled = BuildUtilities.isEnabled(projects, IncrementalProjectBuilder.INCREMENTAL_BUILD); // update menu bar actions in project menu updateCommandEnablement(buildAllAction.getActionDefinitionId()); buildProjectAction.setEnabled(enabled); toggleAutoBuildAction.setChecked(workspace.isAutoBuilding()); cleanAction.setEnabled(BuildUtilities.isEnabled(projects, IncrementalProjectBuilder.CLEAN_BUILD)); // update the cool bar build button ICoolBarManager coolBarManager = getActionBarConfigurer().getCoolBarManager(); IContributionItem cbItem = coolBarManager.find(IWorkbenchActionConstants.TOOLBAR_FILE); if (!(cbItem instanceof IToolBarContributionItem)) { // This should not happen IDEWorkbenchPlugin.log("File toolbar contribution item is missing"); //$NON-NLS-1$ return; } IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem; IToolBarManager toolBarManager = toolBarItem.getToolBarManager(); if (toolBarManager == null) { // error if this happens, file toolbar assumed to always // exist IDEWorkbenchPlugin.log("File toolbar is missing"); //$NON-NLS-1$ return; } // add the build button if build actions are enabled, and remove // it otherwise boolean found = toolBarManager.find(buildAllAction.getId()) != null; if (enabled && !found) { toolBarManager.appendToGroup(IWorkbenchActionConstants.BUILD_GROUP, buildAllAction); toolBarManager.update(false); toolBarItem.update(ICoolBarManager.SIZE); } else if (buildAllAction != null && found && !enabled) { toolBarManager.remove(buildAllAction.getId()); toolBarManager.update(false); toolBarItem.update(ICoolBarManager.SIZE); } } private void updateCommandEnablement(String commandId) { IHandlerService handlerService = (IHandlerService) window.getService(IHandlerService.class); ICommandService commandService = (ICommandService) window.getService(ICommandService.class); if (handlerService != null && commandService != null) { Command buildAllCmd = commandService.getCommand(commandId); buildAllCmd.setEnabled(handlerService.getCurrentState()); } } }; if (immediately) { update.run(); } else { // Dispatch the update to be run later in the UI thread. // This helps to reduce flicker if autobuild is being temporarily // disabled programmatically. Shell shell = window.getShell(); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(update); } } }