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.mylyn.internal.tasks.ui.editors.TaskEditorFindSupport.java

License:Open Source License

public void addFindAction(IToolBarManager toolBarManager) {
    if (toggleFindAction != null && toggleFindAction.isChecked()) {
        ControlContribution findTextboxControl = new ControlContribution(Messages.TaskEditorFindSupport_Find) {
            @Override//www .  j  av a  2s.  co  m
            protected Control createControl(Composite parent) {
                FormToolkit toolkit = taskEditorPage.getEditor().getHeaderForm().getToolkit();
                final Composite findComposite = toolkit.createComposite(parent);

                GridLayout findLayout = new GridLayout();
                findLayout.marginHeight = 4;
                findComposite.setLayout(findLayout);
                findComposite.setBackground(null);

                final Text findText = toolkit.createText(findComposite, "", SWT.FLAT); //$NON-NLS-1$
                findText.setLayoutData(new GridData(100, SWT.DEFAULT));
                findText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
                findText.setFocus();
                toolkit.adapt(findText, false, false);

                findText.addModifyListener(new ModifyListener() {
                    @Override
                    public void modifyText(ModifyEvent e) {
                        if (findText.getText().equals("")) { //$NON-NLS-1$
                            clearSearchResults();
                            findText.setBackground(null);
                        }
                    }
                });

                findText.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetDefaultSelected(SelectionEvent event) {
                        searchTaskEditor(findText);
                    }
                });
                toolkit.paintBordersFor(findComposite);
                return findComposite;
            }

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

    if (toggleFindAction == null) {
        toggleFindAction = new Action("", SWT.TOGGLE) { //$NON-NLS-1$
            @Override
            public void run() {
                if (!this.isChecked()) {
                    clearSearchResults();
                }
                taskEditorPage.getEditor().updateHeaderToolBar();
            }

        };
        toggleFindAction.setImageDescriptor(CommonImages.FIND);
        toggleFindAction.setToolTipText(Messages.TaskEditorFindSupport_Find);
    }
    toolBarManager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, toggleFindAction);
}

From source file:org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage.java

License:Open Source License

/**
 * Override for customizing the tool bar.
 *//*w  w  w .j  a va2  s  .co  m*/
@Override
public void fillToolBar(IToolBarManager toolBarManager) {
    final TaskRepository taskRepository = (model != null) ? getModel().getTaskRepository() : null;

    if (taskData == null) {
        synchronizeEditorAction = new SynchronizeEditorAction();
        synchronizeEditorAction.selectionChanged(new StructuredSelection(getTaskEditor()));
        toolBarManager.appendToGroup("repository", synchronizeEditorAction); //$NON-NLS-1$
    } else {
        if (taskData.isNew()) {
            DeleteTaskEditorAction deleteAction = new DeleteTaskEditorAction(getTask());
            deleteAction.setImageDescriptor(CommonImages.CLEAR);
            toolBarManager.appendToGroup("new", deleteAction); //$NON-NLS-1$
        } else if (taskRepository != null) {
            ClearOutgoingAction clearOutgoingAction = new ClearOutgoingAction(
                    Collections.singletonList((IRepositoryElement) task));
            (clearOutgoingAction).setTaskEditorPage(this);
            if (clearOutgoingAction.isEnabled()) {
                toolBarManager.appendToGroup("new", clearOutgoingAction); //$NON-NLS-1$
            }

            if (task.getSynchronizationState() != SynchronizationState.OUTGOING_NEW) {
                synchronizeEditorAction = new SynchronizeEditorAction();
                synchronizeEditorAction.selectionChanged(new StructuredSelection(getTaskEditor()));
                toolBarManager.appendToGroup("repository", synchronizeEditorAction); //$NON-NLS-1$
            }

            NewSubTaskAction newSubTaskAction = new NewSubTaskAction();
            newSubTaskAction.selectionChanged(newSubTaskAction, new StructuredSelection(task));
            if (newSubTaskAction.isEnabled()) {
                toolBarManager.appendToGroup("new", newSubTaskAction); //$NON-NLS-1$
            }

            AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin
                    .getConnectorUi(taskData.getConnectorKind());
            if (connectorUi != null) {
                final String historyUrl = connectorUi.getTaskHistoryUrl(taskRepository, task);
                if (historyUrl != null) {
                    final Action historyAction = new Action() {
                        @Override
                        public void run() {
                            TasksUiUtil.openUrl(historyUrl);
                        }
                    };

                    historyAction.setText(Messages.AbstractTaskEditorPage_History);
                    historyAction.setImageDescriptor(TasksUiImages.TASK_REPOSITORY_HISTORY);
                    historyAction.setToolTipText(Messages.AbstractTaskEditorPage_History);
                    if (getEditor().openWithBrowserAction != null) {
                        getEditor().openWithBrowserAction.setMenuCreator(new MenuCreator() {
                            @Override
                            protected void initialize(MenuManager menuManager) {
                                OpenWithBrowserAction openWithBrowserAction = new OpenWithBrowserAction();
                                openWithBrowserAction.selectionChanged(new StructuredSelection(task));
                                menuManager.add(openWithBrowserAction);
                                menuManager.add(new Separator());
                                menuManager.add(historyAction);
                            };
                        });
                    } else {
                        toolBarManager.prependToGroup("open", historyAction); //$NON-NLS-1$
                    }
                }
            }
        }
        if (needsSubmitButton()) {
            ToolBarButtonContribution submitButtonContribution = new ToolBarButtonContribution(
                    "org.eclipse.mylyn.tasks.toolbars.submit") { //$NON-NLS-1$
                @Override
                protected Control createButton(Composite composite) {
                    submitButton = new Button(composite, SWT.FLAT);
                    submitButton.setText(Messages.TaskEditorActionPart_Submit + " "); //$NON-NLS-1$
                    submitButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_SUBMIT));
                    submitButton.setBackground(null);
                    submitButton.addListener(SWT.Selection, new Listener() {
                        public void handleEvent(Event e) {
                            doSubmit();
                        }
                    });
                    return submitButton;
                }
            };
            submitButtonContribution.marginLeft = 10;
            toolBarManager.add(submitButtonContribution);
        }
        if (findSupport != null) {
            findSupport.addFindAction(toolBarManager);
        }
    }
}

