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

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

Introduction

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

Prototype

public MenuManager(String text, ImageDescriptor image, String id) 

Source Link

Document

Creates a menu manager with the given text, image, and id.

Usage

From source file:com.amalto.workbench.editors.DataModelMainPage.java

License:Open Source License

private IMenuManager getAddElementMenuForTypeClass(Class<?> typeClass, String menuName) {
    IMenuManager menu = new MenuManager(menuName, ImageCache.getImage(EImage.ADD_OBJ.getPath()),
            ADDELEMENT_MENU_ID);//from w ww.  j  a v  a 2s .c o m

    createActionItems(typeClass, menu);

    return menu;
}

From source file:com.amazonaws.eclipse.explorer.actions.ConfigurationActionProvider.java

License:Apache License

/**
 * This method is invoked whenever the selection in the viewer changes, so
 * we need to make sure not to add our action more than once.
 *//*from  w w w . ja  va  2  s. co  m*/
@Override
public void fillActionBars(IActionBars actionBars) {
    for (IContributionItem item : actionBars.getToolBarManager().getItems()) {
        if (item.getId() == regionSelectionAction.getId())
            return;
    }

    actionBars.getToolBarManager().add(new Separator());
    actionBars.getToolBarManager().add(refreshAction);

    actionBars.getToolBarManager().add(new Separator());
    actionBars.getToolBarManager().add(regionSelectionAction);

    MenuManager menuMgr = new MenuManager("AWS Account",
            AwsToolkitCore.getDefault().getImageRegistry().getDescriptor(AwsToolkitCore.IMAGE_AWS_ICON), "");
    menuMgr.setRemoveAllWhenShown(true);

    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            String currentAccountId = AwsToolkitCore.getDefault().getCurrentAccountId();
            Map<String, String> accounts = AwsToolkitCore.getDefault().getAccounts();
            for (Entry<String, String> entry : accounts.entrySet()) {
                manager.add(new SwitchAccountAction(entry.getKey(), entry.getValue(),
                        currentAccountId.equals(entry.getKey())));
            }
            manager.add(new Separator());
            manager.add(new AccountPreferencesAction());
        }
    });
    actionBars.getMenuManager().add(menuMgr);
    actionBars.getToolBarManager().update(true);
}

From source file:com.aptana.deploy.internal.ui.DeployPopupContributionItem.java

License:Open Source License

@Override
public void fill(Menu menu, int index) {
    menuManager = new MenuManager(Messages.DeployPopupContributionItem_Text, AbstractUIPlugin
            .imageDescriptorFromPlugin(DeployUIPlugin.PLUGIN_ID, DeployUIPlugin.DEPLOY_MENU_ICON),
            DeployUIPlugin.DEPLOY_MENU_ID);
    IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class);
    menuService.populateContributionManager(menuManager, MenuUtil.menuUri(menuManager.getId()));
    menuManager.fill(menu, index);/* w  w  w.  j av a 2 s.  c o m*/
}

From source file:com.bluexml.side.view.presentation.ViewActionBarContributor.java

License:Open Source License

/**
 * Add actions specific to views/*from   ww  w  .j  a  v a2  s .c o m*/
 * @param menuManager
 * @param o
 */
