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

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

Introduction

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

Prototype

IContributionItem find(String id);

Source Link

Document

Finds the contribution item with the given id.

Usage

From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsDiagramActionBarContributor.java

License:Open Source License

/**
 * @generated//from ww  w .j a v a  2 s.  c o m
 */
public void init(IActionBars bars, IWorkbenchPage page) {
    super.init(bars, page);
    // print preview
    IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_FILE);
    assert fileMenu != null;
    IAction printPreviewAction = new RenderedPrintPreviewAction(new EnhancedPrintActionHelper());
    fileMenu.insertBefore("print", printPreviewAction); //$NON-NLS-1$
    IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    assert editMenu != null;
    if (editMenu.find("validationGroup") == null) { //$NON-NLS-1$
        editMenu.add(new GroupMarker("validationGroup")); //$NON-NLS-1$
    }
    IAction validateAction = new ValidateAction(page);
    editMenu.appendToGroup("validationGroup", validateAction); //$NON-NLS-1$
}

From source file:ac.soton.fmusim.components.diagram.part.ComponentsDiagramActionBarContributor.java

License:Open Source License

/**
 * @generated//  w  ww  . j a  v a 2 s .c  o  m
 */
public void init(IActionBars bars, IWorkbenchPage page) {
    super.init(bars, page);
    // print preview
    IMenuManager fileMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_FILE);
    assert fileMenu != null;
    fileMenu.remove("pageSetupAction"); //$NON-NLS-1$
    IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    assert editMenu != null;
    if (editMenu.find("validationGroup") == null) { //$NON-NLS-1$
        editMenu.add(new GroupMarker("validationGroup")); //$NON-NLS-1$
    }
    IAction validateAction = new ValidateAction(page);
    editMenu.appendToGroup("validationGroup", validateAction); //$NON-NLS-1$
}

From source file:com.aptana.ide.search.AptanaFileSearchPage.java

License:Open Source License

/**
 * ovverriden to make it working for matching layout
 * @see org.eclipse.search.internal.ui.text.FileSearchPage#fillContextMenu(org.eclipse.jface.action.IMenuManager)
 *//* w  w w.  j av a  2s . c  o m*/
protected void fillContextMenu(IMenuManager mgr) {
    try {
        super.fillContextMenu(mgr);
        Separator find = (Separator) mgr.find(IContextMenuConstants.GROUP_REORGANIZE);
        IContributionItem[] items = find.getParent().getItems();
        int indexOf = Arrays.asList(items).indexOf(find);
        mgr.remove(items[indexOf + 1]);
        mgr.remove(items[indexOf + 2]);
        doAdd(mgr);
    } catch (ClassCastException e) {
        // should be here if our layout is active
        doAdd(mgr);

    }
    if (this.layout == AptanaFileSearchPage.LAYOUT_MATCHES) {
        Separator find = (Separator) mgr.find(IContextMenuConstants.GROUP_VIEWER_SETUP);
        IContributionItem[] items = find.getParent().getItems();
        int indexOf = Arrays.asList(items).indexOf(find);
        MenuManager contributionItem = (MenuManager) items[indexOf + 1];
        IContributionItem[] items2 = contributionItem.getItems();
        ActionContributionItem it0 = (ActionContributionItem) items2[0];
        ActionContributionItem it1 = (ActionContributionItem) items2[1];
        it0.getAction().setChecked(this.fOrder == AptanaFileSearchPage.SHOW_LABEL_PATH);
        it1.getAction().setChecked(this.fOrder == AptanaFileSearchPage.SHOW_PATH_LABEL);
    }
}

From source file:com.aptana.ide.search.ui.filesystem.AptanaFileSystemSearchPage.java

License:Open Source License

/**
 * @see org.eclipse.search.internal.ui.text.FileSearchPage#fillContextMenu(org.eclipse.jface.action.IMenuManager)
 *///  w  w w .ja va  2s . c  o m
