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

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

Introduction

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

Prototype

void setVisible(boolean visible);

Source Link

Document

Sets whether this contribution item is visibile within its manager.

Usage

From source file:com.aptana.ide.editors.unified.actions.UnifiedActionContributor.java

License:Open Source License

/**
 * Add actions to the editor's menus./* ww w  . j av  a 2  s  .  c  o  m*/
 * 
 * @param menu
 */
public void contributeToMenu(IMenuManager menu) {
    if (fShowDocAction == null) {
        return;
    }

    super.contributeToMenu(menu);

    IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu != null) {
        editMenu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fShowDocAction);
        editMenu.add(this.fCodeFormatAction);
        editMenu.setVisible(true);
    }

    if (fOpenDeclarationAction != null) {
        IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
        if (navigateMenu != null) {
            navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fOpenDeclarationAction);
            navigateMenu.setVisible(true);
        }
    }

    if (fQuickOutlineAction != null) {
        IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
        if (navigateMenu != null) {
            navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fQuickOutlineAction);
            navigateMenu.setVisible(true);
        }
    }

    IMenuManager gotoMenu = menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
    if (gotoMenu != null) {
        gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
        gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
        if (!gotoMenu.isVisible())
            gotoMenu.setVisible(true);
    }

}

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 av  a2s . c  om
        }
    }

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

From source file:com.nokia.tools.s60.views.CustomizedPropertySheet.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {

    super.createPartControl(parent);
    IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
    menuManager.setVisible(false);
    menuManager.removeAll();/*  w ww . j a  v  a  2 s  .com*/
    menuManager.setRemoveAllWhenShown(true);
    menuManager.updateAll(true);

    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    toolBarManager.removeAll();
    menuManager.setRemoveAllWhenShown(true);
    toolBarManager.update(true);
}

From source file:com.nokia.traceviewer.action.ActionFactory.java

License:Open Source License

/**
 * Fills the view menu with the actions/*from ww  w  .  j av  a2s. co  m*/
 * 
 * @param manager
 *            the menu manager
 */
public void fillMenu(IMenuManager manager) {
    manager.add(traceActivationAction);
    manager.add(new Separator());
    IMenuManager subMgr = new MenuManager(Messages.getString("ActionFactory.LogSubMenuTitle"), logSubMenuImage, //$NON-NLS-1$
            null);
    subMgr.setRemoveAllWhenShown(true);
    subMgr.setVisible(true);
    subMgr.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager mgr) {
            mgr.add(logOpenLogAction);
            mgr.add(new Separator());
            mgr.add(logNewBinaryAction);
            mgr.add(logSaveBinaryAction);
            mgr.add(logCloseBinaryAction);

            mgr.add(new Separator());
            mgr.add(logNewAsciiAction);
            mgr.add(logSaveAsciiAction);
            mgr.add(logCloseAsciiAction);

            // Get the logger DataProcessor
            Logger logger = TraceViewerGlobals.getTraceViewer().getDataProcessorAccess().getLogger();

            boolean asciiLogging = logger.isPlainLogging();
            boolean binaryLogging = logger.isBinLogging();
            boolean logFileOpened = logger.isLogFileOpened();

            // Check if Binary logging is on
            logNewBinaryAction.setEnabled(!binaryLogging);
            logCloseBinaryAction.setEnabled(binaryLogging);

            // Check if ASCII logging is on
            logNewAsciiAction.setEnabled(!asciiLogging);
            logCloseAsciiAction.setEnabled(asciiLogging);

            logOpenLogAction.setEnabled(!asciiLogging && !binaryLogging);

            // Check if log file is opened
            if (logFileOpened) {
                logNewBinaryAction.setEnabled(false);
                logCloseBinaryAction.setEnabled(false);
                logNewAsciiAction.setEnabled(false);
                logCloseAsciiAction.setEnabled(false);
            }

        }
    });

    manager.add(subMgr);
    manager.add(new Separator());
    manager.add(triggerAction);
    manager.add(new Separator());
    manager.add(openConnectionSettingsAction);
    manager.add(new Separator());
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}

