List of usage examples for org.eclipse.jface.action IToolBarManager appendToGroup
void appendToGroup(String groupName, IAction action);
From source file:org.eclipse.team.internal.ui.history.GenericHistoryView.java
License:Open Source License
private void configureToolbars(IActionBars actionBars) { pinAction = new Action(TeamUIMessages.GenericHistoryView_PinCurrentHistory, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_PINNED)) { public void run() { if (isChecked()) { //uncheck editor linking linkWithEditorAction.setChecked(false); setLinkingEnabled(false); }/*from w ww . ja v a 2 s.co m*/ setViewPinned(isChecked()); } }; pinAction.setChecked(isViewPinned()); pinAction.setToolTipText(TeamUIMessages.GenericHistoryView_0); refreshAction = new Action(TeamUIMessages.GenericHistoryView_Refresh, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_REFRESH)) { public void run() { getHistoryPage().refresh(); } }; refreshAction.setToolTipText(TeamUIMessages.GenericHistoryView_RefreshTooltip); refreshAction.setEnabled(true); linkWithEditorAction = new Action(TeamUIMessages.GenericHistoryView_LinkWithEditor, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_LINK_WITH)) { public void run() { if (isChecked()) { // uncheck pinned pinAction.setChecked(false); setViewPinned(false); } setLinkingEnabled(isViewPinned() ? false : isChecked()); } }; linkWithEditorAction.setChecked(isLinkingEnabled()); linkWithEditorAction.setToolTipText(TeamUIMessages.GenericHistoryView_LinkWithTooltip); navigateAction = new NavigationHistoryAction(); Utils.initAction(navigateAction, "action.previousHistory."); //$NON-NLS-1$ //Create the local tool bar IToolBarManager tbm = actionBars.getToolBarManager(); tbm.add(new Separator(HISTORY_VIEW_GROUP)); tbm.appendToGroup(HISTORY_VIEW_GROUP, refreshAction); tbm.appendToGroup(HISTORY_VIEW_GROUP, linkWithEditorAction); tbm.appendToGroup(HISTORY_VIEW_GROUP, pinAction); tbm.add(new Separator(NAVIGATION_GROUP)); tbm.appendToGroup(NAVIGATION_GROUP, navigateAction); tbm.update(false); }
From source file:org.eclipse.team.internal.ui.history.LocalHistoryPage.java
License:Open Source License
private void contributeActions() { final IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore(); //Group by Date groupByDateMode = new Action(TeamUIMessages.LocalHistoryPage_GroupRevisionsByDateAction, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DATES_CATEGORY)) { public void run() { groupingOn = !groupingOn;// ww w . j a va 2 s .c om store.setValue(IPreferenceIds.PREF_GROUPBYDATE_MODE, groupingOn); refreshHistory(false); } }; groupingOn = store.getBoolean(IPreferenceIds.PREF_GROUPBYDATE_MODE); groupByDateMode.setChecked(groupingOn); groupByDateMode.setToolTipText(TeamUIMessages.LocalHistoryPage_GroupRevisionsByDateTip); groupByDateMode .setDisabledImageDescriptor(TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DATES_CATEGORY)); groupByDateMode.setHoverImageDescriptor(TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DATES_CATEGORY)); //Collapse All collapseAll = new Action(TeamUIMessages.LocalHistoryPage_CollapseAllAction, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_COLLAPSE_ALL)) { public void run() { treeViewer.collapseAll(); } }; collapseAll.setToolTipText(TeamUIMessages.LocalHistoryPage_CollapseAllTip); collapseAll.setDisabledImageDescriptor(TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_COLLAPSE_ALL)); collapseAll.setHoverImageDescriptor(TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_COLLAPSE_ALL)); IHistoryPageSite historyPageSite = getHistoryPageSite(); if (!historyPageSite.isModal()) { //Compare Mode Action if ((compareMode & ALWAYS) == 0) { compareModeAction = new Action(TeamUIMessages.LocalHistoryPage_CompareModeAction, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_COMPARE_VIEW)) { public void run() { // switch the mode compareMode = compareMode == ON ? OFF : ON; compareModeAction.setChecked(compareMode == ON); } }; compareModeAction.setToolTipText(TeamUIMessages.LocalHistoryPage_CompareModeTip); compareModeAction.setDisabledImageDescriptor( TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_COMPARE_VIEW)); compareModeAction .setHoverImageDescriptor(TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_COMPARE_VIEW)); compareModeAction.setChecked(compareMode == ON); getContentsAction = getContextMenuAction(TeamUIMessages.LocalHistoryPage_GetContents, true /* needs progress */, new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { monitor.beginTask(null, 100); try { if (confirmOverwrite()) { IStorage currentStorage = currentSelection .getStorage(new SubProgressMonitor(monitor, 50)); InputStream in = currentStorage.getContents(); (file).setContents(in, false, true, new SubProgressMonitor(monitor, 50)); } } catch (TeamException e) { throw new CoreException(e.getStatus()); } finally { monitor.done(); } } }); } //TODO: Doc help //PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, ); // Click Compare action compareAction = createCompareAction(); compareAction.setEnabled(!treeViewer.getSelection().isEmpty()); treeViewer.getTree().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { compareAction.setCurrentFileRevision(getCurrentFileRevision()); compareAction.selectionChanged((IStructuredSelection) treeViewer.getSelection()); } }); // Only add the open action if compare mode is not always on if (!((compareMode & (ALWAYS | ON)) == (ALWAYS | ON))) { openAction = new OpenRevisionAction(TeamUIMessages.LocalHistoryPage_OpenAction, this); openAction.setEnabled(!treeViewer.getSelection().isEmpty()); treeViewer.getTree().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { openAction.selectionChanged((IStructuredSelection) treeViewer.getSelection()); } }); // Add 'Open With...' sub-menu openWithMenu = new OpenWithMenu(this); treeViewer.getTree().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { openWithMenu.selectionChanged((IStructuredSelection) treeViewer.getSelection()); } }); } new OpenAndLinkWithEditorHelper(treeViewer) { protected void open(ISelection selection, boolean activate) { if (getSite() != null && selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if ((compareMode & ON) > 0) { StructuredSelection sel = new StructuredSelection(new Object[] { getCurrentFileRevision(), structuredSelection.getFirstElement() }); compareAction.selectionChanged(sel); compareAction.run(); } else { //Pass in the entire structured selection to allow for multiple editor openings if (openAction != null) { openAction.selectionChanged(structuredSelection); openAction.run(); } } } } protected void activate(ISelection selection) { int currentMode = OpenStrategy.getOpenMethod(); try { OpenStrategy.setOpenMethod(OpenStrategy.DOUBLE_CLICK); open(selection, true); } finally { OpenStrategy.setOpenMethod(currentMode); } } protected void linkToEditor(ISelection selection) { // XXX: Not yet implemented, see http://bugs.eclipse.org/324185 } }; //Contribute actions to popup menu MenuManager menuMgr = new MenuManager(); Menu menu = menuMgr.createContextMenu(treeViewer.getTree()); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager menuMgr) { fillTableMenu(menuMgr); } }); menuMgr.setRemoveAllWhenShown(true); treeViewer.getTree().setMenu(menu); //Don't add the object contribution menu items if this page is hosted in a dialog IWorkbenchPart part = historyPageSite.getPart(); if (part != null) { IWorkbenchPartSite workbenchPartSite = part.getSite(); workbenchPartSite.registerContextMenu(menuMgr, treeViewer); } IPageSite pageSite = historyPageSite.getWorkbenchPageSite(); if (pageSite != null) { IActionBars actionBars = pageSite.getActionBars(); // Contribute toggle text visible to the toolbar drop-down IMenuManager actionBarsMenu = actionBars.getMenuManager(); if (actionBarsMenu != null) { actionBarsMenu.removeAll(); } actionBars.updateActionBars(); } } //Create the local tool bar IToolBarManager tbm = historyPageSite.getToolBarManager(); if (tbm != null) { String fileNameQualifier = getFileNameQualifier(); //Add groups tbm.add(new Separator(fileNameQualifier + "grouping")); //$NON-NLS-1$ tbm.appendToGroup(fileNameQualifier + "grouping", groupByDateMode); //$NON-NLS-1$ tbm.add(new Separator(fileNameQualifier + "collapse")); //$NON-NLS-1$ tbm.appendToGroup(fileNameQualifier + "collapse", collapseAll); //$NON-NLS-1$ if (compareModeAction != null) tbm.appendToGroup(fileNameQualifier + "collapse", compareModeAction); //$NON-NLS-1$ tbm.update(false); } }
From source file:org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup.java
License:Open Source License
public void fillActionBars(IActionBars actionBars, String group) { super.fillActionBars(actionBars); IToolBarManager toolBar = actionBars.getToolBarManager(); for (Iterator it = actions.iterator(); it.hasNext();) { DirectionFilterAction action = (DirectionFilterAction) it.next(); if (group != null) { toolBar.appendToGroup(group, action); } else {//ww w.j a v a2 s . c om toolBar.add(action); } } }
From source file:org.eclipse.team.internal.ui.synchronize.actions.DirectionFilterActionGroup.java
License:Open Source License
public void fillToolBar(String groupId, IToolBarManager toolBar) { for (Iterator it = actions.iterator(); it.hasNext();) { DirectionFilterAction action = (DirectionFilterAction) it.next(); toolBar.appendToGroup(groupId, action); }/*from w w w. j a v a 2 s . c o m*/ }
From source file:org.eclipse.titan.log.viewer.views.text.table.TextTableView.java
License:Open Source License
/** * Create a close all action in the tool bar *//*from ww w . j a va 2 s . c o m*/ private void createToolbar() { IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager mgr = actionBars.getToolBarManager(); IAction closeAllAction = new CloseAllAction(); closeAllAction.setEnabled(true); IAction switchToMSCAction = new SwitchToMscAction(this); switchToMSCAction.setEnabled(true); mgr.add(filterAction); mgr.add(closeAllAction); mgr.add(new Separator(Constants.ID_SWITCH_VIEW_GROUP)); mgr.appendToGroup(Constants.ID_SWITCH_VIEW_GROUP, switchToMSCAction); actionBars.updateActionBars(); }
From source file:org.eclipse.tm.te.ui.views.internal.View.java
License:Open Source License
/** * Adds the custom Target Explorer toolbar groups to the view toolbar. *//*from ww w . ja v a2 s . co m*/ protected void addCustomToolbarGroups() { if (getViewSite() != null && getViewSite().getActionBars() != null) { IToolBarManager tbManager = getViewSite().getActionBars().getToolBarManager(); if (tbManager != null) { tbManager.insertBefore("FRAME_ACTION_GROUP_ID", new GroupMarker("group.new")); //$NON-NLS-1$ //$NON-NLS-2$ tbManager.appendToGroup("group.new", new Separator("group.configure")); //$NON-NLS-1$ //$NON-NLS-2$ tbManager.appendToGroup("group.configure", new Separator("group.connect")); //$NON-NLS-1$ //$NON-NLS-2$ tbManager.appendToGroup("group.connect", new Separator("group.symbols.rd")); //$NON-NLS-1$ //$NON-NLS-2$ tbManager.appendToGroup("group.symbols.rd", new GroupMarker("group.symbols")); //$NON-NLS-1$ //$NON-NLS-2$ tbManager.appendToGroup("group.symbols", new Separator("group.refresh")); //$NON-NLS-1$ //$NON-NLS-2$ tbManager.appendToGroup("group.refresh", new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); //$NON-NLS-1$ } } }
From source file:org.eclipse.ui.console.TextConsolePage.java
License:Open Source License
protected void configureToolBar(IToolBarManager mgr) { mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fClearOutputAction); }
From source file:org.eclipse.ui.internal.console.IOConsolePage.java
License:Open Source License
protected void configureToolBar(IToolBarManager mgr) { super.configureToolBar(mgr); mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction); }
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. * /*w ww .j a va2 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); } } }
From source file:org.eclipse.virgo.ide.runtime.ui.views.ArtefactCommonView.java
License:Open Source License
/** * @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse.swt.widgets.Composite) *//*www . ja v a 2s . c om*/ @Override public void createPartControl(Composite aParent) { super.createPartControl(aParent); IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager manager = actionBars.getToolBarManager(); manager.add(new Separator(FILTER_ACTION_GROUP)); FilterAction[] filterActions = FilterAction.createSet(this); for (FilterAction action : filterActions) { manager.appendToGroup(FILTER_ACTION_GROUP, action); } this.repositoryListener = new IBundleRepositoryChangeListener() { public void bundleRepositoryChanged(IRuntime runtime) { refreshView(); } }; ServerCorePlugin.getArtefactRepositoryManager().addBundleRepositoryChangeListener(this.repositoryListener); }