From source file:org.eclipse.ocl.examples.interpreter.console.OCLConsolePage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    // force left-to-right text direction in the console, because it
    //    works with OCL text and the OCL language is based on English
    page = new SashForm(parent, SWT.VERTICAL | SWT.LEFT_TO_RIGHT);

    output = new TextViewer(page, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    output.getTextWidget().setLayoutData(new GridData(GridData.FILL_BOTH));
    output.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    output.setEditable(false);//from   www .j  ava 2s  . com
    output.setDocument(new Document());

    colorManager = new ColorManager();
    document = new OCLDocument();
    document.setOCLFactory(oclFactory);
    document.setModelingLevel(modelingLevel);

    input = new OCLSourceViewer(page, colorManager, SWT.BORDER | SWT.MULTI);
    input.setDocument(document);
    input.getTextWidget().addKeyListener(new InputKeyListener());

    selectionListener = new ISelectionListener() {
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            OCLConsolePage.this.selectionChanged(selection);
        }
    };
    selectionService = getSite().getWorkbenchWindow().getSelectionService();
    selectionService.addPostSelectionListener(selectionListener);

    // get current selection
    ISelection selection = selectionService.getSelection();
    if (selection == null) {
        selection = getActiveSelection();
    }
    selectionChanged(selection);

    ((SashForm) page).setWeights(new int[] { 2, 1 });

    ClearOutputAction clear = new ClearOutputAction(output);
    CloseAction close = new CloseAction();
    SaveAction save = new SaveAction();
    LoadAction load = new LoadAction();

    IMenuManager menu = getSite().getActionBars().getMenuManager();
    menu.add(load);
    menu.add(save);
    menu.add(clear);
    menu.add(close);

    IMenuManager metamodelMenu = new MenuManager(OCLInterpreterMessages.console_metamodelMenu,
            "org.eclipse.ocl.examples.interpreter.metamodel"); //$NON-NLS-1$
    menu.add(metamodelMenu);
    DropDownAction metamodelAction = new DropDownAction();
    metamodelAction.setToolTipText(OCLInterpreterMessages.console_metamodelTip);
    addMetamodelActions(metamodelMenu, metamodelAction);

    IMenuManager levelMenu = new MenuManager(OCLInterpreterMessages.console_modelingLevel);
    menu.add(levelMenu);
    DropDownAction levelAction = new DropDownAction();
    levelAction.setToolTipText(OCLInterpreterMessages.console_modelingLevelTip);
    IAction m2 = new ModelingLevelAction(ModelingLevel.M2);
    m2.setChecked(true);
    levelMenu.add(m2);
    levelAction.addAction(m2);
    IAction m1 = new ModelingLevelAction(ModelingLevel.M1);
    levelMenu.add(m1);
    levelAction.addAction(m1);

    ActionContributionItem metamodelItem = new ActionContributionItem(metamodelAction);
    metamodelItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);

    IToolBarManager toolbar = getSite().getActionBars().getToolBarManager();
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, metamodelItem);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, levelAction);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, load);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, save);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, clear);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, close);
}

