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.summer.ss.ide.highlighting.ShowWhitespaceCharactersActionContributor.java

License:Open Source License

public void contributeActions(XtextEditor editor) {
    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"));
    IToolBarManager toolBarManager = editor.getEditorSite().getActionBars().getToolBarManager();
    toolBarManager.remove(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
    toolBarManager.add(action);/* w w  w . jav  a  2 s  . c om*/
}

From source file:org.talend.designer.core.ui.editor.palette.TalendPaletteHelper.java

License:Open Source License

private static void updatePaletteActions(IActionBars actionBars, IAction action, boolean isTalendEditor) {
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    IContributionItem cItem = toolBarManager.find(action.getClass().getCanonicalName());
    if (cItem == null) {
        if (isTalendEditor) {
            toolBarManager.add(action);/* ww  w . jav  a2 s . co  m*/
        }
    } else {
        if (!isTalendEditor) {
            toolBarManager.remove(new ActionContributionItem(action));
        }
    }
}

From source file:org.wesnoth.product.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 av a  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.xmind.ui.internal.browser.InternalBrowserView.java

License:Open Source License

private void removeControls(IToolBarManager toolBar) {
    if (backActionItem != null) {
        toolBar.remove(backActionItem);
        backActionItem.dispose();//from  w  w w .j  a v a 2s. c  o m
        backActionItem = null;
    }
    if (forwardActionItem != null) {
        toolBar.remove(forwardActionItem);
        forwardActionItem.dispose();
        forwardActionItem = null;
    }
    if (stopRefreshActionItem != null) {
        toolBar.remove(stopRefreshActionItem);
        stopRefreshActionItem.dispose();
        stopRefreshActionItem = null;
    }
}

From source file:ummisco.gama.ui.navigator.GamaNavigator.java

@Override
public void createPartControl(final Composite compo) {
    this.parent = GamaToolbarFactory.createToolbars(this, compo);

    super.createPartControl(parent);
    restoreState();/*from   w w w .  ja  v  a  2s  . c  o  m*/
    final IToolBarManager tb = getViewSite().getActionBars().getToolBarManager();
    for (final IContributionItem item : tb.getItems()) {
        if (item instanceof ActionContributionItem) {
            final ActionContributionItem aci = (ActionContributionItem) item;
            final IAction action = aci.getAction();
            if (action instanceof LinkEditorAction) {
                link = action;
                tb.remove(aci);
            } else if (action instanceof org.eclipse.ui.internal.navigator.actions.CollapseAllAction) {
                tb.remove(aci);
            }

        }
    }
    linkItem.setSelection(link.isChecked());
    tb.update(true);
    tb.insertBefore("toolbar.toggle", byDate.toCheckAction());
    tb.insertBefore("toolbar.toggle", expandAll.toAction());
    tb.insertBefore(expandAll.getId(), collapseAll.toAction());

    try {
        final IDecoratorManager mgr = PlatformUI.getWorkbench().getDecoratorManager();
        mgr.setEnabled("msi.gama.application.date.decorator", false);
    } catch (final CoreException e) {
        e.printStackTrace();
    }
    properties = new PropertyDialogAction(new SameShellProvider(getSite().getShell()),
            getSite().getSelectionProvider());
    findControl.initialize();

}