private void addNewCreationToolToVSM() {
    final SWTBotEditor activeEditor = bot.activeEditor();
    activeEditor.setFocus();

    Group group =
        syncExec(
            new Result<Group>() {
              @Override
              public Group run() {
                SWTBotTree tree = activeEditor.bot().tree();
                SWTBotTreeItem[] allItems = tree.getAllItems();
                Resource vsmResource = (Resource) allItems[0].widget.getData();
                return (Group) vsmResource.getContents().get(0);
              }
            });

    final TableDescription tableDesc =
        (TableDescription) group.getOwnedViewpoints().get(0).getOwnedRepresentations().get(0);

    // Add Mock Creation Line tool
    final CreateLineTool tool = DescriptionFactory.eINSTANCE.createCreateLineTool();
    tool.setMapping(tableDesc.getAllLineMappings().get(0));
    tool.setName(CREATION_TOOL);

    // Add change context
    ChangeContext changeContext = ToolFactory.eINSTANCE.createChangeContext();
    changeContext.setBrowseExpression("var:container");
    tool.setFirstModelOperation(changeContext);

    // A complete tool is not needed : it must contains a model operation.
    EditingDomain ed = AdapterFactoryEditingDomain.getEditingDomainFor(tableDesc);
    ed.getCommandStack()
        .execute(
            new AbstractCommand() {

              @Override
              public void execute() {
                tableDesc.getOwnedCreateLine().add(tool);
              }

              @Override
              public boolean canExecute() {
                return true;
              }

              @Override
              public void redo() {}
            });
    assertTrue("Tool creation should have modified the VSM.", activeEditor.isDirty());
    activeEditor.save();
  }
Пример #2
0
  /**
   * Create a new Form and save it
   *
   * @param bot
   * @param gmfEditor
   * @param nameOfStepOnwhichCreateTheForm
   * @return
   */
  public static SWTBotEditor createFormWhenOnAProcessWithStep1(
      final SWTGefBot bot,
      final SWTBotGefEditor gmfEditor,
      final String nameOfStepOnwhichCreateTheForm) {
    final SWTBotGefEditPart part = gmfEditor.getEditPart(nameOfStepOnwhichCreateTheForm);
    if (part != null) {
      System.out.println("wow part is not null" + part.toString());
    } else {
      System.out.println("part is null");
    }

    try {
      System.out.println(
          "tosting is:"
              + part.toString()
              + "source size is:"
              + part.sourceConnections().size()
              + "target size is:"
              + part.targetConnections().size()
              + "parent"
              + part.parent().toString());
    } catch (final Exception e) {
      System.out.println("Exception is:" + e.getMessage());
    }

    part.click();

    // part.focus();

    bot.viewById("org.bonitasoft.studio.views.properties.application").show();
    bot.viewById("org.bonitasoft.studio.views.properties.application").setFocus();

    SWTBotTestUtil.selectTabbedPropertyView(bot, "Pageflow");
    final SWTBotView properties = bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_APPLICATION);
    properties.bot().button("Add...").click();
    bot.waitUntil(Conditions.shellIsActive("Add form..."));
    bot.button(IDialogConstants.NEXT_LABEL).click();

    bot.button("Unselect all").click();

    bot.button(IDialogConstants.FINISH_LABEL).click();
    final SWTBotEditor activeEditor = bot.activeEditor();
    activeEditor.save();
    return activeEditor;
  }
  /**
   * Save all editors
   *
   * @param bot
   */
  public static void save(final SWTBotEditor editor) {
    editor
        .bot()
        .waitUntil(
            new DefaultCondition() {

              @Override
              public boolean test() throws Exception {
                return editor.isDirty();
              }

              @Override
              public String getFailureMessage() {
                return "Editor never dirty";
              }
            },
            10000,
            1000);
    editor.save();
    editor
        .bot()
        .waitUntil(
            new DefaultCondition() {

              @Override
              public boolean test() throws Exception {
                return !editor.isDirty();
              }

              @Override
              public String getFailureMessage() {
                return "Editor still dirty";
              }
            },
            10000,
            1000);
  }