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

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

Introduction

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

Prototype

IContributionItem[] getItems();

Source Link

Document

Returns all contribution items known to this manager.

Usage

From source file:au.gov.ansto.bragg.kowari.ui.views.KowariDataSourceView.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    defaultFolderName = System.getProperty("sics.data.path");
    try {/* www  .  ja  v a 2 s.co  m*/
        initListeners();
    } catch (Exception e) {
        LoggerFactory.getLogger(this.getClass()).error("can not read folder " + defaultFolderName, e);
    }
    IActionBars bars = getViewSite().getActionBars();
    final IMenuManager menuManager = bars.getMenuManager();
    final IToolBarManager toolBarManager = bars.getToolBarManager();
    menuManager.remove(findAction(menuManager.getItems(), "Combine Data"));
    toolBarManager.remove(findAction(toolBarManager.getItems(), "Combine Data"));
    menuManager.remove(findAction(menuManager.getItems(), "Select All"));
    toolBarManager.remove(findAction(toolBarManager.getItems(), "Select All"));
    menuManager.remove(findAction(menuManager.getItems(), "Deselect All"));
    toolBarManager.remove(findAction(toolBarManager.getItems(), "Deselect All"));
}

From source file:ca.mcgill.cs.swevo.qualyzer.editors.RTFEditor.java

License:Open Source License

@Override
protected void editorContextMenuAboutToShow(IMenuManager menu) {
    super.editorContextMenuAboutToShow(menu);

    menu.remove(ITextEditorActionConstants.GROUP_OPEN);
    menu.remove(ITextEditorActionConstants.GROUP_PRINT);
    menu.remove(ITextEditorActionConstants.GROUP_ADD);
    menu.remove(ITextEditorActionConstants.GROUP_REST);
    menu.remove(ITextEditorActionConstants.SHIFT_RIGHT);
    menu.remove(ITextEditorActionConstants.SHIFT_LEFT);
    menu.remove(ITextEditorActionConstants.GROUP_FIND);
    menu.remove(IWorkbenchActionConstants.MB_ADDITIONS);
    menu.remove(ITextEditorActionConstants.GROUP_SETTINGS);
    menu.remove(ITextEditorActionConstants.CONTEXT_PREFERENCES);

    for (IContributionItem item : menu.getItems()) {
        if (item.getId() == null) {
            menu.remove(item);//from   w w  w.j av a2s . c o m
        }
    }

    addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.BOLD_ACTION_ID);
    addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.ITALIC_ACTION_ID);
    addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.UNDERLINE_ACTION_ID);
    addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.FRAGMENT_ACTION_ID);

    if (isRemoveVisible()) {
        addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.VIEW_FRAGMENTS_ACTION_ID);
        addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.REMOVE_CODE_ACTION_ID);
        addAction(menu, ITextEditorActionConstants.GROUP_EDIT, RTFConstants.REMOVE_ALL_CODES_ACTION_ID);
    }

    //check according to selection
    fBoldAction.setChecked(isBoldChecked());
    fItalicAction.setChecked(isItalicChecked());
    fUnderlineAction.setChecked(isUnderlineChecked());
}

From source file:carisma.ui.eclipse.rcp.ApplicationWorkbenchWindowAdvisor.java

License:Open Source License

@Override
public final void postWindowOpen() {

    //   remove unused menus
    IMenuManager mm = getWindowConfigurer().getActionBarConfigurer().getMenuManager();
    IContributionItem[] mItems = mm.getItems();
    for (int i = 0; i < mItems.length; i++) {

        if (mItems[i].getId().equals("navigate") || mItems[i].getId().equals("additions")
                || mItems[i].getId().equals("org.eclipse.search.menu")
                || mItems[i].getId().equals("org.eclipse.ui.run")
                || mItems[i].getId().equals("org.eclipse.jdt.ui.refactoring.menu")
                || mItems[i].getId().equals("org.eclipse.jdt.ui.source.menu")) {
            mm.remove(mItems[i].getId());
            mm.update(true);// w w  w.j av  a 2s .c om
        }
    }
}

