Search in sources :

Example 1 with MParameter

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

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