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.jboss.tools.central.editors.JBossCentralEditor.java

License:Open Source License

@Override
protected void createHeaderContents(IManagedForm headerForm) {
    final ScrolledForm form = headerForm.getForm();
    //form.setText(JBOSS_CENTRAL);
    new HeaderText(form);
    form.setToolTipText(JBOSS_CENTRAL);/* www .  j a  va  2  s  .c o  m*/
    form.setImage(getHeaderImage());
    getToolkit().decorateFormHeading(form.getForm());

    final IToolBarManager toolbar = form.getToolBarManager();
    ControlContribution searchControl = new ControlContribution("Search") {
        @Override
        protected Control createControl(Composite parent) {
            return createSearchControl(parent);
        }
    };
    toolbar.add(searchControl);
    toolbar.add(new GroupMarker(COMMANDS_GROUP));
    String[] commandIds = ProjectExamplesActivator.getDefault().getConfigurator().getMainToolbarCommandIds();
    for (String commandId : commandIds) {
        CommandContributionItem item = JBossCentralActivator.createContributionItem(getSite(), commandId);
        toolbar.appendToGroup(COMMANDS_GROUP, item);
    }

    toolbar.update(true);
    form.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (toolbar instanceof ToolBarManager) {
                ((ToolBarManager) toolbar).dispose();
            } else {
                toolbar.removeAll();
            }
            form.removeDisposeListener(this);
        }
    });
    form.layout(true, true);
}

From source file:org.jboss.tools.forge.ui.internal.part.ForgeConsolePage.java

License:Open Source License

void initialize(IViewSite viewSite) {
    pageSite = new PageSite(viewSite);
    actionBars = (SubActionBars) pageSite.getActionBars();
    IAction[] actions = forgeConsole.createActions();
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    for (IAction action : actions) {
        toolBarManager.appendToGroup(ForgeConsoleView.FORGE_CONSOLE_ACTION_GROUP, action);
    }/*from www. j av a2 s.  c  o m*/
    actionBars.getMenuManager().add(new ShowForgeMenuAction(pageSite.getWorkbenchWindow()));
}

From source file:org.jboss.tools.vpe.preview.core.util.ActionBar.java

License:Open Source License

public void fillLocalToolBar(IToolBarManager manager) {
    makeActions();/*w  w w.j a  v  a2  s.  com*/

    manager.add(refreshAction);
    manager.add(openInDefaultBrowserAction);
    manager.add(new Separator(GROUP_REFRESH));
    manager.appendToGroup(GROUP_REFRESH, enableAutomaticRefreshAction);
    manager.appendToGroup(GROUP_REFRESH, enableRefreshOnSaveAction);
}

From source file:org.kalypso.metadoc.ui.ExportActionContributor.java

License:Open Source License

/**
 * Fills the export actions into the given target-editor
 *
 * @param mode//from   w  w w .  j  a va2 s . co m
 *          the mode (in the sense of the org.kalypso.metadoc.exportTarget) which denotes which kind of perspective
 *          should be supported by the extension. Optional, can be null, which means take all targets.
 */
public static ExportAction[] contributeActions(final IEditorPart targetEditor, final String menuPath,
        final String toolbarGroup, final String mode) {
    try {
        final IActionBars actionBars = targetEditor.getEditorSite().getActionBars();
        final ExportAction[] actions = createActions(targetEditor, mode);
        final IMenuManager menuManager = actionBars.getMenuManager();

        final IContributionItem menuItem = menuManager.findUsingPath(menuPath);

        final IToolBarManager toolBarManager = actionBars.getToolBarManager();

        for (final ExportAction action : actions) {
            if (menuItem != null) {
                if (menuItem instanceof GroupMarker) {
                    final GroupMarker marker = (GroupMarker) menuItem;
                    final IContributionManager parent = marker.getParent();
                    parent.appendToGroup(marker.getGroupName(), action);
                } else if (menuItem instanceof IMenuManager) {
                    final IMenuManager mm = (IMenuManager) menuItem;
                    mm.add(action);
                }
            }

            if (toolBarManager != null)
                toolBarManager.appendToGroup(toolbarGroup, action);
        }

        return actions;
    } catch (final CoreException e) {
        e.printStackTrace();
        ErrorDialog.openError(targetEditor.getSite().getShell(), "Export Targets laden",
                "Fehler beim Laden der Export Targets", e.getStatus());

        return null;
    }
}

