Example usage for org.eclipse.jface.action MenuManager setActionDefinitionId

List of usage examples for org.eclipse.jface.action MenuManager setActionDefinitionId

Introduction

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

Prototype

public void setActionDefinitionId(String definitionId) 

Source Link

Document

Sets the action definition id of this action.

Usage

From source file:com.astra.ses.spell.dev.advisor.WorkbenchActionBuilder.java

License:Open Source License

/**
 * Creates and returns the File menu./*ww w. ja v a  2s .  c  o m*/
 */
private MenuManager createFileMenu() {
    MenuManager menu = new MenuManager("File", IWorkbenchActionConstants.M_FILE);
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
    {
        // create the New submenu, using the same id for it as the New action
        String newText = "New";
        String newId = ActionFactory.NEW.getId();
        MenuManager newMenu = new MenuManager(newText, newId);
        newMenu.setActionDefinitionId("org.eclipse.ui.file.newQuickMenu"); //$NON-NLS-1$
        newMenu.add(new Separator(newId));
        this.newWizardMenu = new NewWizard(getWindow());
        newMenu.add(this.newWizardMenu);
        newMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
        menu.add(newMenu);
    }

    menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
    menu.add(new Separator());

    menu.add(closeAction);
    menu.add(closeAllAction);
    //      menu.add(closeAllSavedAction);
    menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
    menu.add(new Separator());
    menu.add(saveAction);
    menu.add(saveAsAction);
    menu.add(saveAllAction);
    menu.add(getRevertItem());
    menu.add(new Separator());
    menu.add(getMoveItem());
    menu.add(getRenameItem());
    menu.add(getRefreshItem());

    menu.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));
    menu.add(new Separator());
    menu.add(getPrintItem());
    menu.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT));
    menu.add(new Separator());
    menu.add(openWorkspaceAction);
    menu.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
    menu.add(new Separator());
    menu.add(importResourcesAction);
    menu.add(exportResourcesAction);
    menu.add(new GroupMarker(IWorkbenchActionConstants.IMPORT_EXT));
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

    menu.add(new Separator());
    menu.add(getPropertiesItem());

    menu.add(ContributionItemFactory.REOPEN_EDITORS.create(getWindow()));
    menu.add(new GroupMarker(IWorkbenchActionConstants.MRU));
    menu.add(new Separator());

    // If we're on OS X we shouldn't show this command in the File menu. It
    // should be invisible to the user. However, we should not remove it -
    // the carbon UI code will do a search through our menu structure
    // looking for it when Cmd-Q is invoked (or Quit is chosen from the
    // application menu.
    ActionContributionItem quitItem = new ActionContributionItem(quitAction);
    quitItem.setVisible(!"carbon".equals(SWT.getPlatform())); //$NON-NLS-1$
    menu.add(quitItem);
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
    return menu;
}

From source file:ext.org.eclipse.jdt.internal.ui.actions.SurroundWithActionGroup.java

License:Open Source License

/**
 * The Menu to show when right click on the editor
 * {@inheritDoc}/*from w ww  . j a v  a2s. c  o  m*/
 */
@Override
public void fillContextMenu(IMenuManager menu) {
    ISelectionProvider selectionProvider = fEditor.getSelectionProvider();
    if (selectionProvider == null)
        return;

    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection))
        return;

    ITextSelection textSelection = (ITextSelection) selection;
    if (textSelection.getLength() == 0)
        return;

    String menuText = ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName;

    MenuManager subMenu = new MenuManager(menuText,
            SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
    subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
    menu.appendToGroup(fGroup, subMenu);
    subMenu.add(new Action() {
    });
    subMenu.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            manager.removeAll();
            SurroundWithTemplateMenuAction.fillMenu(manager, fEditor, fSurroundWithTryCatchAction);
        }
    });
}

From source file:fr.inria.portolan.rcp.application.ApplicationActionBarAdvisor.java

License:Open Source License

protected void fillMenuBar(IMenuManager menuBar) {
    // add menu File & Edit (needed by Ecore Diagram Editor: it inserts entries in Edit and Print submenus)
    MenuManager fileMenu = new MenuManager("File", IWorkbenchActionConstants.M_FILE);
    menuBar.add(fileMenu);/*from w  ww .  j a  v  a 2  s. com*/
    {
        // create the New submenu, using the same id for it as the New action
        String newId = ActionFactory.NEW.getId();
        MenuManager newMenu = new MenuManager("&New...", newId);
        newMenu.setActionDefinitionId("org.eclipse.ui.file.newQuickMenu");
        newMenu.add(this.newWizardMenu);
        fileMenu.add(newMenu);
    }
    //      fileMenu.add(newWizardMenu);
    fileMenu.add(printAction);
    fileMenu.add(exitAction);

    MenuManager editMenu = new MenuManager("Edit", IWorkbenchActionConstants.M_EDIT);
    menuBar.add(editMenu);
}

