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

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

Introduction

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

Prototype

void appendToGroup(String groupName, IAction action);

Source Link

Document

Adds a contribution item for the given action at the end of the group with the given name.

Usage

From source file:org.eclipse.linuxtools.internal.docker.ui.RunConsolePageParticipant.java

License:Open Source License

/**
 * Contribute actions to the toolbar/*from w ww. j  a v a  2  s . c  om*/
 */
protected void configureToolBar(IToolBarManager mgr) {
    mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fRemove);
}

From source file:org.eclipse.linuxtools.internal.rpm.ui.RpmConsolePageParticipant.java

License:Open Source License

@Override
public void init(IPageBookViewPage page, IConsole console) {
    if (!(console instanceof RpmConsole)) {
        return;/*from ww  w. j  a va  2s  . c  o  m*/
    }
    IToolBarManager manager = page.getSite().getActionBars().getToolBarManager();

    StopBuildAction stopBuildAction = new StopBuildAction((RpmConsole) console);
    manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, stopBuildAction);

    CloseConsoleAction closeConsoleAction = new CloseConsoleAction((RpmConsole) console);
    manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, closeConsoleAction);
}

From source file:org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart.java

License:Open Source License

public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
    setContentDescription(description);//from   ww w  .  ja  v  a2s.com

    // remove tool specific toolbar controls
    IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
    if (dynamicActions != null) {
        for (ActionContributionItem item : dynamicActions) {
            toolbar.remove(item);
        }
    }

    // remove old view controls
    if (dynamicView != null) {
        dynamicView.dispose();
    }

    // remove old messages
    if (messages != null) {
        messagesViewer.getTreeViewer().setInput(null);
        messages = null;
    }

    for (Control child : dynamicViewHolder.getChildren()) {
        if (!child.isDisposed()) {
            child.dispose();
        }
    }

    if (toolID != null) {
        dynamicView = ValgrindUIPlugin.getDefault().getToolView(toolID);
        dynamicView.createPartControl(dynamicViewHolder);

        // create toolbar items
        IAction[] actions = dynamicView.getToolbarActions();
        if (actions != null) {
            dynamicActions = new ActionContributionItem[actions.length];
            for (int i = 0; i < actions.length; i++) {
                dynamicActions[i] = new ActionContributionItem(actions[i]);
                toolbar.appendToGroup(ValgrindUIPlugin.TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
            }
        }
    } else {
        dynamicView = null;
    }

    // remove old menu items
    IMenuManager menu = getViewSite().getActionBars().getMenuManager();
    menu.removeAll();
    // was content was created?
    hasDynamicContent = dynamicViewHolder.getChildren().length > 0;
    if (hasDynamicContent) {
        menu.add(showCoreAction);
        menu.add(showToolAction);
    }

    menu.update(true);
    toolbar.update(true);
    dynamicViewHolder.layout(true);

    return dynamicView;
}

From source file:org.eclipse.linuxtools.systemtap.ui.consolelog.ScriptConsolePageParticipant.java

License:Open Source License

@Override
public void init(IPageBookViewPage page, IConsole iConsole) {
    if (!(iConsole instanceof ScriptConsole)) {
        return;/*from  w  w w .  j  a  v a2s.  co m*/
    }

    fPage = page;
    fConsole = (ScriptConsole) iConsole;
    fView = (IConsoleView) fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW);

    StopScriptAction stopScriptAction = new StopScriptAction(fConsole);
    CloseStapConsoleAction closeConsoleAction = new CloseStapConsoleAction(fConsole);
    SaveLogAction saveLogAction = new SaveLogAction(fConsole);

    // contribute to toolbar
    IToolBarManager manager = fPage.getSite().getActionBars().getToolBarManager();
    manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, stopScriptAction);
    manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, closeConsoleAction);
    manager.appendToGroup(IConsoleConstants.OUTPUT_GROUP, saveLogAction);

    //TODO if {@link ModifyParsingAction} is restored, it is to be used here,
    //in the same way stopScriptAction and saveLogAction are used.

    DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow())
            .addDebugContextListener(this);
}

From source file:org.eclipse.linuxtools.valgrind.ui.ValgrindViewPart.java

License:Open Source License

/**
 * Returns a refreshable view specific of a Valgrind tool.
 *
 * @param description     the content description
 * @param toolID          the Valgrind tool identifier
 * @return                the Valgrind tool view
 * @throws CoreException  the toolbar is disposed
 *//*w ww  . ja v a 2 s  . c  o  m*/