From source file:org.l2x6.eircc.ui.views.IrcAccountsView.java

License:Open Source License

@Override
public void createPartControl(Composite container) {

    pagebook = new PageBook(container, SWT.NONE);

    emptyLabel = new Label(pagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
    emptyLabel.setText(IrcUiMessages.IrcServersView_empty);

    accountsDetailsSplitter = new SashForm(pagebook, SWT.VERTICAL);
    // accountsDetailsSplitter.setVisible(false);

    /* accounts tree */
    accountsTreeViewer = new TreeViewer(accountsDetailsSplitter, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    accountsTreeViewer.setLabelProvider(IrcLabelProvider.getInstance());
    accountsTreeViewer.setContentProvider(new IrcAccountsTreeContentProvider());
    accountsTreeViewer.addSelectionChangedListener(treesSelectionListener);

    /* the bottom part */

    /* server channels */
    serverChannelsViewForm = new ViewForm(accountsDetailsSplitter, SWT.NONE);
    accountsDetailsSplitter.setWeights(new int[] { 35, 65 });

    serverChannelsTreeViewer = new TreeViewer(serverChannelsViewForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    serverChannelsTreeViewer.setLabelProvider(IrcLabelProvider.getInstance());
    serverChannelsTreeViewer.setContentProvider(new IrcServerChannelsTreeContentProvider());
    serverChannelsTreeViewer.addSelectionChangedListener(treesSelectionListener);

    serverChannelsViewForm.setContent(serverChannelsTreeViewer.getControl());

    serverChannelsLabel = new CLabel(serverChannelsViewForm, SWT.NONE);
    serverChannelsViewForm.setTopLeft(serverChannelsLabel);
    serverChannelsLabel.setText(IrcUiMessages.IrcAccountsView_serverChannelsLabel_text);

    ToolBar serverChannelsToolbar = new ToolBar(serverChannelsViewForm, SWT.FLAT | SWT.WRAP);
    serverChannelsViewForm.setTopCenter(serverChannelsToolbar);

    /* server users */
    // TODO server users pane

    /* connect the model */
    IrcModel ircModel = EirccUi.getDefault().getModel();
    ircModel.addModelEventListener(this);
    accountsTreeViewer.setInput(ircModel);
    setEmptyLabelVisible(!ircModel.hasAccounts());

    /* actions, tolbars and menus */

    /* acounts related actions */
    Tree accountsTree = accountsTreeViewer.getTree();
    accountsTree.addListener(SWT.Selection, getAccountsTreeSelectionListener());
    accountsTree.addMouseListener(getTreeMouseListener());
    accountsTree.addFocusListener(treesFocusListener);
    addIrcAccountAction = new AddIrcAccountAction();
    listChannelsAction = IrcTreeActions.createListChannelsAction(accountsTree);
    connectAccountAction = IrcTreeActions.createConnectAccountAction(accountsTree);
    disconnectAccountAction = IrcTreeActions.createDisonnectAccountAction(accountsTree);
    joinAccountChannelAction = IrcTreeActions.createJoinAccountChannelAction(accountsTree);
    promptChannelAndJoinAction = new PromptAndJoinChannelAction(accountsTree);
    leaveAccountChannelAction = IrcTreeActions.createLeaveChannelAction(accountsTree);
    watchChannelAction = IrcTreeActions.createWatchChannelAction(accountsTree);

    IViewSite site = getViewSite();/*from   w w  w .  j a  v a2 s.  c o  m*/
    IToolBarManager accountsTbm = site.getActionBars().getToolBarManager();
    accountsTbm.add(new Separator(ContextMenuConstants.GROUP_IRC_ACCOUNTS));
    accountsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_ACCOUNTS, addIrcAccountAction);
    accountsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_ACCOUNTS, connectAccountAction);
    accountsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_ACCOUNTS, disconnectAccountAction);
    accountsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_ACCOUNTS, joinAccountChannelAction);
    accountsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_ACCOUNTS, leaveAccountChannelAction);
    site.getActionBars().updateActionBars();

    /* accounts tree context menu */
    MenuManager accountsMenuManager = new MenuManager("#PopupMenu");
    Menu accountsMenu = accountsMenuManager.createContextMenu(accountsTree);
    accountsMenuManager.add(addIrcAccountAction);
    accountsMenuManager.add(listChannelsAction);
    accountsMenuManager.add(connectAccountAction);
    accountsMenuManager.add(disconnectAccountAction);
    accountsMenuManager.add(joinAccountChannelAction);
    accountsMenuManager.add(promptChannelAndJoinAction);
    accountsMenuManager.add(leaveAccountChannelAction);
    accountsMenuManager.add(watchChannelAction);
    accountsTree.setMenu(accountsMenu);
    site.registerContextMenu(accountsMenuManager, accountsTreeViewer);

    /* server channels related actions */
    Tree serverChannelsTree = serverChannelsTreeViewer.getTree();
    serverChannelsTree.addMouseListener(getTreeMouseListener());
    serverChannelsTree.addFocusListener(treesFocusListener);

    joinServerChannelAction = IrcTreeActions.createJoinServerChannelAction(serverChannelsTree);
    treeActions = new IrcTreeAction[] { listChannelsAction, connectAccountAction, disconnectAccountAction,
            joinAccountChannelAction, promptChannelAndJoinAction, leaveAccountChannelAction,
            joinServerChannelAction, watchChannelAction };

    ToolBarManager serverChannelsTbm = new ToolBarManager(serverChannelsToolbar);
    serverChannelsTbm.add(new Separator(ContextMenuConstants.GROUP_IRC_SERVER_CHANNELS));
    serverChannelsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_SERVER_CHANNELS, listChannelsAction);
    serverChannelsTbm.appendToGroup(ContextMenuConstants.GROUP_IRC_SERVER_CHANNELS, joinServerChannelAction);
    serverChannelsTbm.update(false);

    /* server channels context menu */
    MenuManager serverChannelsMenuManager = new MenuManager("#PopupMenu");
    Menu serverChannelsMenu = serverChannelsMenuManager.createContextMenu(accountsTree);
    serverChannelsMenuManager.add(listChannelsAction);
    serverChannelsMenuManager.add(joinServerChannelAction);
    serverChannelsTree.setMenu(serverChannelsMenu);
    site.registerContextMenu(serverChannelsMenuManager, serverChannelsTreeViewer);

    if (site != null) {
        IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
        if (handlerService != null) {
            collapseAllAccounts = new CollapseAllHandler(accountsTreeViewer);
            handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, collapseAllAccounts);
            expandAllAccounts = new ExpandAllHandler(accountsTreeViewer);
            handlerService.activateHandler(ExpandAllHandler.COMMAND_ID, expandAllAccounts);
        }
    }
}