private void addActionsForViews(IMenuManager menuManager, Object o) {
    // Initialize
    initializeView
            .setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "/icons/menu/initialize.png"));
    menuManager.insertAfter("ui-actions", initializeView);

    // Refresh Outline
    refreshOutline.setImageDescriptor(
            ImageDescriptor.createFromFile(this.getClass(), "/icons/menu/refreshOutline.png"));
    menuManager.insertAfter("ui-actions", refreshOutline);

    // Restore
    MenuManager restoreMenu = new MenuManager("Restore",
            ImageDescriptor.createFromFile(this.getClass(), "/icons/menu/restore.png"), "restore");
    if (((AbstractView) o).getDisabled().size() > 0) {
        restoreMenu.add(new Action("never shown entry") {
        });
        restoreMenu.setRemoveAllWhenShown(true);
        IMenuListener restoreListener = new IMenuListener() {
            public void menuAboutToShow(IMenuManager m) {
                fillRestoreContextMenu(m);
            }
        };
        restoreMenu.addMenuListener(restoreListener);
    }
    menuManager.insertAfter("ui-actions", restoreMenu);

    // Add linked field
    final IMenuManager addLinkedFieldMenu = new MenuManager("Add linked Field",
            ImageDescriptor.createFromFile(this.getClass(), "/icons/menu/addLinkedField.png"), "transform");
    addLinkedFieldMenu.add(new Action("never shown entry") {
    });
    addLinkedFieldMenu.setRemoveAllWhenShown(true);
    IMenuListener addLinkedFieldListener = new IMenuListener() {
        public void menuAboutToShow(IMenuManager m) {
            fillAddLinkedMenu(m, addLinkedFieldMenu);
        }
    };
    addLinkedFieldMenu.addMenuListener(addLinkedFieldListener);
    menuManager.insertAfter("ui-actions", addLinkedFieldMenu);
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private ActionGroup createFormatActionGroup() {
    formatMenu = new MenuManager("Format", null, MdwMenuManager.MDW_MENU_PREFIX + "format");
    return new ActionGroup() {
        @Override//from w w w.  jav a2  s  . co m
        public void fillContextMenu(IMenuManager menu) {
            formatMenu.removeAll();
            WorkflowProject project = view.getTestSuite().getProject();
            formatMenu.add(formatFunctionTestResultsAction);
            java.io.File resultsFile = project.getFunctionTestResultsFile();
            formatFunctionTestResultsAction.setEnabled(resultsFile != null && resultsFile.exists());
            formatMenu.add(formatLoadTestResultsAction);
            resultsFile = project.getLoadTestResultsFile();
            formatLoadTestResultsAction.setEnabled(resultsFile != null && resultsFile.exists());
        }
    };
}

From source file:com.centurylink.mdw.plugin.designer.views.ProcessExplorerActionGroup.java

License:Apache License

private ActionGroup createNewActionGroup() {
    newMenu = new MenuManager("New", null, MdwMenuManager.MDW_MENU_PREFIX + "menu.new");
    return new ActionGroup() {
        @Override//  www  .j a  v a2s . c  o m
        public void fillContextMenu(IMenuManager menu) {
            newMenu.removeAll();
            IStructuredSelection selection = getSelection();

            if (!newMenuApplies(selection))
                return;

            if (!MdwPlugin.isRcp())
                newMenu.add(newCloudProjectAction);

            if (createApplies(WorkflowProject.class, selection))
                newMenu.add(newRemoteProjectAction);

            newMenu.add(new Separator());

            if (createApplies(WorkflowPackage.class, selection))
                newMenu.add(newPackageAction);

            if (createApplies(WorkflowProcess.class, selection))
                newMenu.add(newProcessAction);

            newMenu.add(new Separator());

            if (createApplies(Activity.class, selection)) {
                MenuManager activityMenu = new MenuManager("Activity", null,
                        MdwMenuManager.MDW_MENU_PREFIX + "menu.new.activity");
                activityMenu.add(newGeneralActivityAction);
                activityMenu.add(newStartActivityAction);
                activityMenu.add(newAdapterActivityAction);
                activityMenu.add(newEvaluatorActivityAction);
                newMenu.add(activityMenu);
            }

            if (createApplies(ExternalEvent.class, selection)) {
                MenuManager eventHandlerMenu = new MenuManager("Event Handler", null,
                        MdwMenuManager.MDW_MENU_PREFIX + "menu.new.event.handler");
                eventHandlerMenu.add(newEventHandlerAction);
                eventHandlerMenu.add(newCamelProcessHandlerAction);
                eventHandlerMenu.add(newCamelNotifyHandlerAction);
                newMenu.add(eventHandlerMenu);
            }

            newMenu.add(new Separator());

            if (createApplies(WorkflowAsset.class, selection)) {
                newMenu.add(new Separator());
                newMenu.add(newCamelRouteAction);
                newMenu.add(newJarFileAction);
                newMenu.add(newJavaSourceAction);
                newMenu.add(newJsonAction);
                newMenu.add(newPageAction);
                newMenu.add(newReportAction);
                newMenu.add(newRuleAction);
                newMenu.add(newScriptAction);
                newMenu.add(newSpringConfigAction);
                if (selection.getFirstElement() instanceof WorkflowElement
                        && ((WorkflowElement) selection.getFirstElement()).getProject().isFilePersist())
                    newMenu.add(newTaskTemplateAction);
                newMenu.add(newTemplateAction);
                newMenu.add(newTestCaseAction);
                newMenu.add(newTextResourceAction);
                newMenu.add(newWebResourceAction);
                newMenu.add(newWordDocAction);
                newMenu.add(newXmlDocAction);
                newMenu.add(newYamlAction);
                newMenu.add(new Separator());
            }

            newMenu.add(new Separator("Other"));
            IWorkbenchAction otherAction = ActionFactory.NEW.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "new.other");
            otherAction.setText("Other...");
            newMenu.add(otherAction);
        }
    };
}

