List of usage examples for org.eclipse.jface.action IToolBarManager update
void update(boolean force);
From source file:org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart.java
License:Open Source License
/** * Contribute actions to the view/* w ww .j av a 2 s. c o m*/ */ protected void contributeActions() { final Shell shell = getShell(); // Refresh (toolbar) CVSUIPlugin plugin = CVSUIPlugin.getPlugin(); refreshAction = new Action(CVSUIMessages.RepositoriesView_refresh, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_REFRESH_ENABLED)) { public void run() { refreshAll(); } }; refreshAction.setToolTipText(CVSUIMessages.RepositoriesView_refreshTooltip); refreshAction.setDisabledImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH_DISABLED)); refreshAction.setHoverImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_REFRESH)); getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); collapseAllAction = new Action(CVSUIMessages.RepositoriesView_collapseAll, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL_ENABLED)) { public void run() { collapseAll(); } }; collapseAllAction.setToolTipText(CVSUIMessages.RepositoriesView_collapseAllTooltip); collapseAllAction.setHoverImageDescriptor(plugin.getImageDescriptor(ICVSUIConstants.IMG_COLLAPSE_ALL)); // Working Set action group IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) { Object newValue = event.getNewValue(); setWorkingSet((IWorkingSet) newValue, true); } } }; setActionGroup(new WorkingSetFilterActionGroup(shell, workingSetUpdater)); getWorkingSetActionGroup().setWorkingSet(getContentProvider().getWorkingSet()); // Create the popup menu MenuManager menuMgr = new MenuManager(); Tree tree = viewer.getTree(); Menu menu = menuMgr.createContextMenu(tree); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { addWorkbenchActions(manager); } }); menuMgr.setRemoveAllWhenShown(true); tree.setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); // Create the local tool bar IActionBars bars = getViewSite().getActionBars(); IToolBarManager tbm = bars.getToolBarManager(); drillPart.addNavigationActions(tbm); tbm.add(refreshAction); tbm.add(new Separator()); tbm.add(collapseAllAction); tbm.update(false); // Register the open handler openAction = new OpenRemoteFileAction(); viewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { handleOpen(event); } }); bars.updateActionBars(); }
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); }// www.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;// w w 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.svn.ui.lock.LocksView.java
License:Open Source License
protected void createActionBars() { //drop-down menu IActionBars actionBars = this.getViewSite().getActionBars(); IMenuManager actionBarsMenu = actionBars.getMenuManager(); this.linkWithEditorDropDownAction = new Action(SVNUIMessages.SVNView_LinkWith_Label, Action.AS_CHECK_BOX) { public void run() { LocksView.this.linkWithEditor(); LocksView.this.linkWithEditorAction.setChecked(LocksView.this.isLinkWithEditorEnabled); }//from ww w . ja v a2 s . c o m }; this.linkWithEditorDropDownAction.setChecked(this.isLinkWithEditorEnabled); actionBarsMenu.add(this.linkWithEditorDropDownAction); IToolBarManager tbm = actionBars.getToolBarManager(); tbm.removeAll(); Action action = new Action(SVNUIMessages.SVNView_Refresh_Label) { public void run() { LocksView.this.refresh(); } }; action.setImageDescriptor(SVNTeamUIPlugin.instance().getImageDescriptor("icons/common/refresh.gif")); //$NON-NLS-1$ tbm.add(action); tbm.add(this.getLinkWithEditorAction()); tbm.update(true); this.getSite().getPage().addSelectionListener(this.selectionListener); }
From source file:org.eclipse.team.svn.ui.properties.PropertiesView.java
License:Open Source License
public void createPartControl(Composite parent) { super.createPartControl(parent); IPreferenceStore store = SVNTeamUIPlugin.instance().getPreferenceStore(); this.isLinkWithEditorEnabled = SVNTeamPreferences.getPropertiesBoolean(store, SVNTeamPreferences.PROPERTY_LINK_WITH_EDITOR_NAME); this.propertiesComposite = new PropertiesComposite(parent); this.propertiesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); this.propertiesComposite.setPropertiesView(this); this.refresh(); //drop-down menu IActionBars actionBars = this.getViewSite().getActionBars(); IMenuManager actionBarsMenu = actionBars.getMenuManager(); this.linkWithEditorDropDownAction = new Action(SVNUIMessages.SVNView_LinkWith_Label, Action.AS_CHECK_BOX) { public void run() { PropertiesView.this.linkWithEditor(); PropertiesView.this.linkWithEditorAction.setChecked(PropertiesView.this.isLinkWithEditorEnabled); }// w w w . ja va 2 s. co m }; this.linkWithEditorDropDownAction.setChecked(this.isLinkWithEditorEnabled); actionBarsMenu.add(this.linkWithEditorDropDownAction); IToolBarManager tbm = actionBars.getToolBarManager(); tbm.removeAll(); Action action = new Action(SVNUIMessages.SVNView_Refresh_Label) { public void run() { PropertiesView.this.refreshAction(); } }; action.setImageDescriptor(SVNTeamUIPlugin.instance().getImageDescriptor("icons/common/refresh.gif")); //$NON-NLS-1$ tbm.add(action); tbm.add(this.getLinkWithEditorAction()); tbm.update(true); this.getSite().getPage().addSelectionListener(this.selectionListener); //Setting context help PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.team.svn.help.propertiesViewContext"); //$NON-NLS-1$ }
From source file:org.eclipse.team.svn.ui.properties.RevPropertiesView.java
License:Open Source License
public void createPartControl(Composite parent) { IToolBarManager tbm = this.getViewSite().getActionBars().getToolBarManager(); tbm.removeAll();/* w ww. j a v a2 s.co m*/ Action action = new Action(SVNUIMessages.SVNView_Refresh_Label) { public void run() { RevPropertiesView.this.refreshView(); } }; action.setImageDescriptor(SVNTeamUIPlugin.instance().getImageDescriptor("icons/common/refresh.gif")); //$NON-NLS-1$ tbm.add(action); tbm.update(true); this.revPropComposite = new RevisionPropertiesComposite(parent); this.refreshView(); //Setting context help PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.team.svn.help.revPropertiesViewContext"); //$NON-NLS-1$ }
From source file:org.eclipse.team.ui.synchronize.ParticipantPageCompareEditorInput.java
License:Open Source License
protected IPage createPage(CompareViewerPane parent, IToolBarManager toolBarManager) { listener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(ISynchronizePageConfiguration.P_PAGE_DESCRIPTION)) { updateDescription();//from ww w.ja v a 2 s . co m } } }; pageConfiguration.addPropertyChangeListener(listener); updateDescription(); page = participant.createPage(pageConfiguration); site = new DialogSynchronizePageSite(parent.getShell(), true); ((SynchronizePageConfiguration) pageConfiguration).setSite(site); site.createActionBars(toolBarManager); try { ((ISynchronizePage) page).init(pageConfiguration.getSite()); } catch (PartInitException e1) { } page.createControl(parent); page.setActionBars(site.getActionBars()); toolBarManager.update(true); return page; }
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. * //from ww w .j ava 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.ui.internal.intro.impl.model.AbstractIntroPartImplementation.java
License:Open Source License
protected void addToolBarActions() { // Handle menus: IActionBars actionBars = getIntroPart().getIntroSite().getActionBars(); IToolBarManager toolBarManager = actionBars.getToolBarManager(); toolBarManager.add(viewIntroModelAction); toolBarManager.update(true); actionBars.updateActionBars();// w w w . ja va2 s .com }
From source file:org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation.java
License:Open Source License
protected void addToolBarActions() { // Handle menus: IActionBars actionBars = getIntroPart().getIntroSite().getActionBars(); IToolBarManager toolBarManager = actionBars.getToolBarManager(); actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), forwardAction); actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), backAction); if (IntroPlugin.DEBUG_TOOLBAR) { toolBarManager.add(viewIntroModelAction); toolBarManager.add(openBrowserAction); }//w ww . j a v a2s. c o m toolBarManager.add(new Separator(IntroConfigurer.TB_ADDITIONS)); toolBarManager.add(homeAction); toolBarManager.add(backAction); toolBarManager.add(forwardAction); toolBarManager.update(true); IntroTheme theme = getModel().getTheme(); boolean createZoomButtons = theme != null && theme.isScalable() && !resizeActionsAdded && FontSelection.FONT_RELATIVE.equals(FontSelection.getFontStyle()); if (createZoomButtons) { toolBarManager.add(new ReduceAction()); toolBarManager.add(new MagnifyAction()); } actionBars.updateActionBars(); updateNavigationActionsState(); }