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

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

Introduction

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

Prototype

@Override
    public void appendToGroup(String groupName, IAction action) 

Source Link

Usage

From source file:com.byterefinery.rmbench.export.ModelCompareEditor.java

License:Open Source License

private void createActions(CompareViewerPane lowerPane) {
    ToolBarManager toolbar = CompareViewerPane.getToolBarManager(lowerPane);

    final Action executeScriptAction = new ExecuteScriptAction(this);
    final Action executeStmtAction = new ExecuteStatementAction(this);

    dbmodelContribution = new ChooseDBModelContribution(databaseInfo);
    dbmodelContribution.addConnectionListener(new ChooseDBModelContribution.Listener() {
        public void dbModelSelected(DBModel dbmodel) {
            executeScriptAction.setEnabled(dbmodel != null);
            executeStmtAction.setEnabled(dbmodel != null);
        }//from  w ww  .j a va 2  s  .  c om
    });
    connectionListener = new ChooseDBModelContribution.EventManagerListener(toolbar);
    connectionListener.register();

    toolbar.add(new Separator(GROUP_EXEC));
    toolbar.appendToGroup(GROUP_EXEC, dbmodelContribution);
    toolbar.appendToGroup(GROUP_EXEC, executeScriptAction);
    toolbar.appendToGroup(GROUP_EXEC, executeStmtAction);
    toolbar.add(new Separator());
    toolbar.add(new EditorModeAction());
    toolbar.update(true);
}

From source file:com.ibm.etools.mft.samples.scribble.ScribblePublisher.java

License:Open Source License

public ScribblePublisher(Shell shell) {
    super(shell);

    ToolBarManager manager = getToolBarManager();

    manager.add(connectAction = new Action(getString("action.connect"),
            ImageDescriptor.createFromFile(getClass(), "broker_obj.gif")) {
        public void run() {
            connect(null);/*w  w  w. j a v a  2 s . c o m*/
        }
    });
    connectAction.setToolTipText(connectAction.getText());

    manager.add(clearAction = new Action(getString("action.clear"),
            ImageDescriptor.createFromFile(getClass(), "clear_co.gif")) {
        public void run() {
            stopDemo();
            clearAndPublish();
        }
    });
    clearAction.setToolTipText(clearAction.getText());

    manager.add(new Separator("demo"));
    manager.appendToGroup("demo", runDemoAction = new Action(getString("action.demo"),
            ImageDescriptor.createFromFile(getClass(), "resume_co.gif")) {
        public void run() {
            runDemo("torolab-house.bmp");
        }
    });
    runDemoAction.setToolTipText(runDemoAction.getText());
    manager.appendToGroup("demo", stopDemoAction = new Action(getString("action.stop"),
            ImageDescriptor.createFromFile(getClass(), "terminate_co.gif")) {
        public void run() {
            stopDemo();
        }
    });
    stopDemoAction.setToolTipText(stopDemoAction.getText());
    stopDemoAction.setEnabled(false);
}

From source file:com.imperial.fiksen.codesimilarity.compare.ParseTreeMergeViewer.java

License:Open Source License