From source file:com.centurylink.mdw.plugin.designer.views.ProcessExplorerActionGroup.java

License:Apache License

private ActionGroup createImportActionGroup() {
    importMenu = new MenuManager("Import", MdwPlugin.getImageDescriptor("icons/import.gif"),
            MdwMenuManager.MDW_MENU_PREFIX + "menu.import");
    return new ActionGroup() {
        @Override/*from www.j  a v a2s. c  o m*/
        public void fillContextMenu(IMenuManager menu) {
            importMenu.removeAll();
            IStructuredSelection selection = getSelection();

            if (!importMenuApplies(selection))
                return;

            if (importProjectApplies(selection))
                importMenu.add(importProjectAction);

            if (importPackageApplies(selection))
                importMenu.add(importPackageAction);

            if (importVcsApplies(selection))
                importMenu.add(importVcsAction);

            if (importProcessApplies(selection)) {
                if (selection.getFirstElement() instanceof WorkflowProcess) {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.process.version");
                    importProcessAction.setText("New Process Version...");
                } else {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.process");
                    importProcessAction.setText("Process...");
                }
                importMenu.add(importProcessAction);
            }

            if (importWorkflowAssetApplies(selection)) {
                if (selection.getFirstElement() instanceof WorkflowAsset) {
                    WorkflowAsset asset = (WorkflowAsset) selection.getFirstElement();
                    // menu item text and icon are dynamic
                    importWorkflowAssetAction
                            .setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.asset.version");
                    importWorkflowAssetAction.setText("New " + asset.getTitle() + " Version...");
                    importWorkflowAssetAction
                            .setImageDescriptor(MdwPlugin.getImageDescriptor("icons/" + asset.getIcon()));
                } else {
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.asset");
                    importWorkflowAssetAction.setText("Asset...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor("icons/doc.gif"));
                }
                importMenu.add(importWorkflowAssetAction);
            }

            if (importAttributesApplies(selection)) {
                List<IAction> importAttrsActions = getImportAttributeActions(selection);
                if (!importAttrsActions.isEmpty()) {
                    MenuManager attributesMenu = new MenuManager("Attributes",
                            MdwPlugin.getImageDescriptor("icons/attribute.gif"),
                            MdwMenuManager.MDW_MENU_PREFIX + "menu.import.attributes");
                    attributesMenu.removeAll();
                    for (IAction action : importAttrsActions)
                        attributesMenu.add(action);
                    importMenu.add(attributesMenu);
                }
            }

            if (importTaskTemplateApplies(selection))
                importMenu.add(importTaskTemplateAction);

            importMenu.add(new Separator("Other"));
            IWorkbenchAction otherAction = ActionFactory.IMPORT.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.other");
            otherAction.setText("Other...");
            importMenu.add(otherAction);
        }
    };
}

From source file:com.centurylink.mdw.plugin.designer.views.ProcessExplorerActionGroup.java

License:Apache License

private ActionGroup createExportActionGroup() {
    exportMenu = new MenuManager("Export", MdwPlugin.getImageDescriptor("icons/export.gif"),
            MdwMenuManager.MDW_MENU_PREFIX + "menu.export");
    return new ActionGroup() {
        @Override//  w  w  w .j  a  v a  2  s  .  co m
        public void fillContextMenu(IMenuManager menu) {
            exportMenu.removeAll();
            IStructuredSelection selection = getSelection();

            if (exportProjectApplies(selection))
                exportMenu.add(exportProjectAction);

            if (exportPackageApplies(selection))
                exportMenu.add(exportPackageAction);

            if (exportProcessApplies(selection))
                exportMenu.add(exportProcessAction);

            if (exportWorkflowAssetApplies(selection)) {
                WorkflowAsset asset = (WorkflowAsset) selection.getFirstElement();
                // menu item text and icon are dynamic
                exportWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.to.file");
                exportWorkflowAssetAction.setText(asset.getTitle() + " to File...");
                exportWorkflowAssetAction
                        .setImageDescriptor(MdwPlugin.getImageDescriptor("icons/" + asset.getIcon()));
                exportMenu.add(exportWorkflowAssetAction);
            }

            if (exportAttributesApplies(selection)) {
                List<IAction> exportAttrsActions = getExportAttributeActions(selection);
                if (!exportAttrsActions.isEmpty()) {
                    MenuManager attributesMenu = new MenuManager("Attributes",
                            MdwPlugin.getImageDescriptor("icons/attribute.gif"),
                            MdwMenuManager.MDW_MENU_PREFIX + "menu.export.attributes");
                    attributesMenu.removeAll();
                    for (IAction action : exportAttrsActions)
                        attributesMenu.add(action);
                    exportMenu.add(attributesMenu);
                }
            }

            if (exportTaskTemplatesApplies(selection))
                exportMenu.add(exportTaskTemplateAction);

            exportMenu.add(new Separator("Other"));
            IWorkbenchAction otherAction = ActionFactory.EXPORT.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.other");
            otherAction.setText("Other...");
            exportMenu.add(otherAction);
        }
    };
}

From source file:com.centurylink.mdw.plugin.designer.views.ProcessExplorerActionGroup.java

License:Apache License

private ActionGroup createRunActionGroup() {
    runMenu = new MenuManager("Run", MdwPlugin.getImageDescriptor("icons/run.gif"),
            MdwMenuManager.MDW_MENU_PREFIX + "menu.run");
    return new ActionGroup() {
        @Override// ww  w .  jav a2 s. c  o m
        public void fillContextMenu(IMenuManager menu) {
            runMenu.removeAll();
            IStructuredSelection selection = getSelection();

            if (runOnServerApplies(selection))
                runMenu.add(runOnServerAction);
            if (runTestsApplies(selection))
                runMenu.add(runTestsAction);
        }
    };
}

From source file:com.centurylink.mdw.plugin.designer.views.ProcessExplorerActionGroup.java

License:Apache License

private ActionGroup createWebActionGroup() {
    webMenu = new MenuManager("Web", MdwPlugin.getImageDescriptor("icons/webtools.gif"),
            MdwMenuManager.MDW_MENU_PREFIX + "menu.web");
    return new ActionGroup() {
        @Override/*from w w  w  .  ja v  a  2s.c  o  m*/
        public void fillContextMenu(IMenuManager menu) {
            webMenu.removeAll();
            IStructuredSelection selection = getSelection();
            if (webLaunchApplies(selection)) {
                if (selection.getFirstElement() instanceof WorkflowElement) {
                    if (((WorkflowElement) selection.getFirstElement()).getProject().checkRequiredVersion(5,
                            5)) {
                        webMenu.add(mdwHubAction);
                    } else {
                        webMenu.add(taskManagerAction);
                        webMenu.add(webToolsAction);
                    }
                }
            }
        }
    };
}