Search in sources :

Example 1 with MHandledMenuItem

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

the class E4ModelProcessor method createHandledMenuItem.

protected MHandledMenuItem createHandledMenuItem(String elementId, String label, String commandId, String iconURI) {
    MHandledMenuItem handledMenuItem = MMenuFactory.INSTANCE.createHandledMenuItem();
    handledMenuItem.setElementId(elementId);
    handledMenuItem.setLabel(label);
    handledMenuItem.setIconURI(iconURI);
    handledMenuItem.setCommand(E4Utils.findCommand(commandId, application));
    return handledMenuItem;
}
Also used : MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem)

Example 2 with MHandledMenuItem

use of org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem 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

MHandledMenuItem (org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem)2 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