protected void createToolItems(ToolBarManager tbm) {

    fHandlerService = CompareHandlerService.createFor(getCompareConfiguration().getContainer(),
            fLeft.getSourceViewer().getControl().getShell());

    final String ignoreAncestorActionKey = "action.IgnoreAncestor."; //$NON-NLS-1$
    Action ignoreAncestorAction = new Action() {
        public void run() {
            // First make sure the ancestor is hidden
            if (!isIgnoreAncestor())
                getCompareConfiguration().setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, Boolean.FALSE);
            // Then set the property to ignore the ancestor
            getCompareConfiguration().setProperty(ICompareUIConstants.PROP_IGNORE_ANCESTOR,
                    Boolean.valueOf(!isIgnoreAncestor()));
            Utilities.initToggleAction(this, getResourceBundle(), ignoreAncestorActionKey, isIgnoreAncestor());
        }//w  w w. j  ava 2 s .c om
    };
    ignoreAncestorAction.setChecked(isIgnoreAncestor());
    Utilities.initAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey);
    Utilities.initToggleAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey,
            isIgnoreAncestor());

    fIgnoreAncestorItem = new ActionContributionItem(ignoreAncestorAction);
    fIgnoreAncestorItem.setVisible(false);
    tbm.appendToGroup("modes", fIgnoreAncestorItem); //$NON-NLS-1$

    tbm.add(new Separator());

    Action a = new Action() {
        public void run() {
            if (navigate(true, false, false)) {
                endOfDocumentReached(true);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.NextDiff."); //$NON-NLS-1$
    fNextDiff = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fNextDiff); //$NON-NLS-1$
    // Don't register this action since it is probably registered by the
    // container

    a = new Action() {
        public void run() {
            if (navigate(false, false, false)) {
                endOfDocumentReached(false);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.PrevDiff."); //$NON-NLS-1$
    fPreviousDiff = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fPreviousDiff); //$NON-NLS-1$
    // Don't register this action since it is probably registered by the
    // container

    a = new Action() {
        public void run() {
            if (navigate(true, false, true)) {
                endOfDocumentReached(true);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.NextChange."); //$NON-NLS-1$
    fNextChange = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fNextChange); //$NON-NLS-1$
    fHandlerService.registerAction(a, "org.eclipse.compare.selectNextChange"); //$NON-NLS-1$

    a = new Action() {
        public void run() {
            if (navigate(false, false, true)) {
                endOfDocumentReached(false);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.PrevChange."); //$NON-NLS-1$
    fPreviousChange = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fPreviousChange); //$NON-NLS-1$
    fHandlerService.registerAction(a, "org.eclipse.compare.selectPreviousChange"); //$NON-NLS-1$

    CompareConfiguration cc = getCompareConfiguration();

    if (cc.isRightEditable()) {
        a = new Action() {
            public void run() {
                copyDiffLeftToRight();
            }
        };
        Utilities.initAction(a, getResourceBundle(), "action.CopyDiffLeftToRight."); //$NON-NLS-1$
        fCopyDiffLeftToRightItem = new ActionContributionItem(a);
        fCopyDiffLeftToRightItem.setVisible(true);
        tbm.appendToGroup("merge", fCopyDiffLeftToRightItem); //$NON-NLS-1$
        fHandlerService.registerAction(a, "org.eclipse.compare.copyLeftToRight"); //$NON-NLS-1$
    }

    if (cc.isLeftEditable()) {
        a = new Action() {
            public void run() {
                copyDiffRightToLeft();
            }
        };
        Utilities.initAction(a, getResourceBundle(), "action.CopyDiffRightToLeft."); //$NON-NLS-1$
        fCopyDiffRightToLeftItem = new ActionContributionItem(a);
        fCopyDiffRightToLeftItem.setVisible(true);
        tbm.appendToGroup("merge", fCopyDiffRightToLeftItem); //$NON-NLS-1$
        fHandlerService.registerAction(a, "org.eclipse.compare.copyRightToLeft"); //$NON-NLS-1$
    }

    fIgnoreWhitespace = ChangePropertyAction.createIgnoreWhiteSpaceAction(getResourceBundle(),
            getCompareConfiguration());
    fIgnoreWhitespace.setActionDefinitionId(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE);
    fLeft.addTextAction(fIgnoreWhitespace);
    fRight.addTextAction(fIgnoreWhitespace);
    fAncestor.addTextAction(fIgnoreWhitespace);
    fHandlerService.registerAction(fIgnoreWhitespace, fIgnoreWhitespace.getActionDefinitionId());

    boolean needsLeftPainter = !isEditorBacked(fLeft.getSourceViewer());
    boolean needsRightPainter = !isEditorBacked(fLeft.getSourceViewer());
    boolean needsAncestorPainter = !isEditorBacked(fAncestor.getSourceViewer());
    showWhitespaceAction = new ShowWhitespaceAction(new MergeSourceViewer[] { fLeft, fRight, fAncestor },
            new boolean[] { needsLeftPainter, needsRightPainter, needsAncestorPainter });
    fHandlerService.registerAction(showWhitespaceAction,
            ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);

    toggleLineNumbersAction = new TextEditorPropertyAction(CompareMessages.TextMergeViewer_16,
            new MergeSourceViewer[] { fLeft, fRight, fAncestor },
            AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
    fHandlerService.registerAction(toggleLineNumbersAction, ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE);
}

From source file:com.mentor.nucleus.bp.model.compare.contentmergeviewer.ModelContentMergeViewer.java

License:Open Source License

@Override
protected void createToolItems(ToolBarManager toolBarManager) {
    CompareConfiguration cc = getCompareConfiguration();

    if (cc.isRightEditable()) {
        final CopyDiffAction a = new CopyDiffAction(this, true);
        leftTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override//  w  w  w  .  ja v a  2 s  .  c  o  m
            public void selectionChanged(SelectionChangedEvent event) {
                boolean result = a.isEnabled();
                a.setEnabled(!result);
                a.setEnabled(result);
            }
        });
        rightTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                boolean result = a.isEnabled();
                a.setEnabled(!result);
                a.setEnabled(result);
            }
        });
        Utilities.initAction(a, getResourceBundle(), "action.CopyDiffLeftToRight."); //$NON-NLS-1$
        ActionContributionItem item = new ActionContributionItem(a);
        item.setVisible(true);
        toolBarManager.appendToGroup("merge", item); //$NON-NLS-1$
    }

    if (cc.isLeftEditable()) {
        final CopyDiffAction a = new CopyDiffAction(this, false);
        leftTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                boolean result = a.isEnabled();
                a.setEnabled(!result);
                a.setEnabled(result);
            }
        });
        rightTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                boolean result = a.isEnabled();
                a.setEnabled(!result);
                a.setEnabled(result);
            }
        });
        Utilities.initAction(a, getResourceBundle(), "action.CopyDiffRightToLeft."); //$NON-NLS-1$
        ActionContributionItem item = new ActionContributionItem(a);
        item.setVisible(true);
        toolBarManager.appendToGroup("merge", item); //$NON-NLS-1$
    }
    Action navigateDown = new NavigateDownAction(this);
    Utilities.initAction(navigateDown, getResourceBundle(), "action.NextDiff.");
    nextDifference = new ActionContributionItem(navigateDown);
    toolBarManager.appendToGroup("navigation", nextDifference); //$NON-NLS-1$
    Action navigateUp = new NavigateUpAction(this);
    Utilities.initAction(navigateUp, getResourceBundle(), "action.PrevDiff.");
    previousDifference = new ActionContributionItem(navigateUp);
    toolBarManager.appendToGroup("navigation", previousDifference); //$NON-NLS-1$
}

