List of usage examples for org.eclipse.jface.action IToolBarManager find
IContributionItem find(String id);
From source file:org.eclipse.sirius.tests.unit.table.unit.tools.RefreshToolActionBarTest.java
License:Open Source License
/** * Test refresh creation tools when working on several table * representations. VP-1154//from www.j av a2 s . com * * @throws Exception */ @SuppressWarnings("unchecked") public void testRefreshToolBarCreateLine() { final DTable dTable1 = (DTable) createRepresentation(REPRESENTATION_DESC_NAME1, semanticModel); EClassImpl semanticClass = (EClassImpl) ((EPackageImpl) semanticModel).getEClassifier("class1"); final DTable dTable2 = (DTable) createRepresentation(REPRESENTATION_DESC_NAME2, semanticClass); AbstractDTableEditor editor1 = (AbstractDTableEditor) DialectUIManager.INSTANCE.openEditor(session, dTable1, new NullProgressMonitor()); TestsUtil.synchronizationWithUIThread(); AbstractDTableEditor editor2 = null; assertNotNull("The editor has not been correctly opened", editor1); IToolBarManager toolBar = ((EditorActionBarContributor) editor1.getEditorSite().getActionBarContributor()) .getActionBars().getToolBarManager(); ActionContributionItem contributionItem = (ActionContributionItem) toolBar.find(EDITOR_CREATE_LINE_MENU_ID); EditorCreateLineMenuAction editorCreateLineMenuAction = ((EditorCreateLineMenuAction) contributionItem .getAction()); try { List<CreateLineAction> creationsLineAction = (List<CreateLineAction>) getCreateLineActionsForTable .invoke(editorCreateLineMenuAction); assertEquals("TestTableTools_Classes_CreateLine", creationsLineAction.get(0).getText()); editor2 = (AbstractDTableEditor) DialectUIManager.INSTANCE.openEditor(session, dTable2, new NullProgressMonitor()); TestsUtil.synchronizationWithUIThread(); assertNotNull("The editor has not been correctly opened", editor2); toolBar = ((EditorActionBarContributor) editor2.getEditorSite().getActionBarContributor()) .getActionBars().getToolBarManager(); contributionItem = (ActionContributionItem) toolBar.find(EDITOR_CREATE_LINE_MENU_ID); editorCreateLineMenuAction = ((EditorCreateLineMenuAction) contributionItem.getAction()); creationsLineAction = (List<CreateLineAction>) getCreateLineActionsForTable .invoke(editorCreateLineMenuAction); assertEquals("TestTableTools_Attributes_CreateLine", creationsLineAction.get(0).getText()); IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); workbenchPage.activate(editor1); toolBar = ((EditorActionBarContributor) editor1.getEditorSite().getActionBarContributor()) .getActionBars().getToolBarManager(); contributionItem = (ActionContributionItem) toolBar.find(EDITOR_CREATE_LINE_MENU_ID); editorCreateLineMenuAction = ((EditorCreateLineMenuAction) contributionItem.getAction()); creationsLineAction = (List<CreateLineAction>) getCreateLineActionsForTable .invoke(editorCreateLineMenuAction); assertEquals("TestTableTools_Classes_CreateLine", creationsLineAction.get(0).getText()); } catch (Exception e) { e.printStackTrace(); } finally { DialectUIManager.INSTANCE.closeEditor(editor1, false); TestsUtil.synchronizationWithUIThread(); DialectUIManager.INSTANCE.closeEditor(editor2, false); TestsUtil.synchronizationWithUIThread(); } }
From source file:org.eclipse.tcf.te.ui.views.actions.NewActionProvider.java
License:Open Source License
@Override public void fillActionBars(IActionBars actionBars) { // If none of the actions got created, there is nothing to do here if (newWizardCommandActionToolbar == null) { return;// w ww .j a v a 2 s .com } // Get the toolbar manager IToolBarManager toolbar = actionBars.getToolBarManager(); // Check for the newWizard action in the toolbar. If found, // drop out immediately to avoid adding the items to the toolbar // again and again if (toolbar.find("org.eclipse.tcf.te.ui.command.newWizards") != null) { //$NON-NLS-1$ return; } // Add the items to the toolbar toolbar.insertAfter(ICommonMenuConstants.GROUP_NEW, newWizardCommandActionToolbar); }
From source file:org.eclipse.titan.log.viewer.views.msc.ui.actions.ZoomAction.java
License:Open Source License
public void setActionChecked(final String id, final boolean checked) { IActionBars bar = this.view.getViewSite().getActionBars(); if (bar == null) { return;// w ww.j av a2 s .c o m } IToolBarManager barManager = bar.getToolBarManager(); if (barManager == null) { return; } IContributionItem nextPage = barManager.find(id); if ((nextPage != null) && (nextPage instanceof ActionContributionItem)) { IAction action = ((ActionContributionItem) nextPage).getAction(); if (action != null) { action.setChecked(checked); } } }
From source file:org.eclipse.tm.te.ui.views.actions.NewActionProvider.java
License:Open Source License
@Override public void fillActionBars(IActionBars actionBars) { // If none of the actions got created, there is nothing to do here if (newWizardCommandActionToolbar == null) { return;/* w ww. j av a 2 s . c o m*/ } // Get the toolbar manager IToolBarManager toolbar = actionBars.getToolBarManager(); // Check for the newWizard action in the toolbar. If found, // drop out immediately to avoid adding the items to the toolbar // again and again if (toolbar.find("org.eclipse.tm.te.ui.command.newWizards") != null) { //$NON-NLS-1$ return; } // Add the items to the toolbar toolbar.insertAfter(ICommonMenuConstants.GROUP_NEW, newWizardCommandActionToolbar); }
From source file:org.eclipse.ui.internal.ide.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. * /*www . ja va 2 s. co 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); } } }
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./*from w w w .j a v a 2 s. com*/ */ 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 contributeActions(XtextEditor editor) { IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager(); IAction action = editor.getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS); action.setImageDescriptor(imageHelper.getImageDescriptor("full/etool16/show_whitespace_chars.gif")); action.setDisabledImageDescriptor(imageHelper.getImageDescriptor("full/dtool16/show_whitespace_chars.gif")); if (toolBarManager.find(action.getId()) == null) { toolBarManager.add(new ActionContributionItemExtension(action)); // toolBarManager.add(action); }//from www.j ava 2s . c om }
From source file:org.eclipse.xtext.ui.editor.occurrences.MarkOccurrenceActionContributor.java
License:Open Source License
@Override public void contributeActions(XtextEditor editor) { OccurrenceMarker occurrenceMarker = editor2marker.get(editor); if (occurrenceMarker == null) { editor.setAction(getAction().getId(), getAction()); IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager(); if (toolBarManager.find(getAction().getId()) == null) { toolBarManager.add(getAction()); }//from www.j a va 2s. com occurrenceMarker = occurrenceMarkerProvider.get(); occurrenceMarker.connect(editor, isPropertySet()); editor2marker.put(editor, occurrenceMarker); } }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.cpu.CpuSection.java
License:Open Source License
@Override protected void addToolBarActions(IToolBarManager manager) { suspendCpuProfilingAction.setEnabled(false); resumeCpuProfilingAction.setEnabled(false); clearCpuProfilingDataAction.setEnabled(false); manager.insertAfter("defaults", separator); //$NON-NLS-1$ if (manager.find(clearCpuProfilingDataAction.getId()) == null) { manager.insertAfter("defaults", clearCpuProfilingDataAction); //$NON-NLS-1$ }//w ww . ja v a 2 s . com if (manager.find(suspendCpuProfilingAction.getId()) == null) { manager.insertAfter("defaults", suspendCpuProfilingAction); //$NON-NLS-1$ } if (manager.find(resumeCpuProfilingAction.getId()) == null) { manager.insertAfter("defaults", resumeCpuProfilingAction); //$NON-NLS-1$ } if (manager.find(dumpCpuProfilingDataAction.getId()) == null) { manager.insertAfter("defaults", dumpCpuProfilingDataAction); //$NON-NLS-1$ } }
From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.mbean.MBeansSection.java
License:Open Source License
@Override protected void addToolBarActions(IToolBarManager manager) { manager.insertAfter("defaults", separator); //$NON-NLS-1$ if (manager.find(refreshAction.getId()) == null) { manager.insertAfter("defaults", refreshAction); //$NON-NLS-1$ }//from w w w. j a v a2 s . co m }