Example usage for org.eclipse.jface.action IToolBarManager remove

List of usage examples for org.eclipse.jface.action IToolBarManager remove

Introduction

In this page you can find the example usage for org.eclipse.jface.action IToolBarManager remove.

Prototype

IContributionItem remove(String id);

Source Link

Document

Removes and returns the contribution item with the given id from this manager.

Usage

From source file:org.eclipse.orion.internal.server.ui.console.OrionConsoleView.java

License:Open Source License

protected void configureToolBar(IToolBarManager mgr) {
    super.configureToolBar(mgr);

    mgr.remove(IConsoleConstants.LAUNCH_GROUP);
    IContributionItem[] items = mgr.getItems();
    if (items.length >= 3) {
        mgr.remove(items[items.length - 1]);
        mgr.remove(items[items.length - 2]);
        mgr.remove(items[items.length - 3]);
    }//from   w ww. j a v  a  2 s  . c om
}

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());
        }/*from   w  ww  .ja  v a  2  s .c  om*/
    } else if (wasFound) {
        manager.remove(COMPLETE_COMMIT_ACTION_ID);
    }
    manager.update(true);
}

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  v a 2s .  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  . ja v  a2 s. co  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);
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.editor.DiagramOutlinePage.java

License:Open Source License

/**
 * {@inheritDoc}/*w w w.ja  va2 s .  c  o m*/
 * 
 * @see org.eclipse.sirius.common.ui.tools.api.outline.AbstractExtendedContentOutlinePage#dispose()
 */
@Override
public void dispose() {
    if (disposeListener != null) {
        if (getEditor() != null && !getEditor().isDisposed()) {
            getEditor().removeDisposeListener(disposeListener);
        }
        disposeListener = null;
    }

    IToolBarManager tbm = this.getSite().getActionBars().getToolBarManager();
    if (showOutlineAction != null) {
        tbm.remove(SIRIUS_DIAGRAM_OUTLINE_SHOW_OUTLINE);
        showOutlineAction = null;
    }
    if (showOverviewAction != null) {
        tbm.remove(SIRIUS_DIAGRAM_OUTLINE_SHOW_OVERVIEW);
        showOverviewAction = null;
    }

    if (thumbnail != null) {
        thumbnail.deactivate();
        thumbnail = null;
    }
    if (overview != null) {
        overview.dispose();
        overview = null;
    }
    overviewInitialized = false;

    pageBook.dispose();
    pageBook = null;
    contentProvider.dispose();
    contentProvider = null;
    labelProvider.dispose();
    labelProvider = null;
    viewerComparator = null;
    outlineViewer.getTree().dispose();
    outlineViewer = null;
    outline.dispose();
    outline = null;

    listeners.clear();
    menuContributions.clear();

    diagramWorkbenchPart = null;
    graphicalViewer = null;
    input = null;
    super.dispose();
}

From source file:org.eclipse.sirius.table.ui.tools.internal.editor.provider.DTableActionBarContributor.java

License:Open Source License

/**
 * Add the create line menu to the toolbar.
 * /*from   w w  w  .  j a v  a  2s .c  o  m*/
 * @param editorCreateLineMenuAction
 *            the menu to add
 */
public void addCreateLineMenu(final EditorCreateLineMenuAction editorCreateLineMenuAction) {
    final IToolBarManager toolBarManager = getActionBars().getToolBarManager();
    toolBarManager.remove(EditorCreateLineMenuAction.ID);
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, editorCreateLineMenuAction);
    toolBarManager.update(true);
}

From source file:org.eclipse.sirius.table.ui.tools.internal.editor.provider.DTableActionBarContributor.java

License:Open Source License

/**
 * Add the create target column menu to the toolbar.
 * /*from www .ja  v  a2s  . c o  m*/
 * @param editorCreateTargetColumnMenuAction
 *            the menu to add
 */
public void addCreateTargetColumnMenu(
        final EditorCreateTargetColumnMenuAction editorCreateTargetColumnMenuAction) {
    final IToolBarManager toolBarManager = getActionBars().getToolBarManager();
    toolBarManager.remove(EditorCreateTargetColumnMenuAction.ID);
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, editorCreateTargetColumnMenuAction);
    toolBarManager.update(true);
}

From source file:org.eclipse.sirius.tree.ui.tools.internal.editor.DTreeActionBarContributor.java

License:Open Source License

/**
 * Add the create tree item menu to the toolbar.
 * /*from  www .  j  av  a  2 s .c  o m*/
 * @param editorCreateLineMenuAction
 *            the menu to add
 */
public void addCreateTreeItemMenu(final EditorCreateTreeItemMenuAction editorCreateLineMenuAction) {
    final IToolBarManager toolBarManager = getActionBars().getToolBarManager();
    toolBarManager.remove(EditorCreateTreeItemMenuAction.ID);
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, editorCreateLineMenuAction); //$NON-NLS-1$
    toolBarManager.update(true);
}

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   w w  w.j  ava 2s  .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.navigator.CommonNavigatorActionGroup.java

License:Open Source License

private void updateToolBar(IToolBarManager toolBar) {
    boolean hasBeenFrameActionsShown = frameActionsShown;
    frameActionsShown = backAction.isEnabled() || upAction.isEnabled() || forwardAction.isEnabled();
    if (frameActionsShown != hasBeenFrameActionsShown) {
        if (hasBeenFrameActionsShown) {
            toolBar.remove(backAction.getId());
            toolBar.remove(forwardAction.getId());
            toolBar.remove(upAction.getId());
            toolBar.remove(FRAME_ACTION_SEPARATOR_ID);
        } else {/*  w  ww  .  j  a  va 2 s  .  co  m*/
            toolBar.prependToGroup(FRAME_ACTION_GROUP_ID, new Separator(FRAME_ACTION_SEPARATOR_ID));
            toolBar.prependToGroup(FRAME_ACTION_GROUP_ID, upAction);
            toolBar.prependToGroup(FRAME_ACTION_GROUP_ID, forwardAction);
            toolBar.prependToGroup(FRAME_ACTION_GROUP_ID, backAction);
        }
        toolBar.update(true);
    }
}