From source file:com.mindquarry.desktop.client.MindClient.java

License:Open Source License

protected ToolBarManager createToolBarManager(int style) {
    ToolBarManager manager = new ImageAndTextToolbarManager(style);

    // create toolbar groups
    manager.add(new GroupMarker(ActionBase.WORKSPACE_ACTION_GROUP));
    manager.add(new GroupMarker(ActionBase.TASK_ACTION_GROUP));
    manager.add(new GroupMarker(ActionBase.STOP_ACTION_GROUP));
    manager.add(new GroupMarker(ActionBase.WORKSPACE_OPEN_GROUP));
    manager.appendToGroup(ActionBase.WORKSPACE_OPEN_GROUP, new Separator());
    manager.add(new GroupMarker(ActionBase.MANAGEMENT_ACTION_GROUP));
    manager.appendToGroup(ActionBase.MANAGEMENT_ACTION_GROUP, new Separator());

    for (ActionBase action : actions) {
        if ((action.isToolbarAction()) && (INITIAL_TOOLBAR_GROUPS.contains(action.getGroup()))) {
            manager.appendToGroup(action.getGroup(), action);
            if (action.isEnabledByDefault()) {
                action.setEnabled(true);
            } else {
                action.setEnabled(false);
            }/*from w w w.j  a v a 2s.c o m*/
        }
    }
    return manager;
}

From source file:ext.org.eclipse.jdt.internal.ui.compare.JavaStructureDiffViewer.java

License:Open Source License

/**
 * Overriden to create a "smart" button in the viewer's pane control bar.
 * <p>/* ww  w  .ja  v a2 s. com*/
 * Clients can override this method and are free to decide whether they want to call
 * the inherited method.
 *
 * @param toolBarManager the toolbar manager for which to add the buttons
 */
@Override
protected void createToolItems(ToolBarManager toolBarManager) {

    super.createToolItems(toolBarManager);

    IAction a = new ChangePropertyAction(getBundle(), getCompareConfiguration(), "action.Smart.", SMART); //$NON-NLS-1$
    fSmartActionItem = new ActionContributionItem(a);
    fSmartActionItem.setVisible(fThreeWay);
    toolBarManager.appendToGroup("modes", fSmartActionItem); //$NON-NLS-1$
}

From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java

License:Open Source License