public IValgrindToolView createDynamicContent(String description, String toolID) throws CoreException {
    setContentDescription(description);

    // remove tool specific toolbar controls
    IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
    ToolBar tb = ((ToolBarManager) toolbar).getControl();
    if (tb == null || tb.isDisposed()) {
        throw new CoreException(new Status(IStatus.ERROR, RVMatchPlugin.PLUGIN_ID, "Toolbar is disposed")); //$NON-NLS-1$
    }

    if (dynamicActions != null) {
        for (ActionContributionItem item : dynamicActions) {
            toolbar.remove(item);
        }
    }

    // remove old view controls
    if (dynamicView != null) {
        dynamicView.dispose();
    }

    // remove old messages
    if (messages != null) {
        messagesViewer.getTreeViewer().setInput(null);
        messages = null;
    }

    for (Control child : dynamicViewHolder.getChildren()) {
        if (!child.isDisposed()) {
            child.dispose();
        }
    }

    if (toolID != null) {
        dynamicView = RVMatchPlugin.getDefault().getToolView(toolID);
        dynamicView.createPartControl(dynamicViewHolder);

        // create toolbar items
        IAction[] actions = dynamicView.getToolbarActions();
        if (actions != null) {
            dynamicActions = new ActionContributionItem[actions.length];
            for (int i = 0; i < actions.length; i++) {
                dynamicActions[i] = new ActionContributionItem(actions[i]);
                toolbar.appendToGroup(TOOLBAR_LOC_GROUP_ID, dynamicActions[i]);
            }
        }
    } else {
        dynamicView = null;
    }

    // remove old menu items
    IMenuManager menu = getViewSite().getActionBars().getMenuManager();
    menu.removeAll();
    // was content was created?
    hasDynamicContent = dynamicViewHolder.getChildren().length > 0;
    if (hasDynamicContent) {
        menu.add(showCoreAction);
        menu.add(showToolAction);
    }

    menu.update(true);
    toolbar.update(true);
    // Update to notify the workbench items have been changed
    getViewSite().getActionBars().updateActionBars();
    dynamicViewHolder.layout(true);

    return dynamicView;
}

From source file:org.eclipse.m2e.core.ui.internal.console.MavenConsolePageParticipant.java

License:Open Source License

private void configureToolBar(IToolBarManager mgr) {
    mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, consoleRemoveAction);
    mgr.prependToGroup(IConsoleConstants.OUTPUT_GROUP, debugAction);
    mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, showOnOutputAction);
    mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, showOnErrorAction);
}

From source file:org.eclipse.mat.ui.internal.chart.PieChartPane.java

License:Open Source License

@Override
public void contributeToToolBar(IToolBarManager manager) {
    if (queryResult.getQuery() != null && queryResult.getQuery().getHelpUrl() != null)
        manager.appendToGroup("help", new OpenHelpPageAction(queryResult.getQuery().getHelpUrl())); //$NON-NLS-1$

    super.contributeToToolBar(manager);
}

From source file:org.eclipse.mat.ui.internal.viewer.RefinedResultViewer.java

License:Open Source License

public void contributeToToolBar(IToolBarManager manager) {
    Action calculateRetainedSizeMenu = new EasyToolBarDropDown(
            Messages.RefinedResultViewer_CalculateRetainedSize, //
            MemoryAnalyserPlugin.getImageDescriptor(MemoryAnalyserPlugin.ISharedImages.CALCULATOR), //
            editor) {/* w w w .  ja  v  a 2s . co m*/

        @Override
        public void contribute(PopupMenu menu) {
            List<ContextProvider> providers = new ArrayList<ContextProvider>();

            List<ContextProvider> p = result.getResultMetaData().getContextProviders();
            if (p != null && !p.isEmpty())
                providers.addAll(p);
            else
                providers.add(queryResult.getDefaultContextProvider());

            if (!providers.isEmpty()) {
                for (ContextProvider cp : providers) {
                    PopupMenu toThisMenu = menu;
                    if (providers.size() > 1) {
                        PopupMenu subMenu = new PopupMenu(cp.getLabel());
                        menu.add(subMenu);
                        toThisMenu = subMenu;
                    }

                    addRetainedSizeActions(toThisMenu, cp);
                }
            }
        }

        private void addRetainedSizeActions(PopupMenu toThisMenu, final ContextProvider cp) {
            ContextDerivedData derivedData = context.getContextDerivedData();
            if (derivedData == null)
                return;

            for (DerivedColumn derivedColumn : derivedData.getDerivedColumns()) {
                for (final DerivedOperation derivedOperation : derivedColumn.getOperations()) {
                    Action action = new Action(derivedOperation.getLabel()) {
                        @Override
                        public void run() {
                            doCalculateDerivedValuesForAll(cp, derivedOperation);
                        }
                    };

                    action.setImageDescriptor(MemoryAnalyserPlugin
                            .getImageDescriptor(MemoryAnalyserPlugin.ISharedImages.CALCULATOR));
                    toThisMenu.add(action);
                }
            }
        }

    };

    Action exportMenu = new EasyToolBarDropDown(Messages.RefinedResultViewer_Export,
            MemoryAnalyserPlugin.getImageDescriptor(MemoryAnalyserPlugin.ISharedImages.EXPORT_MENU), //
            editor) {

        @Override
        public void contribute(PopupMenu menu) {
            menu.add(new ExportActions.HtmlExport(control, result, context));
            menu.add(new ExportActions.CsvExport(control, result, context));
            menu.add(new ExportActions.TxtExport(control));
        }
    };

    manager.add(calculateRetainedSizeMenu);
    manager.add(exportMenu);

    if (queryResult.getQuery() != null && queryResult.getQuery().getHelpUrl() != null)
        manager.appendToGroup("help", new OpenHelpPageAction(queryResult.getQuery().getHelpUrl()));//$NON-NLS-1$

}