From source file:org.eclipse.ocl.examples.xtext.console.OCLConsolePage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    // force left-to-right text direction in the console, because it
    //    works with OCL text and the OCL language is based on English
    page = new SashForm(parent, SWT.VERTICAL | SWT.LEFT_TO_RIGHT);

    output = new TextViewer(page, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    output.getTextWidget().setLayoutData(new GridData(GridData.FILL_BOTH));
    output.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    output.setEditable(false);/*from w ww.  ja  v a 2s.c om*/
    output.setDocument(new Document());

    colorManager = new ColorManager();
    //      document.setOCLFactory(oclFactory);
    //      document.setModelingLevel(modelingLevel);

    createEditor(page);
    input = editor.getViewer();
    input.getTextWidget().addKeyListener(new InputKeyListener());
    input.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));

    selectionListener = new ISelectionListener() {
        public void selectionChanged(IWorkbenchPart part, final ISelection selection) {
            //            System.out.println("selectionChanged: ");
            if (part instanceof IConsoleView) {
                IConsole console = ((IConsoleView) part).getConsole();
                if (console instanceof OCLConsole) {
                    return;
                }
            }
            if (part instanceof ContentOutline) {
                ContentOutline contentOutline = (ContentOutline) part;
                IPage currentPage = contentOutline.getCurrentPage();
                if (currentPage instanceof OutlinePage) {
                    OutlinePage outlinePage = (OutlinePage) currentPage;
                    IXtextDocument xtextDocument = outlinePage.getXtextDocument();
                    Element pivotElement = xtextDocument.readOnly(new IUnitOfWork<Element, XtextResource>() {
                        public Element exec(XtextResource state) throws Exception {
                            if (selection instanceof IStructuredSelection) {
                                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                                if (structuredSelection.size() == 1) {
                                    Object selectedObject = structuredSelection.getFirstElement();
                                    if (selectedObject instanceof EObjectNode) {
                                        EObjectNode eObjectNode = (EObjectNode) selectedObject;
                                        URI uri = eObjectNode.getEObjectURI();
                                        EObject csObject = state.getEObject(uri.fragment());
                                        if (csObject instanceof Pivotable) {
                                            Element pivotObject = ((Pivotable) csObject).getPivot();
                                            if (pivotObject != null) {
                                                return pivotObject;
                                            }
                                        }
                                    }
                                }
                            }
                            return null;
                        }
                    });
                    if (pivotElement != null) {
                        OCLConsolePage.this.selectionChanged(new StructuredSelection(pivotElement));
                        return;
                    }
                }
            }
            OCLConsolePage.this.selectionChanged(selection);
        }
    };
    selectionService = getSite().getWorkbenchWindow().getSelectionService();
    selectionService.addPostSelectionListener(selectionListener);

    // get current selection
    //      ISelection selection = selectionService.getSelection();         // Doesn't have a value preceding console start
    ISelection selection = BaseUIUtil.getActiveSelection(getSite());
    selectionChanged(selection);

    ((SashForm) page).setWeights(new int[] { 2, 1 });

    ClearOutputAction clear = new ClearOutputAction(output);
    CloseAction close = new CloseAction();
    SaveExpressionAction saveExpression = new SaveExpressionAction(this);
    LoadExpressionAction loadExpression = new LoadExpressionAction(this);

    IMenuManager menu = getSite().getActionBars().getMenuManager();
    menu.add(loadExpression);
    menu.add(saveExpression);
    menu.add(clear);
    menu.add(close);

    //      IMenuManager metamodelMenu = new MenuManager(
    //          OCLInterpreterMessages.console_metamodelMenu,
    //          "org.eclipse.ocl.examples.xtext.console.metamodel"); //$NON-NLS-1$
    //      menu.add(metamodelMenu);
    //      DropDownAction metamodelAction = new DropDownAction();
    //      metamodelAction.setToolTipText(OCLInterpreterMessages.console_metamodelTip);
    //      addMetamodelActions(metamodelMenu, metamodelAction);

    //      IMenuManager levelMenu = new MenuManager(OCLInterpreterMessages.console_modelingLevel);
    //      menu.add(levelMenu);
    //        DropDownAction levelAction = new DropDownAction();
    //        levelAction.setToolTipText(OCLInterpreterMessages.console_modelingLevelTip);
    //      IAction m2 = new ModelingLevelAction(ModelingLevel.M2);
    //      m2.setChecked(true);
    //      levelMenu.add(m2);
    //      levelAction.addAction(m2);
    //      IAction m1 = new ModelingLevelAction(ModelingLevel.M1);
    //      levelMenu.add(m1);
    //      levelAction.addAction(m1);

    //      ActionContributionItem metamodelItem = new ActionContributionItem(
    //          metamodelAction);
    //      metamodelItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);

    IToolBarManager toolbar = getSite().getActionBars().getToolBarManager();
    //        toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, metamodelItem);
    //        toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, levelAction);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, loadExpression);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, saveExpression);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, clear);
    toolbar.appendToGroup(IConsoleConstants.OUTPUT_GROUP, close);
}