private void initializeToolbars(Composite parent) {
    ToolBarManager tbm = (ToolBarManager) getToolBarManager(parent);
    if (tbm != null) {
        tbm.removeAll();/*from ww w . ja  v  a2  s  .  c o m*/

        // define groups
        tbm.add(new Separator("modes")); //$NON-NLS-1$
        tbm.add(new Separator("merge")); //$NON-NLS-1$
        tbm.add(new Separator("navigation")); //$NON-NLS-1$

        CompareConfiguration cc = getCompareConfiguration();

        if (cc.isRightEditable()) {
            fCopyLeftToRightAction = new Action() {
                public void run() {
                    copy(true);
                }
            };
            Utilities.initAction(fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); //$NON-NLS-1$
            tbm.appendToGroup("merge", fCopyLeftToRightAction); //$NON-NLS-1$
            fHandlerService.registerAction(fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); //$NON-NLS-1$
        }

        if (cc.isLeftEditable()) {
            fCopyRightToLeftAction = new Action() {
                public void run() {
                    copy(false);
                }
            };
            Utilities.initAction(fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); //$NON-NLS-1$
            tbm.appendToGroup("merge", fCopyRightToLeftAction); //$NON-NLS-1$
            fHandlerService.registerAction(fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); //$NON-NLS-1$
        }

        final ChangePropertyAction a = new ChangePropertyAction(fBundle, getCompareConfiguration(),
                "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); //$NON-NLS-1$
        a.setChecked(fAncestorVisible);
        fAncestorItem = new ActionContributionItem(a);
        fAncestorItem.setVisible(false);
        tbm.appendToGroup("modes", fAncestorItem); //$NON-NLS-1$
        tbm.getControl().addDisposeListener(a);

        createToolItems(tbm);
        updateToolItems();

        tbm.update(true);
    }
}

From source file:org.eclipse.compare.codereview.compareEditor.RefacTextMergeViewer.java

License:Open Source License

protected void createToolItems(ToolBarManager tbm) {

    fHandlerService = CompareHandlerService.createFor(getCompareConfiguration().getContainer(),
            fLeft.getSourceViewer().getControl().getShell());

    final String ignoreAncestorActionKey = "action.IgnoreAncestor."; //$NON-NLS-1$
    Action ignoreAncestorAction = new Action() {
        public void run() {
            // First make sure the ancestor is hidden
            if (!isIgnoreAncestor())
                getCompareConfiguration().setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, Boolean.FALSE);
            // Then set the property to ignore the ancestor
            getCompareConfiguration().setProperty(ICompareUIConstants.PROP_IGNORE_ANCESTOR,
                    Boolean.valueOf(!isIgnoreAncestor()));
            Utilities.initToggleAction(this, getResourceBundle(), ignoreAncestorActionKey, isIgnoreAncestor());
        }// w w w  .j av a  2 s  .  co m
    };
    ignoreAncestorAction.setChecked(isIgnoreAncestor());
    Utilities.initAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey);
    Utilities.initToggleAction(ignoreAncestorAction, getResourceBundle(), ignoreAncestorActionKey,
            isIgnoreAncestor());

    fIgnoreAncestorItem = new ActionContributionItem(ignoreAncestorAction);
    fIgnoreAncestorItem.setVisible(false);
    tbm.appendToGroup("modes", fIgnoreAncestorItem); //$NON-NLS-1$

    tbm.add(new Separator());

    Action a = new Action() {
        public void run() {
            if (navigate(true, false, false)) {
                endOfDocumentReached(true);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.NextDiff."); //$NON-NLS-1$
    fNextDiff = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fNextDiff); //$NON-NLS-1$
    // Don't register this action since it is probably registered by the container

    a = new Action() {
        public void run() {
            if (navigate(false, false, false)) {
                endOfDocumentReached(false);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.PrevDiff."); //$NON-NLS-1$
    fPreviousDiff = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fPreviousDiff); //$NON-NLS-1$
    // Don't register this action since it is probably registered by the container

    a = new Action() {
        public void run() {
            if (navigate(true, false, true)) {
                endOfDocumentReached(true);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.NextChange."); //$NON-NLS-1$
    fNextChange = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fNextChange); //$NON-NLS-1$
    fHandlerService.registerAction(a, "org.eclipse.compare.selectNextChange"); //$NON-NLS-1$

    a = new Action() {
        public void run() {
            if (navigate(false, false, true)) {
                endOfDocumentReached(false);
            }
        }
    };
    Utilities.initAction(a, getResourceBundle(), "action.PrevChange."); //$NON-NLS-1$
    fPreviousChange = new ActionContributionItem(a);
    tbm.appendToGroup("navigation", fPreviousChange); //$NON-NLS-1$
    fHandlerService.registerAction(a, "org.eclipse.compare.selectPreviousChange"); //$NON-NLS-1$

    CompareConfiguration cc = getCompareConfiguration();

    if (cc.isRightEditable()) {
        a = new Action() {
            public void run() {
                copyDiffLeftToRight();
            }
        };
        Utilities.initAction(a, getResourceBundle(), "action.CopyDiffLeftToRight."); //$NON-NLS-1$
        fCopyDiffLeftToRightItem = new ActionContributionItem(a);
        fCopyDiffLeftToRightItem.setVisible(true);
        tbm.appendToGroup("merge", fCopyDiffLeftToRightItem); //$NON-NLS-1$
        fHandlerService.registerAction(a, "org.eclipse.compare.copyLeftToRight"); //$NON-NLS-1$
    }

    if (cc.isLeftEditable()) {
        a = new Action() {
            public void run() {
                copyDiffRightToLeft();
            }
        };
        Utilities.initAction(a, getResourceBundle(), "action.CopyDiffRightToLeft."); //$NON-NLS-1$
        fCopyDiffRightToLeftItem = new ActionContributionItem(a);
        fCopyDiffRightToLeftItem.setVisible(true);
        tbm.appendToGroup("merge", fCopyDiffRightToLeftItem); //$NON-NLS-1$
        fHandlerService.registerAction(a, "org.eclipse.compare.copyRightToLeft"); //$NON-NLS-1$
    }

    fIgnoreWhitespace = ChangePropertyAction.createIgnoreWhiteSpaceAction(getResourceBundle(),
            getCompareConfiguration());
    fIgnoreWhitespace.setActionDefinitionId(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE);
    fLeft.addTextAction(fIgnoreWhitespace);
    fRight.addTextAction(fIgnoreWhitespace);
    fAncestor.addTextAction(fIgnoreWhitespace);
    fHandlerService.registerAction(fIgnoreWhitespace, fIgnoreWhitespace.getActionDefinitionId());

    boolean needsLeftPainter = !isEditorBacked(fLeft.getSourceViewer());
    boolean needsRightPainter = !isEditorBacked(fLeft.getSourceViewer());
    boolean needsAncestorPainter = !isEditorBacked(fAncestor.getSourceViewer());
    showWhitespaceAction = new ShowWhitespaceAction(new MergeSourceViewer[] { fLeft, fRight, fAncestor },
            new boolean[] { needsLeftPainter, needsRightPainter, needsAncestorPainter });
    fHandlerService.registerAction(showWhitespaceAction,
            ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);

    toggleLineNumbersAction = new TextEditorPropertyAction(CompareMessages.TextMergeViewer_16,
            new MergeSourceViewer[] { fLeft, fRight, fAncestor },
            AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
    fHandlerService.registerAction(toggleLineNumbersAction, ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE);
}

From source file:org.eclipse.compare.examples.xml.XMLStructureViewer.java

License:Open Source License

/**
 * Overriden to create buttons in the viewer's pane control bar.
 * <p>//from ww w  .j  a va 2s  .  c  om
 *
 * @param toolBarManager the toolbar manager for which to add the buttons
 */
protected void createToolItems(ToolBarManager toolBarManager) {
    super.createToolItems(toolBarManager);
    toolBarManager.appendToGroup("modes", new ChooseMatcherDropDownAction(this)); //$NON-NLS-1$
    toolBarManager.appendToGroup("modes", new CreateNewIdMapAction(this)); //$NON-NLS-1$
}

From source file:org.eclipse.compare.internal.patch.PatchCompareEditorInput.java

License:Open Source License

public void contributeDiffViewerToolbarItems(Action[] actions, boolean workspacePatch) {
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(viewer.getControl().getParent());
    if (tbm != null) {
        tbm.removeAll();/*from   w  w  w.j av  a2  s  .c o  m*/

        tbm.add(new Separator("contributed")); //$NON-NLS-1$

        for (int i = 0; i < actions.length; i++) {
            tbm.appendToGroup("contributed", actions[i]); //$NON-NLS-1$
        }

        tbm.update(true);
    }
}