Search in sources :

Example 1 with MMenuElement

use of org.eclipse.e4.ui.model.application.ui.menu.MMenuElement in project whole by wholeplatform.

the class E4ModelProcessor method createFileMenu.

protected MMenu createFileMenu() {
    MMenu fileMenu = MMenuFactory.INSTANCE.createMenu();
    fileMenu.setLabel("File");
    List<MMenuElement> menuItems = fileMenu.getChildren();
    menuItems.add(createHandledMenuItem("save", "Save", "org.eclipse.ui.file.save", "platform:/plugin/org.whole.product.e4.lw/icons/save_edit.png"));
    menuItems.add(createHandledMenuItem("quit", "Quit", "org.eclipse.ui.file.exit"));
    menuItems.add(createHandledMenuItem("revert", "Revert", "org.eclipse.ui.file.revert"));
    return fileMenu;
}
Also used : MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) MMenuElement(org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)

Example 2 with MMenuElement

use of org.eclipse.e4.ui.model.application.ui.menu.MMenuElement in project whole by wholeplatform.

the class E4ModelProcessor method createEditMenu.

protected MMenu createEditMenu() {
    MMenu editMenu = MMenuFactory.INSTANCE.createMenu();
    editMenu.setLabel("Edit");
    List<MMenuElement> menuItems = editMenu.getChildren();
    menuItems.add(createHandledMenuItem("undo", "Undo", "org.eclipse.ui.edit.undo"));
    menuItems.add(createHandledMenuItem("redo", "Redo", "org.eclipse.ui.edit.redo"));
    menuItems.add(MMenuFactory.INSTANCE.createMenuSeparator());
    menuItems.add(createHandledMenuItem("cut", "Cut", "org.eclipse.ui.edit.cut"));
    menuItems.add(createHandledMenuItem("copy", "Copy", "org.eclipse.ui.edit.copy"));
    menuItems.add(createHandledMenuItem("paste", "Paste", "org.eclipse.ui.edit.paste"));
    menuItems.add(createHandledMenuItem("delete", "Delete", "org.eclipse.ui.edit.delete"));
    menuItems.add(createHandledMenuItem("selectAll", "Select All", "org.eclipse.ui.edit.selectAll"));
    menuItems.add(createHandledMenuItem("findReplace", "Find/Replace...", "org.eclipse.ui.edit.findReplace"));
    return editMenu;
}
Also used : MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) MMenuElement(org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)

Example 3 with MMenuElement

use of org.eclipse.e4.ui.model.application.ui.menu.MMenuElement in project whole by wholeplatform.

the class E4Utils method findMenu.

@SuppressWarnings("unchecked")
public static <T> T findMenu(String elementId, EModelService modelService, MApplication application, Class<T> type) {
    for (MWindow window : modelService.findElements(application, null, MWindow.class, null)) {
        MMenu mainMenu = window.getMainMenu();
        if (mainMenu == null)
            continue;
        MMenuElement menuElement = findMenu(elementId, mainMenu);
        if (menuElement != null)
            return (T) menuElement;
    }
    return null;
}
Also used : MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) MMenuElement(org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)

Example 4 with MMenuElement

use of org.eclipse.e4.ui.model.application.ui.menu.MMenuElement in project portfolio by buchen.

the class RecentFilesMenuContribution method aboutToShow.

@AboutToShow
public void aboutToShow(List<MMenuElement> items) {
    if (mCommand == null || mParameter == null)
        return;
    for (String file : recentFiles.getRecentFiles()) {
        MParameter parameter = modelService.createModelElement(MParameter.class);
        parameter.setName(mParameter.getElementId());
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(UIConstants.Parameter.FILE, file);
        ParameterizedCommand command = commandService.createCommand(UIConstants.Command.OPEN_RECENT_FILE, parameters);
        MHandledMenuItem menuItem = MMenuFactory.INSTANCE.createHandledMenuItem();
        menuItem.setToBeRendered(true);
        menuItem.setLabel(file);
        // $NON-NLS-1$
        menuItem.setTooltip("");
        // $NON-NLS-1$
        menuItem.setContributorURI("platform:/plugin/" + PortfolioPlugin.PLUGIN_ID);
        menuItem.getParameters().add(parameter);
        menuItem.setWbCommand(command);
        menuItem.setCommand(mCommand);
        items.add(menuItem);
    }
}
Also used : HashMap(java.util.HashMap) MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem) MParameter(org.eclipse.e4.ui.model.application.commands.MParameter) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand) AboutToShow(org.eclipse.e4.ui.di.AboutToShow)

Aggregations

MMenu (org.eclipse.e4.ui.model.application.ui.menu.MMenu)3 MMenuElement (org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)3 HashMap (java.util.HashMap)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)1 AboutToShow (org.eclipse.e4.ui.di.AboutToShow)1 MParameter (org.eclipse.e4.ui.model.application.commands.MParameter)1 MWindow (org.eclipse.e4.ui.model.application.ui.basic.MWindow)1 MHandledMenuItem (org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem)1