List of usage examples for org.eclipse.jface.action IToolBarManager find
IContributionItem find(String id);
From source file:org.eclipse.egit.ui.internal.repository.BranchPropertySource.java
License:Open Source License
/** * @param repository// www . j a va 2 s.co m * the repository * @param fullBranchName * the full name of the branch to show * @param page * the page showing the properties */ public BranchPropertySource(Repository repository, String fullBranchName, PropertySheetPage page) { myPage = page; myBranchName = Repository.shortenRefName(fullBranchName); myRepository = repository; synchronized (myPage) { // check if the actions are already there, if not, create them IActionBars bars = myPage.getSite().getActionBars(); IToolBarManager mgr = bars.getToolBarManager(); editAction = ((ActionContributionItem) mgr.find(EDITACTIONID)); if (editAction != null) ((EditAction) editAction.getAction()).setSource(this); else { editAction = new ActionContributionItem( new EditAction(UIText.RepositoryPropertySource_EditConfigButton, UIIcons.EDITCONFIG, this)); mgr.add(new Separator()); mgr.add(editAction); } mgr.update(false); } }
From source file:org.eclipse.elk.core.ui.views.LayoutViewPart.java
License:Open Source License
/** * {@inheritDoc}//from ww w . j a v a 2s .co m */ @Override public void createPartControl(final Composite parent) { // GUI code needs magic numbers // CHECKSTYLEOFF MagicNumber toolkit = new FormToolkit(parent.getDisplay()); Form form = toolkit.createForm(parent); // Content Composite content = form.getBody(); FormLayout contentLayout = new FormLayout(); contentLayout.marginWidth = MARGIN_WIDTH; content.setLayout(contentLayout); // Property Sheet Page page = new PropertySheetPage(); page.setRootEntry(new ValidatingPropertySheetEntry()); page.createControl(content); FormData formData = new FormData(); formData.left = new FormAttachment(FORM_LEFT, 0); formData.right = new FormAttachment(FORM_RIGHT, 0); formData.top = new FormAttachment(FORM_TOP, 5); formData.bottom = new FormAttachment(FORM_BOTTOM, 0); page.getControl().setLayoutData(formData); IPreferenceStore preferenceStore = ElkUiPlugin.getInstance().getPreferenceStore(); // add actions to the toolbar, view menu, and context menu IActionBars actionBars = getViewSite().getActionBars(); page.setActionBars(actionBars); IToolBarManager toolBarManager = actionBars.getToolBarManager(); // CHECKSTYLEON MagicNumber // set the stored value of the categories button ActionContributionItem categoriesItem = (ActionContributionItem) toolBarManager.find("categories"); if (categoriesItem != null) { categoriesItem.getAction().setChecked(preferenceStore.getBoolean(PREF_CATEGORIES)); categoriesItem.getAction().run(); } // set the stored value of the advanced button ActionContributionItem advancedItem = (ActionContributionItem) toolBarManager.find("filter"); if (advancedItem != null) { advancedItem.getAction().setChecked(preferenceStore.getBoolean(PREF_ADVANCED)); advancedItem.getAction().run(); } // get the current selection and trigger an update IWorkbenchWindow workbenchWindow = getSite().getWorkbenchWindow(); IWorkbenchPage activePage = workbenchWindow.getActivePage(); if (activePage != null) { final IWorkbenchPart activePart = activePage.getActivePart(); final ISelection selection = workbenchWindow.getSelectionService().getSelection(); if (activePart != null && selection != null) { workbenchWindow.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { selectionListener.selectionChanged(activePart, selection); } }); } } workbenchWindow.getSelectionService().addSelectionListener(selectionListener); workbenchWindow.getPartService().addPartListener(partListener); }
From source file:org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.Zoom.java
License:Open Source License
/** * Set action check state of a view action for a given action ID. * @param id The action ID/* www . j a v a 2 s.c o m*/ * @param checked true to check the action, false to uncheck the action */ protected void setActionChecked(String id, boolean checked) { if (fView != null) { IActionBars bar = fView.getViewSite().getActionBars(); if (bar == null) { return; } 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.linuxtools.tmf.ui.views.uml2sd.SDView.java
License:Open Source License
/** * Updates the view coolbar buttons state according to the value return by: - * ISDExtendedActionBarProvider.hasNextPage()<br> * - ISDExtendedActionBarProvider.hasPrevPage()<br> * /* www . jav a 2 s . co m*/ */ public void updateCoolBar() { if (sdPagingProvider != null) { IActionBars bar = getViewSite().getActionBars(); if (bar == null) return; IToolBarManager barManager = bar.getToolBarManager(); if (barManager == null) return; IContributionItem nextPage = barManager.find(NextPage.ID); if (nextPage != null && nextPage instanceof ActionContributionItem) { IAction nextPageAction = ((ActionContributionItem) nextPage).getAction(); if (nextPageAction != null && nextPageAction instanceof NextPage) { ((NextPage) nextPageAction).setEnabled(sdPagingProvider.hasNextPage()); } } IContributionItem prevPage = barManager.find(PrevPage.ID); if (prevPage != null && prevPage instanceof ActionContributionItem) { IAction prevPageAction = ((ActionContributionItem) prevPage).getAction(); if (prevPageAction != null && prevPageAction instanceof PrevPage) { ((PrevPage) prevPageAction).setEnabled(sdPagingProvider.hasPrevPage()); } } IContributionItem firstPage = barManager.find(FirstPage.ID); if (firstPage != null && firstPage instanceof ActionContributionItem) { IAction firstPageAction = ((ActionContributionItem) firstPage).getAction(); if (firstPageAction != null && firstPageAction instanceof FirstPage) { ((FirstPage) firstPageAction).setEnabled(sdPagingProvider.hasPrevPage()); } } IContributionItem lastPage = barManager.find(LastPage.ID); if (lastPage != null && lastPage instanceof ActionContributionItem) { IAction lastPageAction = ((ActionContributionItem) lastPage).getAction(); if (lastPageAction != null && lastPageAction instanceof LastPage) { ((LastPage) lastPageAction).setEnabled(sdPagingProvider.hasNextPage()); } } updatePagesMenuItem(bar); } }
From source file:org.eclipse.mylyn.internal.tasks.ui.views.TaskListView.java
License:Open Source License
public void setFocusedMode(boolean focusedMode) { if (this.focusedMode == focusedMode) { return;//from ww w . j ava2 s . co m } this.focusedMode = focusedMode; customDrawer.setFocusedMode(focusedMode); IToolBarManager manager = getViewSite().getActionBars().getToolBarManager(); ToolBarManager toolBarManager = getToolBarManager(manager); try { if (toolBarManager != null) { toolBarManager.getControl().setRedraw(false); } if (focusedMode && isAutoExpandMode()) { manager.remove(FilterCompletedTasksAction.ID); manager.remove(CollapseAllAction.ID); } else if (manager.find(CollapseAllAction.ID) == null) { manager.prependToGroup(ID_SEPARATOR_CONTEXT, collapseAll); manager.prependToGroup(ID_SEPARATOR_CONTEXT, filterCompleteTask); } updateFilterEnablement(); getViewSite().getActionBars().updateActionBars(); } finally { if (toolBarManager != null) { toolBarManager.getControl().setRedraw(true); } } }
From source file:org.eclipse.osee.framework.ui.skynet.widgets.xmerge.MergeXWidget.java
License:Open Source License
private void setCompleteCommitItemVisible(boolean isVisible) { IToolBarManager manager = getToolBarManager(); boolean wasFound = manager.find(COMPLETE_COMMIT_ACTION_ID) != null; if (isVisible) { if (!wasFound) { manager.insertBefore(REFRESH_ACTION_ID, getCompleteCommitAction()); }// w w w . j a v a 2 s .c om } else if (wasFound) { manager.remove(COMPLETE_COMMIT_ACTION_ID); } manager.update(true); }
From source file:org.eclipse.php.composer.ui.editor.composer.DependencyGraphPage.java
License:Open Source License
@Override public void contributeToToolbar(IToolBarManager manager, IManagedForm headerForm) { this.manager = manager; searchControl = new SearchControl(SEARCH_ID, headerForm); searchControl.setVisible(false);// w w w . j a v a 2 s . com searchControl.addModifyListener(this); manager.add(searchControl); manager.add(new ToggleDevAction(this)); manager.find(ToggleDevAction.ID).setVisible(false); Separator graphSeparator = new Separator(); graphSeparator.setId(SEPARATOR_ID); graphSeparator.setVisible(false); manager.add(graphSeparator); }
From source file:org.eclipse.ptp.internal.ui.actions.RemoveElementAction.java
License:Open Source License
/** * Call delete group action/* www. ja v a2s .c om*/ * */ private void callDeleteGroupAction() { IToolBarManager manager = view.getViewSite().getActionBars().getToolBarManager(); IContributionItem item = manager.find(DeleteSetAction.name); if (item != null && item instanceof ActionContributionItem) { ((ActionContributionItem) item).getAction().run(); } }
From source file:org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor.java
License:Open Source License
@Override public void init(IActionBars bars) { disableActionBarUIUpdates();//from w ww.j a va2s .c o m try { super.init(bars); IToolBarManager toolBarManager = bars.getToolBarManager(); toolBarManager.remove(ActionIds.MENU_COMPARTMENT); toolBarManager.remove(ActionIds.ACTION_COMPARTMENT_ALL); toolBarManager.remove(ActionIds.ACTION_COMPARTMENT_NONE); toolBarManager.remove(ActionIds.ACTION_HIDE_CONNECTION_LABELS); toolBarManager.remove(ActionIds.ACTION_SHOW_CONNECTION_LABELS); toolBarManager.remove(ActionIds.ACTION_SHOW_COMPARTMENT_TITLE); if (!isOldUIEnabled()) { // The actions create for the default GMF toolbar are no longer // useful. They must be removed from the toolbarManager and // disposed. This avoids unnecessary notifications and // calculations // on these actions. cleanOldToolBarGMFAction(toolBarManager, ActionIds.CUSTOM_FONT_NAME); cleanOldToolBarGMFAction(toolBarManager, ActionIds.CUSTOM_FONT_COLOR); cleanOldToolBarGMFAction(toolBarManager, ActionIds.CUSTOM_FONT_SIZE); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_FONT_ITALIC); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_FONT_BOLD); cleanOldToolBarGMFAction(toolBarManager, ActionIds.CUSTOM_FILL_COLOR); cleanOldToolBarGMFAction(toolBarManager, ActionIds.CUSTOM_LINE_COLOR); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_MAKE_SAME_SIZE_BOTH); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_AUTOSIZE); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_COPY_APPEARANCE_PROPERTIES); cleanOldToolBarGMFAction(toolBarManager, ActionIds.CUSTOM_ZOOM); cleanOldToolBarGMFAction(toolBarManager, ActionIds.MENU_ARRANGE); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ARRANGE_ALL); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ARRANGE_SELECTION); cleanOldToolBarGMFAction(toolBarManager, ActionIds.MENU_ARRANGE_TOOLBAR); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_TOOLBAR_ARRANGE_ALL); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_TOOLBAR_ARRANGE_SELECTION); cleanOldToolBarGMFAction(toolBarManager, ActionIds.MENU_SELECT); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_SELECT_ALL_CONNECTIONS); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_SELECT_ALL_SHAPES); cleanOldToolBarGMFAction(toolBarManager, ActionIds.MENU_SELECT_TOOLBAR); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_TOOLBAR_SELECT_ALL_SHAPES); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_TOOLBAR_SELECT_ALL_CONNECTIONS); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_TOOLBAR_SELECT_ALL); cleanOldToolBarGMFAction(toolBarManager, ActionIds.MENU_ALIGN); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ALIGN_BOTTOM); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ALIGN_CENTER); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ALIGN_LEFT); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ALIGN_MIDDLE); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ALIGN_RIGHT); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ALIGN_TOP); cleanOldToolBarGMFAction(toolBarManager, ActionIds.MENU_ROUTER); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ROUTER_OBLIQUE); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ROUTER_RECTILINEAR); cleanOldToolBarGMFAction(toolBarManager, ActionIds.ACTION_ROUTER_TREE); } else { Bundle uiWorkbenchBundle = Platform.getBundle("org.eclipse.ui.workbench"); //$NON-NLS-1$ Version junoStart = Version.parseVersion("3.103"); // Version keplerStart = Version.parseVersion("3.105"); if (uiWorkbenchBundle != null && uiWorkbenchBundle.getVersion().compareTo(junoStart) < 0) { // Do not reorder old ui toolbar for 4.x. IContributionItem arrange = toolBarManager.find(ActionIds.MENU_ARRANGE); IContributionItem diagram = toolBarManager.find(REFRESH_DIAGRAM); if (arrange != null && diagram != null) { toolBarManager.remove(arrange); toolBarManager.insertBefore(REFRESH_DIAGRAM, arrange); IContributionItem select = toolBarManager.find(ActionIds.MENU_SELECT); if (select != null) { toolBarManager.remove(select); toolBarManager.insertAfter(ActionIds.MENU_ARRANGE, select); IContributionItem align = toolBarManager.find(ActionIds.MENU_ALIGN); if (align != null) { toolBarManager.remove(align); toolBarManager.insertAfter(ActionIds.MENU_SELECT, align); toolBarManager.insertAfter(ActionIds.MENU_ALIGN, new Separator()); } } } IContributionItem setStyleItem = toolBarManager .find(SetStyleToWorkspaceImageAction.SET_STYLE_TO_WORKSPACE_IMAGE_ACTION_ID); IContributionItem copyApparenceItem = toolBarManager .find(ActionIds.ACTION_COPY_APPEARANCE_PROPERTIES); if (setStyleItem != null && copyApparenceItem != null) { toolBarManager.remove(setStyleItem); toolBarManager.insertBefore(ActionIds.ACTION_COPY_APPEARANCE_PROPERTIES, setStyleItem); } IContributionItem zoom = toolBarManager.find(ActionIds.CUSTOM_ZOOM); IContributionItem launchBehavior = toolBarManager.find(LAUNCH_BEHAVIOR); if (zoom != null && launchBehavior != null) { toolBarManager.remove(zoom); toolBarManager.insertAfter(LAUNCH_BEHAVIOR, zoom); } } } } finally { reenableActionBarUIUpdates(); } }
From source file:org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor.java
License:Open Source License
/** * Remove the contribution with the given id and dispose the corresponding * action if this contribution is an {@link ActionContributionItem}. * // w ww. jav a 2s . c o m * @param toolBarManager * The {@link IToolBarManager} to clean. * @param actionId * The id of the action to clean. */ private void cleanOldToolBarGMFAction(IToolBarManager toolBarManager, String actionId) { IContributionItem contribution = toolBarManager.find(actionId); if (contribution instanceof ActionContributionItem) { if (((ActionContributionItem) contribution).getAction() instanceof Disposable) { ((Disposable) ((ActionContributionItem) contribution).getAction()).dispose(); } } toolBarManager.remove(contribution); }