From source file:edu.buffalo.cse.green.editor.DiagramEditor.java

License:Open Source License

public void createContextMenu(IMenuManager m) {
    buildMenu(m);
    updateMenuDisplay(m);
    _menuManager = m;
    m.setVisible(true);
}

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);/*from   w w w  .  jav a  2 s  .  c om*/
        }
    }

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

From source file:net.refractions.udig.project.ui.internal.tool.display.MenuToolCategory.java

License:Open Source License

/**
 * Adds items action in the correct locations in the menu.
 * /* www.j  a v  a 2 s  . c o  m*/
 * @param manager
 */
public void contribute(IMenuManager manager) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IContextService contextService = (IContextService) workbench.getService(IContextService.class);
    Collection<String> active = (Collection<String>) contextService.getActiveContextIds();

    MenuManager actionMenu = new MenuManager(name, id);
    final String actionExt = "action.ext";
    actionMenu.add(new GroupMarker(actionExt)); //$NON-NLS-1$
    actionMenu.add(new GroupMarker("modal.ext")); //$NON-NLS-1$
    for (ModalItem item : this) {
        ToolProxy tool = (ToolProxy) item;
        String categoryId = tool.getCategoryId();
        if (contextService.getDefinedContextIds().contains(categoryId)) {
            // we have an context for this tool category
            if (!active.contains(categoryId)) {
                continue; // skip this category please!
            }
        }
        if (tool.getType() == ToolProxy.ACTION) {
            String menuPath = tool.getMenuPath();
            IAction action = tool.getAction();

            if (menuPath != null) {
                String root = menuPath.substring(0, menuPath.lastIndexOf("/")); //$NON-NLS-1$
                String groupName = menuPath.substring(menuPath.lastIndexOf("/") + 1, menuPath.length()); //$NON-NLS-1$
                if (groupName.equals(Constants.M_TOOL)) {
                    groupName = "map";
                }
                IMenuManager targetMenu = manager.findMenuUsingPath(root);
                if (targetMenu != null) {
                    IContributionItem find = targetMenu.find(groupName);
                    if (find != null && find instanceof GroupMarker) {
                        //targetMenu.appendToGroup(groupName, action); //$NON-NLS-1$
                        targetMenu.appendToGroup(groupName, tool.getAction());
                        targetMenu.setVisible(true);
                    } else {
                        targetMenu.add(action);
                        targetMenu.setVisible(true);
                    }
                } else
                    actionMenu.appendToGroup(actionExt, tool.getAction()); //$NON-NLS-1$
            } else {
                actionMenu.appendToGroup(actionExt, tool.getAction()); //$NON-NLS-1$
            }
        }
        if (tool.getType() == ToolProxy.MODAL) {
            MenuCurrentToolItem menuItem = new MenuCurrentToolItem(tool);
            tool.addContribution(menuItem);
            actionMenu.appendToGroup("modal.ext", menuItem); //$NON-NLS-1$
        }
    }
    if (actionMenu.getItems().length > 0) {
        // Handle left over tools! Place them in the map menu?
        String menuPath = "map"; // was Constants.M_TOOL
        IMenuManager toolManager = manager.findMenuUsingPath(menuPath);
        if (toolManager == null) {
            toolManager = new MenuManager(Messages.MenuToolCategory_menu_manager_title, "tools"); //$NON-NLS-1$
            manager.add(toolManager);
            toolManager.add(new GroupMarker(actionExt)); //$NON-NLS-1$
            toolManager.add(new GroupMarker("modal.ext")); //$NON-NLS-1$
        }
        if (toolManager.find(actionExt) == null) {
            toolManager.add(new GroupMarker(actionExt)); //$NON-NLS-1$
        }
        toolManager.appendToGroup(actionExt, actionMenu); //$NON-NLS-1$
        toolManager.setVisible(true);
    }
}