From source file:io.usethesource.impulse.editor.GenerateActionGroup.java

License:Open Source License

public void fillContextMenu(IMenuManager menu) {
    super.fillContextMenu(menu);
    MenuManager subMenu = new MenuManager("Source", MENU_ID);
    subMenu.setActionDefinitionId(QUICK_MENU_ID);
    int added = 0;
    if (isEditorOwner()) {
        added = fillEditorSubMenu(subMenu);
    } else {// w ww  .j  a  v  a 2s .c om
        added = fillViewSubMenu(subMenu);
    }
    if (added > 0)
        menu.appendToGroup(fGroupName, subMenu);
}

From source file:org.codehaus.groovy.eclipse.quickfix.templates.SurroundWithActionGroup.java

License:Open Source License

/**
 * The Menu to show when right click on the editor
 * {@inheritDoc}/*from w  w w .  j  ava 2  s  .c  o  m*/
 */
@Override
public void fillContextMenu(IMenuManager menu) {
    ISelectionProvider selectionProvider = fEditor.getSelectionProvider();
    if (selectionProvider == null)
        return;

    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection))
        return;

    //      ITextSelection textSelection= (ITextSelection)selection;
    //      if (textSelection.getLength() == 0)
    //         return;

    String menuText = ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTemplateSubMenuName;

    MenuManager subMenu = new MenuManager(menuText,
            SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
    subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
    menu.appendToGroup(fGroup, subMenu);
    subMenu.add(new Action() {
    });
    subMenu.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            manager.removeAll();
            SurroundWithTemplateMenuAction.fillMenu(manager, fEditor);
        }
    });
}

From source file:org.eclipse.cdt.internal.ui.actions.SurroundWithActionGroup.java

License:Open Source License

/**
 * The Menu to show when right click on the editor
 * {@inheritDoc}// w  w w. j a v  a 2  s  . com
 */
@Override
public void fillContextMenu(IMenuManager menu) {
    ISelectionProvider selectionProvider = fEditor.getSelectionProvider();
    if (selectionProvider == null)
        return;

    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection))
        return;

    ITextSelection textSelection = (ITextSelection) selection;
    if (textSelection.getLength() == 0)
        return;

    String menuText = ActionMessages.SurroundWithTemplateMenuAction_SubMenuName;

    MenuManager subMenu = new MenuManager(menuText,
            SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
    subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
    menu.appendToGroup(fGroup, subMenu);
    subMenu.add(new Action() {
    });
    subMenu.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            manager.removeAll();
            SurroundWithTemplateMenuAction.fillMenu(manager, fEditor);
        }
    });
}

From source file:org.eclipse.cdt.ui.actions.GenerateActionGroup.java

License:Open Source License

@Override
public void fillContextMenu(IMenuManager menu) {
    super.fillContextMenu(menu);
    MenuManager subMenu = new MenuManager(ActionMessages.SourceMenu_label, MENU_ID);
    subMenu.setActionDefinitionId(QUICK_MENU_ID);
    int added = 0;
    if (isEditorOwner()) {
        added = fillEditorSubMenu(subMenu);
    } else {/* www .  ja v  a  2  s  .c om*/
        added = fillViewSubMenu(subMenu);
    }
    if (added > 0)
        menu.appendToGroup(fGroupName, subMenu);
}

From source file:org.eclipse.datatools.enablement.rcp.ApplicationActionBarAdvisor.java

License:Open Source License

/**
 * Creates and returns the File menu./*from   w  ww.j av a 2s .  c  om*/
 */
