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

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

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Returns whether this manager has any contribution items.

Usage

From source file:com.android.menubar.MenuBarEnhancer.java

License:Open Source License

public static IMenuBarEnhancer setupMenuManager(String appName, Display display, final IMenuManager menuManager,
        final IAction aboutAction, final IAction preferencesAction, final IAction quitAction) {

    IMenuBarCallback callbacks = new IMenuBarCallback() {
        @Override/*  w  w w  .j a  v  a  2s . c o  m*/
        public void printError(String format, Object... args) {
            System.err.println(String.format(format, args));
        }

        @Override
        public void onPreferencesMenuSelected() {
            if (preferencesAction != null) {
                preferencesAction.run();
            }
        }

        @Override
        public void onAboutMenuSelected() {
            if (aboutAction != null) {
                aboutAction.run();
            }
        }
    };

    IMenuBarEnhancer enhancer = getEnhancer(callbacks, display);

    // Default implementation for generic platforms
    if (enhancer == null) {
        enhancer = new IMenuBarEnhancer() {

            @Override
            public MenuBarMode getMenuBarMode() {
                return MenuBarMode.GENERIC;
            }

            @Override
            public void setupMenu(String appName, Display display, final IMenuBarCallback callbacks) {
                if (!menuManager.isEmpty()) {
                    menuManager.add(new Separator());
                }

                if (aboutAction != null) {
                    menuManager.add(aboutAction);
                }
                if (preferencesAction != null) {
                    menuManager.add(preferencesAction);
                }
                if (quitAction != null) {
                    if (aboutAction != null || preferencesAction != null) {
                        menuManager.add(new Separator());
                    }
                    menuManager.add(quitAction);
                }
            }
        };
    }

    enhancer.setupMenu(appName, display, callbacks);
    return enhancer;
}

From source file:com.google.dart.tools.ui.callhierarchy.SearchScopeActionGroup.java

License:Open Source License

protected void fillSearchActions(IMenuManager searchMM) {
    Action[] actions = getActions();

    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];

        if (action.isEnabled()) {
            searchMM.add(action);//w w w . j  a va2s  .c om
        }
    }

    searchMM.setVisible(!searchMM.isEmpty());
}

From source file:com.google.dart.tools.ui.DartToolsPlugin.java

License:Open Source License

/**
 * Creates the Java plug-in's standard groups for view context menus.
 * /*from   ww w  .ja  va 2 s . com*/
 * @param menu the menu manager to be populated
 */
public static void createStandardGroups(IMenuManager menu) {
    if (!menu.isEmpty()) {
        return;
    }

    menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
    menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
    menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
    menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
    menu.add(new Separator(IContextMenuConstants.GROUP_EDIT));
    menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
    menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
    menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
    menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
    menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
    menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
    menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
}

From source file:com.iw.plugins.spindle.editors.template.TemplateEditor.java

License:Mozilla Public License

protected void editorContextMenuAboutToShow(IMenuManager menu) {
    super.editorContextMenuAboutToShow(menu);
    if (getStorage(getEditorInput()) instanceof IFile) {
        addAction(menu, NAV_GROUP, OpenDeclarationAction.ACTION_ID);
        addAction(menu, NAV_GROUP, ShowInPackageExplorerAction.ACTION_ID);
    }/*w ww .  j  a  va  2s . c o  m*/
    IMenuManager moreNav = new MenuManager("Jump");
    for (int i = 0; i < fJumpActions.length; i++) {
        fJumpActions[i].editorContextMenuAboutToShow(moreNav);
    }
    if (!moreNav.isEmpty())
        menu.appendToGroup(NAV_GROUP, moreNav);

    // menu.insertBefore(ITextEditorActionConstants.GROUP_SAVE, new
    // GroupMarker(HTML_GROUP));
    // MenuManager templateMenu = new MenuManager("Template");
    // templateMenu.add(getAction(SAVE_HTML_TEMPLATE));
    // templateMenu.add(getAction(REVERT_HTML_TEMPLATE));
    // menu.appendToGroup(HTML_GROUP, templateMenu);
    // addAction(menu, HTML_GROUP, SAVE_HTML_TEMPLATE);
    // addAction(menu, HTML_GROUP, REVERT_HTML_TEMPLATE);

    MenuManager sourceMenu = new MenuManager("Refactor");
    MoveToSpecAction moveAction = (MoveToSpecAction) getAction(MoveToSpecAction.ACTION_ID);
    moveAction.setEnabled(moveAction.canProceed());
    sourceMenu.add(moveAction);
    menu.appendToGroup(SOURCE_GROUP, sourceMenu);
}

From source file:com.nokia.carbide.search.system.internal.ui.SearchPlugin.java

License:Open Source License

/**
 * Creates the Search plugin standard groups in a context menu.
 * @param menu the menu to create in/* w  w w.j a v a 2  s .c  o m*/
 */
public static void createStandardGroups(IMenuManager menu) {
    if (!menu.isEmpty())
        return;
    menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
    menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
    menu.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN));
    menu.add(new Separator(IContextMenuConstants.GROUP_SHOW));
    menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
    menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
    menu.add(new Separator(IContextMenuConstants.GROUP_REMOVE_MATCHES));
    menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE));
    menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
    menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
    menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
    menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
}