From source file:org.eclipse.php.composer.ui.console.TerminalConsolePage.java

License:Open Source License

@Override
public void init(IPageSite pageSite) {
    super.init(pageSite);
    IToolBarManager toolBarManager = pageSite.getActionBars().getToolBarManager();
    toolBarManager.insertBefore(IConsoleConstants.OUTPUT_GROUP, new GroupMarker(TOOLBAR_GROUP_ID));
    toolBarManager.appendToGroup(TOOLBAR_GROUP_ID, stopAction);
    toolBarManager.appendToGroup(TOOLBAR_GROUP_ID, removeInactiveAction);
}

From source file:org.eclipse.ptp.debug.internal.ui.views.array.ArrayView.java

License:Open Source License

protected void configureToolBar(IToolBarManager toolBarMgr) {
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.IUITABVARIABLEGROUP, new AddVariableAction(this));
}

From source file:org.eclipse.ptp.debug.internal.ui.views.variable.PVariableView.java

License:Open Source License

protected void configureToolBar(IToolBarManager toolBarMgr) {
    toolBarMgr.add(new Separator(IPTPDebugUIConstants.VAR_GROUP));

    toolBarMgr.appendToGroup(IPTPDebugUIConstants.VAR_GROUP, getAction(AddPExpressionAction.name));
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.VAR_GROUP, getAction(EditPExpressionAction.name));
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.VAR_GROUP, getAction(DeletePExpressionAction.name));
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.VAR_GROUP, getAction(UpdatePExpressionAction.name));
    toolBarMgr.add(new Separator());
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.VAR_GROUP, getAction(CompareValueAction.name));
}

From source file:org.eclipse.ptp.debug.ui.views.ParallelDebugView.java

License:Open Source License

@Override
protected void createToolBarActions(IToolBarManager toolBarMgr) {
    resumeAction = new ResumeAction(this);
    suspendAction = new SuspendAction(this);
    terminateAction = new TerminateAction(this);
    stepIntoAction = new StepIntoAction(this);
    stepOverAction = new StepOverAction(this);
    stepReturnAction = new StepReturnAction(this);
    registerAction = new RegisterAction(this);
    unregisterAction = new UnregisterAction(this);

    toolBarMgr.appendToGroup(IPTPDebugUIConstants.THREAD_GROUP, resumeAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.THREAD_GROUP, suspendAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.THREAD_GROUP, terminateAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.STEP_INTO_GROUP, stepIntoAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.STEP_OVER_GROUP, stepOverAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.STEP_RETURN_GROUP, stepReturnAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.REG_GROUP, registerAction);
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.REG_GROUP, unregisterAction);

    super.buildInToolBarActions(toolBarMgr);
    // createOrientationActions();
}

From source file:org.eclipse.ptp.internal.debug.ui.views.array.ArrayView.java

License:Open Source License

@Override
protected void configureToolBar(IToolBarManager toolBarMgr) {
    toolBarMgr.appendToGroup(IPTPDebugUIConstants.IUITABVARIABLEGROUP, new AddVariableAction(this));
}

From source file:org.eclipse.ptp.internal.ui.views.AbstractParallelSetView.java

License:Open Source License

/**
 * Build-in Toolbar actions/*from   w  ww.  ja  v  a2 s  .  co m*/
 * 
 * @param toolBarMgr
 */
protected void buildInToolBarActions(IToolBarManager toolBarMgr) {
    zoomOutAction = new ZoomOutAction(this);
    zoomInAction = new ZoomInAction(this);
    createSetAction = new CreateSetAction(this);
    deleteSetAction = new DeleteSetAction(this);
    deleteProcessAction = new RemoveElementAction(this);
    changeSetAction = new ChangeSetAction(this);

    toolBarMgr.appendToGroup(IPTPUIConstants.IUIZOOMGROUP, zoomOutAction);
    toolBarMgr.appendToGroup(IPTPUIConstants.IUIZOOMGROUP, zoomInAction);
    toolBarMgr.appendToGroup(IPTPUIConstants.IUISETGROUP, createSetAction);
    toolBarMgr.appendToGroup(IPTPUIConstants.IUISETGROUP, deleteSetAction);
    toolBarMgr.appendToGroup(IPTPUIConstants.IUISETGROUP, deleteProcessAction);
    toolBarMgr.appendToGroup(IPTPUIConstants.IUICHANGESETGROUP, changeSetAction);
}