private MenuManager createFileMenu() {
    MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_file, IWorkbenchActionConstants.M_FILE);
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
    {
        // create the New submenu, using the same id for it as the New action
        String newText = IDEWorkbenchMessages.Workbench_new;
        String newId = ActionFactory.NEW.getId();
        MenuManager newMenu = new MenuManager(newText, newId);
        newMenu.setActionDefinitionId("org.eclipse.ui.file.newQuickMenu"); //$NON-NLS-1$
        newMenu.add(new Separator(newId));
        this.newWizardMenu = new NewWizardMenu(getWindow());
        newMenu.add(this.newWizardMenu);
        newMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
        menu.add(newMenu);
    }

    menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
    menu.add(new Separator());

    menu.add(closeAction);
    menu.add(closeAllAction);
    //      menu.add(closeAllSavedAction);
    menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
    menu.add(new Separator());
    menu.add(saveAction);
    menu.add(saveAsAction);
    menu.add(saveAllAction);
    menu.add(getRevertItem());
    menu.add(new Separator());
    menu.add(getMoveItem());
    menu.add(getRenameItem());
    menu.add(getRefreshItem());

    menu.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));
    menu.add(new Separator());
    menu.add(getPrintItem());
    menu.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT));
    menu.add(new Separator());
    //        menu.add(openWorkspaceAction);
    //        menu.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
    //        menu.add(new Separator());
    //        menu.add(importResourcesAction);
    //        menu.add(exportResourcesAction);
    menu.add(new GroupMarker(IWorkbenchActionConstants.IMPORT_EXT));
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

    menu.add(new Separator());
    menu.add(getPropertiesItem());

    menu.add(ContributionItemFactory.REOPEN_EDITORS.create(getWindow()));
    menu.add(new GroupMarker(IWorkbenchActionConstants.MRU));
    menu.add(new Separator());

    // If we're on OS X we shouldn't show this command in the File menu. It
    // should be invisible to the user. However, we should not remove it -
    // the carbon UI code will do a search through our menu structure
    // looking for it when Cmd-Q is invoked (or Quit is chosen from the
    // application menu.
    ActionContributionItem quitItem = new ActionContributionItem(quitAction);
    quitItem.setVisible(!"carbon".equals(SWT.getPlatform())); //$NON-NLS-1$
    menu.add(quitItem);
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
    return menu;
}

From source file:org.eclipse.datatools.enablement.rcp.ApplicationActionBarAdvisor.java

License:Open Source License

/**
 * Creates and returns the Navigate menu.
 *//*from  w ww .j av a2 s .  c om*/
private MenuManager createNavigateMenu() {
    MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_navigate,
            IWorkbenchActionConstants.M_NAVIGATE);
    menu.add(new GroupMarker(IWorkbenchActionConstants.NAV_START));
    menu.add(goIntoAction);

    MenuManager goToSubMenu = new MenuManager(IDEWorkbenchMessages.Workbench_goTo,
            IWorkbenchActionConstants.GO_TO);
    menu.add(goToSubMenu);
    goToSubMenu.add(backAction);
    goToSubMenu.add(forwardAction);
    goToSubMenu.add(upAction);
    goToSubMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

    menu.add(new Separator(IWorkbenchActionConstants.OPEN_EXT));
    for (int i = 2; i < 5; ++i) {
        menu.add(new Separator(IWorkbenchActionConstants.OPEN_EXT + i));
    }
    menu.add(new Separator(IWorkbenchActionConstants.SHOW_EXT));
    {
        MenuManager showInSubMenu = new MenuManager(IDEWorkbenchMessages.Workbench_showIn, "showIn"); //$NON-NLS-1$
        showInSubMenu.setActionDefinitionId(showInQuickMenu.getActionDefinitionId());
        showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getWindow()));
        menu.add(showInSubMenu);
    }
    for (int i = 2; i < 5; ++i) {
        menu.add(new Separator(IWorkbenchActionConstants.SHOW_EXT + i));
    }
    menu.add(new Separator());
    menu.add(nextAction);
    menu.add(previousAction);
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    menu.add(new GroupMarker(IWorkbenchActionConstants.NAV_END));

    //TBD: Location of this actions
    menu.add(new Separator());
    menu.add(backwardHistoryAction);
    menu.add(forwardHistoryAction);
    return menu;
}

From source file:org.eclipse.dltk.internal.ui.actions.refactoring.RefactorActionGroup.java

License:Open Source License

private void addRefactorSubmenu(IMenuManager menu) {
    String menuText = ActionMessages.RefactorMenu_label;
    // if (fQuickAccessAction != null) {
    // menuText= fQuickAccessAction.addShortcut(menuText);
    // }//from  w  ww . j  a v  a 2s  .  c  o m
    MenuManager refactorSubmenu = new MenuManager(menuText, MENU_ID);
    refactorSubmenu.setActionDefinitionId(QUICK_MENU_ID);
    if (fEditor != null) {
        IModelElement element = SelectionConverter.getInput(fEditor);
        if (element != null && ActionUtil.isOnBuildPath(element)) {
            refactorSubmenu.addMenuListener(new IMenuListener() {
                public void menuAboutToShow(IMenuManager manager) {
                    refactorMenuShown(manager);
                }
            });
            refactorSubmenu.add(fNoActionAvailable);
            menu.appendToGroup(fGroupName, refactorSubmenu);
        }
    } else {
        ISelection selection = fSite.getSelectionProvider().getSelection();
        for (SelectionDispatchAction action : fActions) {
            action.update(selection);
        }
        if (fillRefactorMenu(refactorSubmenu) > 0) {
            menu.appendToGroup(fGroupName, refactorSubmenu);
        }
    }
}