protected void fillContextMenu(IMenuManager mgr) {
    super.fillContextMenu(mgr);

    // should be here if our layout is active
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
    if (!selection.isEmpty()) {
        FileSystemReplaceAction replaceSelection = new FileSystemReplaceAction(getSite().getShell(),
                (FileSystemSearchResult) getInput(), selection.toArray(), true);
        replaceSelection.setText(SearchMessages.ReplaceAction_label_selected);
        mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceSelection);
    }
    FileSystemReplaceAction replaceAll = new FileSystemReplaceAction(getSite().getShell(),
            (FileSystemSearchResult) getInput(), null, true);
    replaceAll.setText(SearchMessages.ReplaceAction_label_all);
    mgr.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, replaceAll);

    if (this.layout == AptanaFileSystemSearchPage.LAYOUT_MATCHES) {
        Separator find = (Separator) mgr.find(IContextMenuConstants.GROUP_VIEWER_SETUP);
        IContributionItem[] items = find.getParent().getItems();
        int indexOf = Arrays.asList(items).indexOf(find);
        MenuManager contributionItem = (MenuManager) items[indexOf + 1];
        IContributionItem[] items2 = contributionItem.getItems();
        ActionContributionItem it0 = (ActionContributionItem) items2[0];
        ActionContributionItem it1 = (ActionContributionItem) items2[1];
        it0.getAction().setChecked(fOrder == AptanaFileSystemSearchPage.SHOW_LABEL_PATH);
        it1.getAction().setChecked(fOrder == AptanaFileSystemSearchPage.SHOW_PATH_LABEL);
    }
}

From source file:com.archimatetool.editor.diagram.AbstractDiagramEditorActionBarContributor.java

License:Open Source License

protected IMenuManager contributeToFileMenu(IMenuManager menuManager) {
    IMenuManager fileMenu = (IMenuManager) menuManager.find(IWorkbenchActionConstants.M_FILE);

    // Export menu items
    IMenuManager exportMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_FILE + "/export_menu"); //$NON-NLS-1$
    exportMenu.add(getAction(ExportAsImageAction.ID));
    exportMenu.add(getAction(ExportAsImageToClipboardAction.ID));

    return fileMenu;
}

From source file:com.archimatetool.editor.diagram.AbstractDiagramEditorActionBarContributor.java

License:Open Source License

protected IMenuManager contributeToEditMenu(IMenuManager menuManager) {
    IMenuManager editMenu = (IMenuManager) menuManager.find(IWorkbenchActionConstants.M_EDIT);
    editMenu.insertAfter(ArchimateEditorActionFactory.RENAME.getId(), new Separator(GROUP_EDIT_MENU));

    // Fill Color Action
    editMenu.appendToGroup(GROUP_EDIT_MENU, getAction(FillColorAction.ID));

    // Connection Line Width and Color
    editMenu.appendToGroup(GROUP_EDIT_MENU, getAction(ConnectionLineWidthAction.ID));
    editMenu.appendToGroup(GROUP_EDIT_MENU, getAction(LineColorAction.ID));

    // Font/* w  ww.  j av  a  2 s.c om*/
    editMenu.appendToGroup(GROUP_EDIT_MENU, getAction(FontAction.ID));
    editMenu.appendToGroup(GROUP_EDIT_MENU, getAction(FontColorAction.ID));

    // Text Alignment
    IMenuManager textAlignmentMenu = new MenuManager(Messages.AbstractDiagramEditorActionBarContributor_8);
    textAlignmentMenu.add(getAction(TextAlignmentAction.ACTION_LEFT_ID));
    textAlignmentMenu.add(getAction(TextAlignmentAction.ACTION_CENTER_ID));
    textAlignmentMenu.add(getAction(TextAlignmentAction.ACTION_RIGHT_ID));
    editMenu.appendToGroup(GROUP_EDIT_MENU, textAlignmentMenu);

    return editMenu;
}