From source file:org.locationtech.udig.style.ui.StyleView.java

License:Open Source License

private void createToolBar() {
    IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();

    mgr.add(new GroupMarker(CHOOSER_MENU_GROUP));
    mgr.appendToGroup(CHOOSER_MENU_GROUP, new ControlContribution("none") { //$NON-NLS-1$
        protected Control createControl(Composite parent) {
            configChooser = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);

            // update the chooser with the currently selected layer
            ///*from w  w  w.  j  a v  a 2  s  .  com*/
            updateChooser();

            configChooser.addSelectionListener(chooserListener);

            // setFocus();
            // updateChooser();
            /*
             * XXX Justin what are you doing?
             * PlatformUI.getWorkbench().getDisplay().asyncExec( new Runnable() { public
             * void run() { chooserListener.widgetSelected(null); } } );
             */
            return configChooser;
        }

        protected int computeWidth(Control control) {
            return 125;
        }
    });
    mgr.add(new GroupMarker(STYLE_MENU_GROUP));
    mgr.appendToGroup(STYLE_MENU_GROUP, new Separator());
    mgr.appendToGroup(STYLE_MENU_GROUP, applyAction);
    mgr.appendToGroup(STYLE_MENU_GROUP, cancelAction);

    mgr.add(new GroupMarker(CONFIG_MENU_GROUP));
    mgr.add(new Separator());
}

From source file:org.neo4j.neoclipse.view.NeoGraphMenu.java

License:Apache License

/**
 * Add layout actions to the menu and toolbar.
 * //w w  w .jav a2 s  . co  m
 * @param tm current tool bar manager
 * @param mm current menu manager
 */
