Example usage for org.eclipse.jface.action ICoolBarManager find

List of usage examples for org.eclipse.jface.action ICoolBarManager find

Introduction

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

Prototype

IContributionItem find(String id);

Source Link

Document

Finds the contribution item with the given id.

Usage

From source file:com.astra.ses.spell.dev.advisor.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  w  w .j a v  a2 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
            buildAllAction.setEnabled(enabled);
            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
                System.err.println("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
                System.err.println("File toolbar is missing"); //$NON-NLS-1$
                return;
            }
        }
    };
    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:com.astra.ses.spell.dev.advisor.WorkbenchActionBuilder.java

License:Open Source License

/**
  * Update the pin action's tool bar//from  w w  w. j  a v a  2s  . co m
  */
void updatePinActionToolbar() {

    ICoolBarManager coolBarManager = getActionBarConfigurer().getCoolBarManager();
    IContributionItem cbItem = coolBarManager.find(IWorkbenchActionConstants.TOOLBAR_NAVIGATE);
    if (!(cbItem instanceof IToolBarContributionItem)) {
        // This should not happen
        System.err.println("Navigation toolbar contribution item is missing"); //$NON-NLS-1$
        return;
    }
    IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem;
    IToolBarManager toolBarManager = toolBarItem.getToolBarManager();
    if (toolBarManager == null) {
        // error if this happens, navigation toolbar assumed to always exist
        System.err.println("Navigate toolbar is missing"); //$NON-NLS-1$
        return;
    }

    toolBarManager.update(false);
    toolBarItem.update(ICoolBarManager.SIZE);
}

From source file:com.generalrobotix.ui.view.GrxJythonPromptView.java

License:Open Source License

private IAction getStartSimulationAction() {
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    for (IWorkbenchWindow w : windows) {
        if (!(w instanceof ApplicationWindow))
            continue;
        ApplicationWindow window = (ApplicationWindow) w;
        ICoolBarManager coolbar = window.getCoolBarManager2();
        if (coolbar == null)
            continue;
        IContributionItem setitem = coolbar.find("com.generalrobotix.ui.actionSet");
        if (setitem != null && setitem instanceof ToolBarContributionItem) {
            IToolBarManager toolbar = ((ToolBarContributionItem) setitem).getToolBarManager();
            if (toolbar == null)
                continue;
            IContributionItem actitem = toolbar.find("com.generalrobotix.ui.actions.ExecuteScript");
            if (actitem != null && actitem instanceof ActionContributionItem)
                return ((ActionContributionItem) actitem).getAction();
        }//from   w  ww.  ja va 2s  . c  o m
    }
    return null;
}

From source file:com.google.dart.tools.deploy.ApplicationActionBarAdvisor.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.
 * /*ww  w.  ja  v  a 2  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() {
        @Override
        public void run() {
            if (isDisposed) {
                return;
            }
            //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;
            }
        }
    };
    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:com.google.dart.tools.deploy.ApplicationActionBarAdvisor.java

License:Open Source License

/**
 * Update the pin action's tool bar//from  ww  w.  j a  v  a 2 s . co m
 */
void updatePinActionToolbar() {

    ICoolBarManager coolBarManager = getActionBarConfigurer().getCoolBarManager();
    IContributionItem cbItem = coolBarManager.find(IWorkbenchActionConstants.TOOLBAR_NAVIGATE);
    if (!(cbItem instanceof IToolBarContributionItem)) {
        // This should not happen
        IDEWorkbenchPlugin.log("Navigation toolbar contribution item is missing"); //$NON-NLS-1$
        return;
    }
    IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem;
    IToolBarManager toolBarManager = toolBarItem.getToolBarManager();
    if (toolBarManager == null) {
        // error if this happens, navigation toolbar assumed to always exist
        IDEWorkbenchPlugin.log("Navigate toolbar is missing"); //$NON-NLS-1$
        return;
    }

    toolBarManager.update(false);
    toolBarItem.update(ICoolBarManager.SIZE);
}

From source file:es.cv.gvcase.mdt.common.part.SubActionBarsExt.java

License:Open Source License

/**
 * Gets the ToolBarManager looking for the parent tool bar and cleaning it
 * from duplicated items./*  w ww  .  j  av  a 2 s.c  o m*/
 */
public IToolBarManager getToolBarManager() {
    if (myToolBarManager == null) {
        ICoolBarManager parentCoolBarManager = getTopCoolBarManager();
        if (parentCoolBarManager == null) {
            return null;
        }
        IContributionItem foundItem = parentCoolBarManager.find(myType);
        if (foundItem instanceof ToolBarContributionItem
                && ((ToolBarContributionItem) foundItem).getToolBarManager() != null) {
            myToolBarContributionItem = (ToolBarContributionItem) foundItem;
            myToolBarManager = myToolBarContributionItem.getToolBarManager();
        } else {
            if (false == parentCoolBarManager instanceof ContributionManager) {
                return null;
            }
            myToolBarManager = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
            myToolBarContributionItem = new ToolBarContributionItem(myToolBarManager, myType);
            if (!((ContributionManager) parentCoolBarManager).replaceItem(myType, myToolBarContributionItem)) {
                parentCoolBarManager.add(myToolBarContributionItem);
            }
        }
        myToolBarContributionItem.setVisible(getActive());
        myToolBarManager.markDirty();
    }

    return myToolBarManager;
}