From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.OutlinePage.java

License:Open Source License

/**
 * This viewer uses its own actions that delegate to the ones given
 * by the {@link LayoutCanvas}. All the processing is actually handled
 * directly by the canvas and this viewer only gets refreshed as a
 * consequence of the canvas changing the XML model.
 *///from ww w.java 2s.  com
private void setupContextMenu() {

    mMenuManager = new MenuManager();
    mMenuManager.removeAll();

    mMenuManager.add(mMoveUpAction);
    mMenuManager.add(mMoveDownAction);
    mMenuManager.add(new Separator());

    mMenuManager.add(new SelectionManager.SelectionMenu(mGraphicalEditorPart));
    mMenuManager.add(new Separator());
    final String prefix = LayoutCanvas.PREFIX_CANVAS_ACTION;
    mMenuManager.add(new DelegateAction(prefix + ActionFactory.CUT.getId()));
    mMenuManager.add(new DelegateAction(prefix + ActionFactory.COPY.getId()));
    mMenuManager.add(new DelegateAction(prefix + ActionFactory.PASTE.getId()));

    mMenuManager.add(new Separator());

    mMenuManager.add(new DelegateAction(prefix + ActionFactory.DELETE.getId()));

    mMenuManager.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            // Update all actions to match their LayoutCanvas counterparts
            for (IContributionItem contrib : manager.getItems()) {
                if (contrib instanceof ActionContributionItem) {
                    IAction action = ((ActionContributionItem) contrib).getAction();
                    if (action instanceof DelegateAction) {
                        ((DelegateAction) action).updateFromEditorPart(mGraphicalEditorPart);
                    }
                }
            }
        }
    });

    new DynamicContextMenu(mGraphicalEditorPart.getEditorDelegate(), mGraphicalEditorPart.getCanvasControl(),
            mMenuManager);

    getTreeViewer().getTree().setMenu(mMenuManager.createContextMenu(getControl()));

    // Update Move Up/Move Down state only when the menu is opened
    getTreeViewer().getTree().addMenuDetectListener(new MenuDetectListener() {
        @Override
        public void menuDetected(MenuDetectEvent e) {
            mMenuManager.update(IAction.ENABLED);
        }
    });
}

From source file:com.aptana.ide.ui.io.navigator.actions.OpenActionProvider.java

License:Open Source License

private void addOpenWithMenu(IMenuManager menu) {
    IStructuredSelection selection = getSelection();
    if (selection == null || selection.size() != 1) {
        return;/*www  .  j a v a  2  s .co  m*/
    }

    Object element = selection.getFirstElement();
    if (!(element instanceof IAdaptable)) {
        return;
    }
    IMenuManager submenu = new MenuManager(Messages.OpenActionProvider_LBL_OpenWith,
            ICommonMenuConstants.GROUP_OPEN_WITH);
    submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
    submenu.add(new OpenWithMenu(fSite.getPage(), (IAdaptable) element, new Client() {

        public void openEditor(IFileStore file, IEditorDescriptor editorDescriptor) {
            EditorUtils.openFileInEditor(file, editorDescriptor);
        }
    }));
    submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_ADDITIONS));

    // adds the submenu
    if (submenu.getItems().length > 2 && submenu.isEnabled()) {
        menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN_WITH, submenu);
    }
}

From source file:com.arc.cdt.debug.seecode.internal.ui.MenuBarUpdateManager.java

License:Open Source License

/**
 * //from w w w  .  j  a va 2 s.  c o  m
 */
public MenuBarUpdateManager(IMenuManager menubar) {
    mMenuBar = menubar;
    IContributionItem[] items = menubar.getItems();
    if (items.length > 2) {
        mIdOfMenuToInsertBefore = items[items.length - 2].getId();
    }
}