From source file:net.refractions.udig.project.ui.internal.tool.display.ToolManager.java

License:Open Source License

/**
 * Used to contribute Tools to the provided menu manger.
 * <p>/*from   w w w. j  a  v  a  2s .  co  m*/
 * The following contributions are made:
 * <ul>
 * <li>navigate: forward and backward buttons
 * <li>map: an entry for each tool category
 * </ul>
 */
public void contributeToMenu(IMenuManager manager) {
    IMenuManager navigateMenu = manager.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);

    if (navigateMenu == null) {
        // I would like to arrange for the Navigate menu to already
        // be in place before the ToolManager is kicked into action
        // (this is part of the missions to have uDig plugins walk
        //  softly when being hosted in other RCP applications)
        // See UDIGActionBarAdvisor for hosting requirements.
        navigateMenu = new MenuManager(Messages.ToolManager_menu_manager_title,
                IWorkbenchActionConstants.M_NAVIGATE);

        IContributionItem additions = manager.find(IWorkbenchActionConstants.MB_ADDITIONS);
        if (additions == null || !(additions instanceof GroupMarker)) {
            manager.add(navigateMenu);
        } else {
            manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, navigateMenu);
        }
        navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.NAV_START));
        navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.NAV_END));
    }
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    // we are using the global BACK and FORWARD actions here
    // and will register "handlers" for these commands 
    navigateMenu.appendToGroup(IWorkbenchActionConstants.NAV_END, ActionFactory.BACK.create(window));
    navigateMenu.appendToGroup(IWorkbenchActionConstants.NAV_END, ActionFactory.FORWARD.create(window));

    if (!manager.isVisible()) {
        // since this is the top level menu bar why would it not be visible?
        manager.setVisible(true);
    }
    IMenuManager mapMenu = manager.findMenuUsingPath("map");
    if (mapMenu == null) {
        // Once again the hosting RCP application should of provided
        // us with a Map menu; but let's be careful and make our own here
        // if needed.
        // See UDIGActionBarAdvisor for hosting requirements.
        mapMenu = new MenuManager(Messages.ToolManager_menu_manager_title, "map");
        manager.add(mapMenu);
        mapMenu.add(new GroupMarker("mapStart"));
        mapMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        mapMenu.add(new GroupMarker("mapEnd"));
    }
    // churn through each category and add stuff as needed
    // note we check with the cmdService to see what we if the actionSet
    // associated with this cateogry is turned on by the
    // current perspective.
    for (MenuToolCategory category : menuCategories) {
        category.contribute(manager);
    }
}

From source file:org.eclipse.bpel.common.ui.composite.CompositeEditorManager.java

License:Open Source License

/**
 * Creates and initializes an IEditorPart given its id and input. 
 *//*from w w w.  jav a2  s  .c o  m*/
public IEditorPart createEditor(String editorId, IEditorInput input) throws CoreException {
    IEditorPart editor = instantiateEditor(editorId);
    EditorSite site = createEditorSite(editorId, editor);
    editor.init(site, input);

    // Force menus to be created.
    IMenuManager menuManager = mainEditorSite.getActionBars().getMenuManager();
    menuManager.setVisible(false);
    menuManager.setVisible(true);

    return editor;
}

From source file:org.eclipse.emf.henshin.presentation.CustomizedHenshinActionBarContributor.java

License:Open Source License

@Override
public void contributeToMenu(IMenuManager menuManager) {
    super.contributeToMenu(menuManager);
    IMenuManager subMenuManager = (IMenuManager) menuManager.find("org.eclipse.emf.henshin.modelMenuID");
    MenuManager mm = new MenuManager(HenshinEditorPlugin.INSTANCE.getString("_UI_CreateAdvanced_menu_item"));
    subMenuManager.setVisible(false);
    subMenuManager.insertBefore("additions", mm);
    this.managedMenus.add(mm);
}