private void contributeLayoutActions(final IToolBarManager tm, final IMenuManager mm) {
    {
        String groupName = "layout";
        GroupMarker layoutGroup = new GroupMarker(groupName);
        tm.add(layoutGroup);
        mm.add(layoutGroup);
        // spring layout
        ShowSpringLayoutAction springLayoutAction = new ShowSpringLayoutAction(graphView);
        tm.appendToGroup(groupName, springLayoutAction);
        mm.appendToGroup(groupName, springLayoutAction);
        // tree layout
        ShowTreeLayoutAction treeLayoutAction = new ShowTreeLayoutAction(graphView);
        tm.appendToGroup(groupName, treeLayoutAction);
        mm.appendToGroup(groupName, treeLayoutAction);
        // radial layout
        ShowRadialLayoutAction radialLayoutAction = new ShowRadialLayoutAction(graphView);
        tm.appendToGroup(groupName, radialLayoutAction);
        mm.appendToGroup(groupName, radialLayoutAction);
        // grid layout
        ShowGridLayoutAction gridLayoutAction = new ShowGridLayoutAction(graphView);
        tm.appendToGroup(groupName, gridLayoutAction);
        mm.appendToGroup(groupName, gridLayoutAction);
        // horizontal tree layout
        ShowHorizontalTreeLayoutAction horizontalTreeLayoutAction = new ShowHorizontalTreeLayoutAction(
                graphView);
        mm.appendToGroup(groupName, horizontalTreeLayoutAction);
        // horizontal shift layout
        ShowHorizontalShiftLayoutAction horizontalShiftLayoutAction = new ShowHorizontalShiftLayoutAction(
                graphView);
        mm.appendToGroup(groupName, horizontalShiftLayoutAction);
    }
}

From source file:org.neuro4j.studio.debug.ui.views.FlowLaunchView.java

License:Apache License

protected void configureToolBar(IToolBarManager tbm) {
    tbm.add(new Separator(IDebugUIConstants.THREAD_GROUP));
    tbm.add(new Separator(IDebugUIConstants.STEP_GROUP));
    tbm.add(new GroupMarker(IDebugUIConstants.STEP_INTO_GROUP));
    tbm.add(new GroupMarker(IDebugUIConstants.STEP_OVER_GROUP));
    tbm.add(new GroupMarker(IDebugUIConstants.STEP_RETURN_GROUP));
    tbm.add(new GroupMarker(IDebugUIConstants.EMPTY_STEP_GROUP));
    tbm.add(new Separator(IDebugUIConstants.RENDER_GROUP));

    tbm.appendToGroup(IDebugUIConstants.THREAD_GROUP, getAction(RESUME));
    tbm.appendToGroup(IDebugUIConstants.THREAD_GROUP, getAction(SUSPEND));
    tbm.appendToGroup(IDebugUIConstants.THREAD_GROUP, getAction(TERMINATE));
    tbm.appendToGroup(IDebugUIConstants.THREAD_GROUP, getAction(DISCONNECT));

    tbm.appendToGroup(IDebugUIConstants.STEP_INTO_GROUP, getAction(STEP_INTO));
    tbm.appendToGroup(IDebugUIConstants.STEP_OVER_GROUP, getAction(STEP_OVER));
    tbm.appendToGroup(IDebugUIConstants.STEP_RETURN_GROUP, getAction(STEP_RETURN));

    tbm.appendToGroup(IDebugUIConstants.EMPTY_STEP_GROUP, getAction(DROP_TO_FRAME));

    tbm.appendToGroup(IDebugUIConstants.RENDER_GROUP, getAction(TOGGLE_STEP_FILTERS));
}

From source file:org.openmaji.implementation.tool.eclipse.browser.patterns.common.ExplorerView.java

License:Open Source License

protected void fillActionBars(IToolBarManager toolBar) {
    super.fillActionBars(toolBar);
    GroupMarker viewGroup = new GroupMarker(VIEW_GROUP);
    toolBar.add(viewGroup);//from w w w. j  a  v a 2  s .  c  o m
    toolBar.appendToGroup(VIEW_GROUP, verticalOrientationAction);
    toolBar.appendToGroup(VIEW_GROUP, horizontalOrientationAction);
    toolBar.appendToGroup(VIEW_GROUP, contentViewOnlyAction);
    toolBar.add(new Separator());
    toolBar.add(hideInfoPaneAction);
}

From source file:org.overture.ide.debug.ui.ProcessConsolePageParticipant.java

License:Open Source License

/**
 * Contribute actions to the toolbar/*from w  w  w. j av a 2  s  . c  o  m*/
 */
protected void configureToolBar(IToolBarManager mgr) {
    mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fTerminate);
    // mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fRemoveTerminated);
    // mgr.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fRemoveAllTerminated);
    // mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fStdOut);
    // mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fStdErr);
}