/* (non-Javadoc)
     * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
     */
    @Override
    protected IContributionItem[] getContributionItems() {
      final List<IContributionItem> res = new ArrayList<IContributionItem>();
      IRepository repository = RepositoryManager.getInstance().getCurrentRepository();
      diagramSotre =
          (DiagramRepositoryStore) repository.getRepositoryStore(DiagramRepositoryStore.class);
      try {
        for (AbstractProcess process : diagramSotre.getAllProcesses()) {
          if (process.getName().equals(subprocessName)) {
            Map<String, String> params = new HashMap<String, String>();
            params.put(OpenSpecificProcessCommand.PARAMETER_PROCESS_NAME, process.getName());
            params.put(OpenSpecificProcessCommand.PARAMETER_PROCESS_VERSION, process.getVersion());
            CommandContributionItemParameter param =
                new CommandContributionItemParameter(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
                    null,
                    OpenSpecificProcessCommand.ID,
                    CommandContributionItem.STYLE_PUSH);
            param.parameters = params;
            param.label = process.getVersion();
            param.visibleEnabled = true;
            param.commandId = OpenSpecificProcessCommand.ID;
            CommandContributionItem commandContributionItem = new CommandContributionItem(param);
            commandContributionItem.setVisible(true);
            res.add(commandContributionItem);
          }
        }

      } catch (Exception ex) {
        BonitaStudioLog.error(ex);
      }
      return res.toArray(new IContributionItem[res.size()]);
    }
  @Test
  public void testDeleteDiagrams() {

    final DiagramRepositoryStore diagramStore =
        RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);

    final int nbDiagramsInRepository = diagramStore.getChildren().size();

    final SWTBotMenu diagramMenu = bot.menu("Diagram");
    final List<String> newDiagramsName = new ArrayList<String>();
    for (int i = 0; i < nbDiagrams; i++) {
      SWTBotTestUtil.createNewDiagram(bot);
      bot.waitUntil(Conditions.widgetIsEnabled(diagramMenu), 40000);
      newDiagramsName.add(bot.activeEditor().getTitle());
    }
    assertEquals("4 diagrams should have been created", nbDiagrams, newDiagramsName.size());

    final int nbEditors = bot.editors().size();
    final String currentDiagramName = bot.activeEditor().getTitle();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Diagram")), 10000);
    bot.menu("Diagram").menu("Delete...").click();
    bot.waitUntil(Conditions.shellIsActive(Messages.DeleteDiagramWizardPage_title), 10000);

    final SWTBotTree tree = bot.tree();
    assertEquals(
        "the list of diagrams should contain 4 items",
        nbDiagramsInRepository + nbDiagrams,
        tree.getAllItems().length);

    final TableCollection selection = tree.selection();
    assertEquals(
        "only " + currentDiagramName + " should be selected in the tree viewer",
        1,
        selection.rowCount());
    assertEquals(
        "diagram " + currentDiagramName + " should be selected",
        currentDiagramName,
        selection.get(0, 0));

    //   final SWTBotTreeItem firstSwtBotTreeItem = tree.getAllItems()[1];
    //   final SWTBotTreeItem secondSwtBotTreeItem = tree.getAllItems()[2];
    //   final SWTBotTreeItem thirdSwtBotTreeItem = tree.getAllItems()[3];

    tree.select(newDiagramsName.get(1), newDiagramsName.get(2), newDiagramsName.get(3));

    bot.button(Messages.removeProcessLabel).click();

    bot.waitUntil(Conditions.shellIsActive(Messages.confirmProcessDeleteTitle));
    bot.button(IDialogConstants.YES_LABEL).click();
    bot.waitUntil(
        new ICondition() {

          @Override
          public boolean test() throws Exception {
            return nbEditors - 3 == bot.editors().size();
          }

          @Override
          public void init(final SWTBot bot) {}

          @Override
          public String getFailureMessage() {
            return "editors have not been closed after deleted diagrams";
          }
        },
        40000,
        100);

    assertEquals(
        "deleted diagrams are still in repository",
        nbDiagramsInRepository + 1,
        diagramStore.getChildren().size());
  }