@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);
  }