From source file:org.eclipse.mylyn.internal.reviews.ui.views.ReviewExplorer.java

License:Open Source License

/**
 * @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse.swt.widgets.Composite)
 *//*from  w ww . ja va2 s.c  om*/
@Override
public void createPartControl(Composite aParent) {
    IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager manager = actionBars.getToolBarManager();

    if (isSupportsListTree()) {
        showList = false;
        if (getMemento() != null) {
            Boolean value = getMemento().getBoolean(SHOW_VIEW_LIST);
            if (value != null) {
                showList = value;
            }
        }
        ShowTreeAction showTreeAction = new ShowTreeAction();
        showTreeAction.setChecked(!showList);
        ShowListAction showListAction = new ShowListAction();
        showListAction.setChecked(showList);
        manager.add(new Separator(TREE_ACTION_GROUP));
        manager.add(new Separator("presentation")); //$NON-NLS-1$
        manager.appendToGroup("presentation", showTreeAction); //$NON-NLS-1$
        manager.appendToGroup("presentation", showListAction); //$NON-NLS-1$
    }
    filterForComments = false;
    if (getMemento() != null) {
        Boolean value = getMemento().getBoolean(FILTER_FOR_COMMENTS);
        if (value != null) {
            filterForComments = value;
        }
    }
    manager.add(new Separator(FILTER_ACTION_GROUP));
    manager.appendToGroup(FILTER_ACTION_GROUP, new FilterNonCommentsReviewsAction());
    manager.add(new Separator("Separator")); //$NON-NLS-1$

    super.createPartControl(aParent);

    manager.add(new Separator(REFRESH_ACTION_GROUP));
    refreshAction = new RefreshReviewsAction();
    refreshAction.setEnabled(false);
    manager.appendToGroup(REFRESH_ACTION_GROUP, refreshAction);

    updateActivations();

    ReviewsUiPlugin.getDefault().getReviewManager().addReviewListener(new IActiveReviewListener() {

        @Override
        public void reviewDeactivated() {
            setReview(null);
        }

        @Override
        public void reviewActivated(IReview review) {
            setReview(review);
        }
    });
    setReview(getActiveReview());
}

From source file:org.eclipse.mylyn.internal.sandbox.ui.editors.ExtensibleBugzillaTaskEditorPage.java

License:Open Source License

private void addFindAction(IToolBarManager toolBarManager) {
    if (toggleFindAction != null && toggleFindAction.isChecked()) {
        ControlContribution findTextboxControl = new ControlContribution("Find") {
            @Override//w w  w .  j  a v  a2s. c  o m
            protected Control createControl(Composite parent) {
                FormToolkit toolkit = getTaskEditor().getHeaderForm().getToolkit();
                Composite findComposite = toolkit.createComposite(parent);
                findComposite.setLayout(new RowLayout());
                findComposite.setBackground(null);

                final Text findText = toolkit.createText(findComposite, "", SWT.FLAT);
                findText.setLayoutData(new RowData(100, SWT.DEFAULT));
                findText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
                findText.setFocus();
                toolkit.adapt(findText, false, false);
                findText.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetDefaultSelected(SelectionEvent event) {
                        try {
                            setReflow(false);
                            findAndHighlight(ExtensibleBugzillaTaskEditorPage.this, findText.getText());
                            // always toggle attachment part close after every search, since all ExpandableComposites are open
                            AbstractTaskEditorPart attachmentsPart = getPart(
                                    AbstractTaskEditorPage.ID_PART_ATTACHMENTS);
                            CommonFormUtil.setExpanded((ExpandableComposite) attachmentsPart.getControl(),
                                    false);
                        } finally {
                            setReflow(true);
                        }
                        reflow();
                    }
                });
                toolkit.paintBordersFor(findComposite);
                return findComposite;
            }

        };
        toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, findTextboxControl);
    }

    if (toggleFindAction == null) {
        toggleFindAction = new Action("", SWT.TOGGLE) {
            @Override
            public void run() {
                getTaskEditor().updateHeaderToolBar();
            }

        };
        toggleFindAction.setImageDescriptor(CommonImages.FIND);
        toggleFindAction.setToolTipText("Find");
        //getManagedForm().getForm().setData(TaskEditorFindHandler.KEY_FIND_ACTION, toggleFindAction);
    }

    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, toggleFindAction);
}