private MMenuItem createFeature(Feature f) {
    MHandledMenuItem e = modelService.createModelElement(MHandledMenuItem.class);
    e.setLabel("%editorfeature." + f.name());
    e.setContributorURI("platform:/plugin/at.bestsolution.dart.app");
    e.setType(ItemType.CHECK);
    if (f == Feature.SHOW_LINE_NUMBERS) {
      e.setSelected(true);
    }

    MParameter parameter = modelService.createModelElement(MParameter.class);
    parameter.setName("feature");
    parameter.setValue(f.name());

    e.getParameters().add(parameter);
    application
        .getCommands()
        .stream()
        .filter(
            c -> c.getElementId().equals("at.bestsolution.dart.app.command.toggleeditorfeature"))
        .findFirst()
        .ifPresent(e::setCommand);
    itemMap.put(f, e);

    return e;
  }
  @SuppressWarnings("restriction")
  @Execute
  public void execute(
      MApplication app, EModelService service, IExtensionRegistry registery, IThemeManager mgr) {

    // sanity check
    if (menu == null) {
      return;
    }

    List<String> tags = app.getTags();
    for (String tag : tags) {
      if (PROCESSOR_ID.equals(tag)) {
        return; // already processed
      }
    }

    tags.add(PROCESSOR_ID);

    IThemeEngine engine = mgr.getEngineForDisplay(Display.getCurrent());

    List<ITheme> themes = engine.getThemes();

    MCommand switchThemeCommand = ThemeHelper.findCommand(app);

    // no themes or command, stop processing
    if (themes.size() <= 0 || switchThemeCommand == null) {
      return;
    }

    themesMenu = service.createModelElement(MMenu.class);
    themesMenu.setLabel("%switchThemeMenu"); // $NON-NLS-1$
    themesMenu.setContributorURI(BUNDLE_ID);

    for (ITheme theme : themes) {
      if (!theme.getId().startsWith("org.eclipse.e4.demo.contacts.")) {
        return;
      }
      MParameter parameter = service.createModelElement(MParameter.class);
      parameter.setName("contacts.commands.switchtheme.themeid"); // $NON-NLS-1$
      parameter.setValue(theme.getId());
      String iconURI = ThemeHelper.getCSSUri(theme.getId(), registery);
      if (iconURI != null) {
        iconURI = iconURI.replace(".css", ".png");
      }
      processTheme(theme.getLabel(), switchThemeCommand, parameter, iconURI, service);
    }
    menu.getChildren().add(themesMenu);
  }
 public static ParameterizedCommand generateParameterizedCommand(
     final MHandledItem item, final IEclipseContext lclContext) {
   ECommandService cmdService = (ECommandService) lclContext.get(ECommandService.class.getName());
   Map<String, Object> parameters = null;
   List<MParameter> modelParms = item.getParameters();
   if (modelParms != null && !modelParms.isEmpty()) {
     parameters = new HashMap<String, Object>();
     for (MParameter mParm : modelParms) {
       parameters.put(mParm.getName(), mParm.getValue());
     }
   }
   ParameterizedCommand cmd =
       cmdService.createCommand(item.getCommand().getElementId(), parameters);
   item.setWbCommand(cmd);
   return cmd;
 }