From source file:com.architexa.diagrams.parts.NavAidsEditPolicy.java

License:Open Source License

protected IFigure getRelButton(IFigure contents, final ContextMenuProvider dropDownMenu, final String tooltip) {
    MenuButton btn = new MenuButton(contents, getHost().getViewer()) {
        @Override/*  ww w.  j  ava  2  s.  c  om*/
        public void buildMenu(final IMenuManager menu) {
            // if there is a menu and there is more than one option            
            if (dropDownMenu == null)
                return;
            dropDownMenu.buildContextMenu(menu);

            if (menu.getItems().length <= 2 || dropDownMenu.find(MoreButtonUtils.showAllId) != null)
                return;
            MoreButtonUtils.addShowAllItem(menu,
                    NavAidsEditPolicy.this.getArtifactSelectionHandlesHost().getRootController());
        }
    };
    return btn;

}

From source file:com.architexa.diagrams.parts.NavAidsSpec.java

License:Open Source License

public void createMenu(IMenuManager menuManager, Set<Artifact> showableSetModel, NavAidsEditPart aep,
        DirectedRel rel, BasicRootController rc) {

    IContributionItem[] contributions = menuManager.getItems();
    if (contributions.length > 0)
        menuManager.add(new Separator("header"));
    for (IContributionItem menuItem : contributions) {
        menuManager.add(menuItem);// ww w.j  a v a 2 s  .co m
    }
    menuManager.add(new Separator("main"));

    List<Artifact> listOrdered = new ArrayList<Artifact>(showableSetModel);
    sortArtifactListByName(listOrdered, aep);
    boolean createMultipleMenus = showableSetModel.size() > MAX_LENGTH ? true : false;
    List<Artifact> tempList = new ArrayList<Artifact>(listOrdered);
    Iterator<Artifact> itr = tempList.iterator();
    while (!listOrdered.isEmpty()) {
        String menuStrStart = aep.getRelModelLabel(listOrdered.get(0));
        MenuManager subMenu;

        if (createMultipleMenus) {
            subMenu = new MenuManager(menuStrStart + " - ...");
            subMenu.add(new Separator("main"));
            menuManager.add(subMenu);
        } else
            subMenu = (MenuManager) menuManager;

        int i = 0;
        while (i < MAX_LENGTH && itr.hasNext()) {
            Artifact relArt = itr.next();
            listOrdered.remove(relArt);

            String relArtLbl = aep.getRelModelLabel(relArt);
            IAction action = aep.getShowRelAction(rc, rel, relArt, relArtLbl);
            if (action == null)
                continue;
            try {
                ImageDescriptor des = rc.getIconDescriptor(aep, relArt);
                if (des != null)
                    action.setImageDescriptor(des);
            } catch (Throwable t) {
                NavAidsEditPolicy.logger.error("Unexpected error while getting icon for: " + relArt, t);
            }
            subMenu.appendToGroup("main", action);
            i++;
        }
    }
}

From source file:com.architexa.diagrams.relo.parts.MoreItemsEditPart.java

License:Open Source License

public void buildMoreMenu(IMenuManager menu, MenuButton button) {
    menu.add(new Separator("main"));
    buildMoreChildrenContextMenu(menu);/*from w  w w .  j a  v  a  2 s. c  o m*/
    if (menu.getItems().length <= 2)
        return;
    MoreButtonUtils.addShowAllItem(menu, getRootController());
}

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;
    if (fEditor != null) {
        String groupName = "SearchMessages.group_search";
        searchSubMenu = new MenuManager(groupName, ITextEditorActionConstants.GROUP_FIND);
        searchSubMenu.add(new GroupMarker(ITextEditorActionConstants.GROUP_FIND));
        // target = searchSubMenu;
    }/*  w w  w . j  a  v  a 2s.com*/

    // 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);
    }
}