From source file:ext.org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.java

License:Open Source License

protected void fillSearchActions(IMenuManager javaSearchMM) {
    Action[] actions = getActions();

    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];

        if (action.isEnabled()) {
            javaSearchMM.add(action);//w ww  . j a  v a 2  s  . c  o  m
        }
    }

    javaSearchMM.setVisible(!javaSearchMM.isEmpty());
}

From source file:melnorme.lang.ide.ui.editor.structure.AbstractContentOutlinePage.java

License:Open Source License

protected void contextMenuAboutToShow(IMenuManager menu) {
    if (menu.isEmpty()) {
        menu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
    }// ww  w. j a  va  2s  .c  o  m
}

From source file:net.certiv.fluentmark.outline.FluentOutlinePage.java

License:Open Source License

protected void contextMenuAboutToShow(IMenuManager mgr) {
    if (mgr.isEmpty()) {
        mgr.add(new GroupMarker(ICommonMenuConstants.GROUP_GOTO));
        mgr.add(new Separator(ICommonMenuConstants.GROUP_EDIT));
        mgr.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
        mgr.add(new Separator(ICommonMenuConstants.GROUP_PROPERTIES));

        mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_COPY));
        mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_CUT));
        mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_PASTE));
        mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_DELETE));
    }/*from  w  w  w  . j  ava 2s .c  o m*/

    actionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
    actionGroups.fillContextMenu(mgr);
}

From source file:net.karlmartens.ui.widget.VisibleColumnsContribution.java

License:Apache License

@Override
protected IContributionItem[] getContributionItems() {
    final IMenuManager menu = getMenuManager();
    menu.removeAll();/*from   ww w . j a  v  a 2s .  c om*/

    final IContributionItem[] items = new IContributionItem[_table.getColumnCount()];
    for (int i = 0; i < items.length; i++) {
        final TableColumn column = _table.getColumn(i);
        if (!column.isHideable())
            continue;

        menu.add(new ActionContributionItem(new ToggleColumnVisibiltyAction(column)));
    }

    menu.update();

    if (menu.isEmpty())
        return new IContributionItem[0];

    return new IContributionItem[] { menu };
}

From source file:org.bbaw.pdr.ae.view.main.editors.AspectEditorDialog.java

License:Open Source License

/**
 * Fill menu.//from ww w  .j a  v  a 2 s . co m
 * @param rootMenuManager the root menu manager
 */
protected final void fillMenu(final IMenuManager rootMenuManager) {

    if (Platform.getPreferencesService().getBoolean(CommonActivator.PLUGIN_ID, "FAVORITE_MARKUP_ALL", false,
            null)) {
        final HashMap<String, ConfigData> configs = _facade.getConfigs().get(_markupProvider).getChildren();
        for (String key : configs.keySet()) {
            ConfigData cd = configs.get(key);
            if (!(cd.getValue().contains("relation") || cd.getValue().contains("semantic"))) {
                createActionFromConfigData(rootMenuManager, cd);
            }
        }
    } else if (_facade.getFavoriteMarkups() != null && !_facade.getFavoriteMarkups().isEmpty()) {
        if (_facade.getFavoriteMarkups().size() < 20) {
            List<String> keys = new ArrayList<String>(_facade.getFavoriteMarkups().keySet());
            Collections.sort(keys);
            for (String key : keys) {
                final ConfigData cd = _facade.getFavoriteMarkups().get(key);
                Action markup = new Action(cd.getLabel()) {
                    @Override
                    public void run() {

                        setCombosByQuickSelect(cd);
                        setMarkup();
                    }
                };
                rootMenuManager.add(markup);
                markup.setImageDescriptor(_imageReg.getDescriptor(IconsInternal.MARKUP));
            }
        } else {
            IMenuManager subtype = new MenuManager(NLMessages.getString("Editor_submenu_subtype"));
            IMenuManager role = new MenuManager(NLMessages.getString("Editor_submenu_role"));
            List<String> keys = new ArrayList<String>(_facade.getFavoriteMarkups().keySet());
            Collections.sort(keys);
            for (String key : keys) {
                final ConfigData cd = _facade.getFavoriteMarkups().get(key);
                Action markup = new Action(cd.getLabel()) {
                    @Override
                    public void run() {
                        setCombosByQuickSelect(cd);
                        setMarkup();

                    }
                };
                if (cd.getPos().equals("type")) {
                    rootMenuManager.add(markup);
                } else if (cd.getPos().equals("subtype")) {
                    subtype.add(markup);
                } else {
                    role.add(markup);
                }
            }
            rootMenuManager.add(new Separator());
            if (!subtype.isEmpty()) {
                rootMenuManager.add(subtype);
            }
            if (!role.isEmpty()) {
                rootMenuManager.add(role);
            }

        }
    }
    rootMenuManager.add(new Separator());
    rootMenuManager.add(_customizeFavoriteMarkup);
    if (_selectedText != null && _selectedText.trim().length() > 0) {
        rootMenuManager.add(_createPersonFromString);
    }
    rootMenuManager.add(new Separator());
    rootMenuManager.add(_undoAction);
    rootMenuManager.add(_redoAction);
    rootMenuManager.add(_insertSpecialCharAction);
}