From source file:gov.redhawk.internal.ui.SubActionBarsExt.java

License:Open Source License

@Override
public IToolBarManager getToolBarManager() {
    if (this.myToolBarManager == null) {
        final ICoolBarManager parentCoolBarManager = getTopCoolBarManager();
        if (parentCoolBarManager == null) {
            return null;
        }//w ww  .j a  v  a 2 s.co m
        final IContributionItem foundItem = parentCoolBarManager.find(this.myType);
        if (foundItem instanceof ToolBarContributionItem
                && ((ToolBarContributionItem) foundItem).getToolBarManager() != null) {
            this.myToolBarContributionItem = (ToolBarContributionItem) foundItem;
            this.myToolBarManager = this.myToolBarContributionItem.getToolBarManager();
        } else {
            if (!(parentCoolBarManager instanceof ContributionManager)) {
                return null;
            }
            this.myToolBarManager = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
            this.myToolBarContributionItem = new ToolBarContributionItem(this.myToolBarManager, this.myType);
            if (!((ContributionManager) parentCoolBarManager).replaceItem(this.myType,
                    this.myToolBarContributionItem)) {
                parentCoolBarManager.add(this.myToolBarContributionItem);
            }
        }
        this.myToolBarContributionItem.setVisible(getActive());
        this.myToolBarManager.markDirty();
    }

    return this.myToolBarManager;
}

From source file:org.eclipse.datatools.enablement.rcp.ApplicationActionBarAdvisor.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 a v  a  2s.  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
            buildAllAction.setEnabled(enabled);
            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);
            }
        }
    };
    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.debug.internal.ui.contextlaunching.LaunchingResourceManager.java

License:Open Source License

/**
 * Adds a mouse listener to the launch toolbar 
 * /*from w ww.j  ava  2s.  c  om*/
 * @param window the {@link IWorkbenchWindow} to work with
 */
private void addMouseListener(IWorkbenchWindow window) {
    ICoolBarManager cmgr = ((WorkbenchWindow) window).getCoolBarManager2();
    if (cmgr != null) {
        IContributionItem item = cmgr.find("org.eclipse.debug.ui.launchActionSet"); //$NON-NLS-1$
        if (item instanceof ToolBarContributionItem) {
            ToolBarManager tmgr = (ToolBarManager) ((ToolBarContributionItem) item).getToolBarManager();
            ToolBar bar = tmgr.getControl();
            if (bar != null && !bar.isDisposed()) {
                bar.addMouseTrackListener(fMouseListener);
                fToolbars.put(window, bar);
            }
        }
    }
}

From source file:org.eclipse.epf.library.ui.LibraryUIManager.java

License:Open Source License

/**
 * Displays the method configuration combobox in the system toolbar.
 *//*from   ww  w  .  j a v  a 2s . c  o m*/
private void showConfigurationContribution(ICoolBarManager coolBarMgr) throws Exception {
    // Check for the method configuration combobox toolbar.
    IContributionItem configToolBar = coolBarMgr.find(TOOLBAR_CONFIG_CONTRIBUTION_ID);

    if (configToolBar != null) {
        // Make sure the toolbar has the method configuration combobox
        // contribution.
        if (configToolBar instanceof ToolBarContributionItem) {
            IToolBarManager toolBarMgr = ((ToolBarContributionItem) configToolBar).getToolBarManager();
            if (toolBarMgr != null) {
                IContributionItem[] toolBarItems = toolBarMgr.getItems();
                if (toolBarItems != null && toolBarItems.length > 0) {
                    for (int i = 0; i < toolBarItems.length; i++) {
                        toolBarItems[i].setVisible(true);
                    }
                    configToolBar.setVisible(true);
                    updateSystemToolBar(coolBarMgr);
                    return;
                }
            }

            // The method configuration combobox toolbar has been restored
            // via a saved perspective, add the method configuration
            // combobox contribution.
            configCombo = new ConfigurationContributionItem(null);
            if (DebugUtil.uiDebug) {
                DebugUtil.print("showConfigurationContribution, configCombo 1: " + configCombo);//$NON-NLS-1$
                DebugUtil.print();
            }
            configCombo.setId(ConfigurationContributionItem.class.getName());
            toolBarMgr.add(configCombo);
            configToolBar.setVisible(true);
            updateSystemToolBar(coolBarMgr);
            return;
        }
    }

    IToolBarManager toolBarMgr = new ToolBarManager(SWT.FLAT | SWT.LEFT);
    configCombo = new ConfigurationContributionItem(null);
    if (DebugUtil.uiDebug) {
        DebugUtil.print("showConfigurationContribution, configCombo 2: " + configCombo);//$NON-NLS-1$
        DebugUtil.print();
    }
    configCombo.setId(ConfigurationContributionItem.class.getName());
    toolBarMgr.add(configCombo);
    ToolBarContributionItem configComboToolBar = new ToolBarContributionItem(toolBarMgr,
            TOOLBAR_CONFIG_CONTRIBUTION_ID);
    coolBarMgr.add(configComboToolBar);
}