From source file:com.dubture.twig.ui.actions.TwigRefactorActionGroup.java

License:Open Source License

@Override
public void fillContextMenu(IMenuManager menu) {

    // super.fillContextMenu(menu);

    // IMenuManager target = menu;
    IMenuManager searchSubMenu = null;//ww w  .j av a2s.co m
    if (fEditor != null) {
        String groupName = "SearchMessages.group_search";
        searchSubMenu = new MenuManager(groupName, ITextEditorActionConstants.GROUP_FIND);
        searchSubMenu.add(new GroupMarker(ITextEditorActionConstants.GROUP_FIND));
        // target = searchSubMenu;
    }

    // if (searchSubMenu != null) {
    // fOccurrencesGroup.fillContextMenu(target);
    // searchSubMenu.add(new Separator());
    // }

    // no other way to find out if we have added items.
    if (searchSubMenu != null && searchSubMenu.getItems().length > 2) {
        menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, searchSubMenu);
    }

    IContributionItem item = menu.find(IContextMenuConstants.GROUP_ADDITIONS);
    if (item != null) {
        menu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, surroundAction);
    }
}

From source file:com.google.dart.tools.ui.actions.MemberFilterActionGroup.java

License:Open Source License

/**
 * Adds the filter actions to the given menu manager.
 * // w  ww .j a  v a 2 s .c o m
 * @param menu the menu manager to which the actions are added
 */
public void contributeToViewMenu(IMenuManager menu) {
    if (!fInViewMenu) {
        return;
    }
    final String filters = "filters"; //$NON-NLS-1$
    if (menu.find(filters) != null) {
        for (int i = 0; i < fFilterActions.length; i++) {
            menu.prependToGroup(filters, fFilterActions[i]);
        }
    } else {
        for (int i = 0; i < fFilterActions.length; i++) {
            menu.add(fFilterActions[i]);
        }
    }
}

From source file:com.isb.datamodeler.internal.ui.views.actions.workingset.DataModelerWorkingSetFilterActionGroup.java

License:Open Source License

public void fillActionBars(IActionBars actionBars) {
    IMenuManager menuManager = actionBars.getMenuManager();

    if (menuManager.find(IWorkbenchActionConstants.MB_ADDITIONS) != null)
        menuManager.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS,
                new Separator(WORKING_SET_ACTION_GROUP));
    else//  ww  w. j  a va  2  s  .c  om
        menuManager.add(new Separator(WORKING_SET_ACTION_GROUP));

    menuManager.appendToGroup(WORKING_SET_ACTION_GROUP, selectWorkingSetAction);
    menuManager.appendToGroup(WORKING_SET_ACTION_GROUP, clearWorkingSetAction);
    menuManager.appendToGroup(WORKING_SET_ACTION_GROUP, editWorkingSetAction);
    menuManager.appendToGroup(WORKING_SET_ACTION_GROUP, new Separator(START_SEPARATOR_ID));
    menuManager.appendToGroup(WORKING_SET_ACTION_GROUP, mruList);
    menuManager.appendToGroup(WORKING_SET_ACTION_GROUP, new Separator(SEPARATOR_ID));
}

From source file:com.microsoft.tfs.client.common.ui.views.AbstractCheckinControlView.java

License:Open Source License

private void addAdditionsGroupToContextMenu(final MenuManager contextMenu) {
    contextMenu.addMenuListener(new IMenuListener() {
        @Override/*from w  ww. j  a  v  a  2s . co m*/
        public void menuAboutToShow(final IMenuManager manager) {
            if (manager.find(IWorkbenchActionConstants.MB_ADDITIONS) != null) {
                return;
            }

            final String groupId = StandardActionConstants.HOSTING_CONTROL_CONTRIBUTIONS;

            manager.appendToGroup(groupId, new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
        }
    });
}