public static void movepositions(
      final SWTGefBot bot,
      SWTBotGefEditor gmfEditor,
      final String sourcelane,
      final String destlane,
      final String element,
      final int j,
      final int i) {

    final SWTBotEditor botEditor = bot.activeEditor();
    gmfEditor = bot.gefEditor(botEditor.getTitle());

    final SWTBotGefEditPart lane2 = gmfEditor.getEditPart(sourcelane);
    lane2.parent().select().resize(PositionConstants.NORTH, 100, 150);

    // compute target destination
    final SWTBotGefEditPart lane3 = gmfEditor.getEditPart(destlane);

    // move step2 to lane2

    final SWTBotGefEditPart ele = gmfEditor.getEditPart(element).parent();
    ele.select();

    // move step2 to lane2

    SWTBotGefEditPart step = gmfEditor.getEditPart(element).parent();
    step.select();

    IFigure figure = ((GraphicalEditPart) step.part()).getFigure();
    final Rectangle dest = figure.getBounds().getCopy();
    figure.translateToAbsolute(dest);

    gmfEditor.drag(step, dest.x + j, dest.y + i);

    step = gmfEditor.getEditPart(element).parent();
    step.select();
    figure = ((GraphicalEditPart) step.part()).getFigure();
    final Rectangle targetdest = figure.getBounds().getCopy();
    figure.translateToAbsolute(targetdest);

    Assert.assertTrue("Move has failed", !targetdest.equals(dest));

    bot.waitUntil(
        new ICondition() {
          @Override
          public boolean test() throws Exception {
            return getPartRecursively(lane3.parent(), element) != null;
          }

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

          @Override
          public String getFailureMessage() {
            System.out.println(element + "is not in sourcelane");
            return "element is not in sourcelane (unable to move the step)";
          }
        });
  }
  @Test
  public void testConditionExpressions() throws IOException, InterruptedException {

    SWTBotTestUtil.importProcessWIthPathFromClass(
        bot,
        "TestDecisionTable-1.0.bos",
        SWTBotTestUtil.IMPORTER_TITLE_BONITA,
        "TestDecisionTable",
        getClass(),
        false);

    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    gmfEditor.getEditPart("sf1").click();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "General");

    bot.radio(useDecisionTable).click();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(editDecisionTable)));
    bot.button(editDecisionTable).click();

    bot.waitUntil(Conditions.shellIsActive(Messages.wizardPageTitle));
    bot.waitUntil(Conditions.widgetIsEnabled(bot.link("<A>" + Messages.addRow + "</A>")));

    bot.link("<A>" + Messages.addRow + "</A>").click(Messages.addRow);

    bot.waitUntil(Conditions.widgetIsEnabled(bot.link("<A>" + Messages.addCondition + "</A>")));
    addTrueCondition(0, "true");
    addTrueCondition(1, "1==2");
    addFalseCondition(2, "sdkgjskrg");

    changeCondition(2, "myBoolean");
    testUpdateLineButtonEnabled();
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_ERASEBUTTON, 0).click();
    bot.sleep(1000);
    testUpdateLineButtonNotEnabled();

    changeCondition(0, "myText==\"\"");
    testUpdateLineButtonEnabled();
    bot.button(Messages.updateLine).click();
    bot.button(IDialogConstants.FINISH_LABEL);
    SWTBotTestUtil.waitUntilBonitaBPmShellIsActive(bot);
    bot.saveAllEditors();
  }
  private static SWTBotEditor checkActiveEditorTitle(SWTBotExt bot, String expectedOpenedFileName) {

    SWTBotEditor activeEditor = null;
    try {
      bot.waitUntil(
          new ActiveEditorHasTitleCondition(bot, expectedOpenedFileName), Timing.time10S());
      activeEditor = bot.activeEditor();
    } catch (TimeoutException toe) {
      activeEditor = bot.activeEditor();
      fail(
          "Opened file has to have title "
              + expectedOpenedFileName
              + " but has "
              + activeEditor.getTitle());
    }

    return activeEditor;
  }
 /** @return */
 protected SWTBotGefEditor getGefEditor() {
   SWTBotEditor activeEditor = bot.activeEditor();
   String title = activeEditor.getTitle();
   SWTBotGefEditor ed = bot.gefEditor(title);
   return ed;
 }
  @Test
  public void testServerBuild() {

    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor activeEditor = bot.activeEditor();
    final String editorTitle = activeEditor.getTitle();
    // System.out.println("editorTitle1 = "+editorTitle1);
    assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty());

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();
    new BotGefProcessDiagramEditor(bot).selectElement("Step1");
    new BotExecutionDiagramPropertiesView(bot).selectFormTab().selectLegacy();

    // get the GEF editor to activate tools
    final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle);

    // Create 2 Pools
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 500);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 800);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    // Save Diagram
    bot.menu("Diagram").menu("Save").click();

    // System.out.println(editorTitle);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Server")));

    // Menu Server > Build...
    bot.menu("Server").menu("Build...").click();

    // shell 'Build'
    final SWTBotShell shell = bot.shell(Messages.buildTitle);
    bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle));

    // select and check created Diagram in the Tree
    final SWTBotTree tree = bot.treeWithLabel("Select processes to export");
    final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle);

    // check the diagram to export
    diagramTreeItem.select().check();
    diagramTreeItem.expand();

    // Number of pool in the diagram
    final int poolListSize = diagramTreeItem.getItems().length;
    // System.out.println("Diagram contains "+ poolListSize + " items");
    assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize);

    // unselect the first pool of the list

    diagramTreeItem.getNode(0).select();
    diagramTreeItem.getNode(0).uncheck();

    final Vector<String> poolTitleList = new Vector<String>(3);
    final int poolTitleListSize = poolTitleList.size();

    // check the selected pools
    for (int i = 1; i < poolTitleListSize; i++) {
      final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i);
      poolTitleList.set(i, poolTreeItem.getText());
      final String poolName = getItemName(poolTitleList.get(i));

      // test the good pool is checked
      assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked());
      assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i));
    }
    // create tmp directory to write diagrams
    final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar");
    tmpBarFolder.mkdirs();
    // set the path where files are saved
    final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath();
    bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath);
    //		String tmpBarFolderPath = bot.comboBoxWithLabel(Messages.destinationPath+" *").getText();
    //		System.out.println("tmpBarFolder = "+tmpBarFolderPath);

    // click 'Finish' button to close 'Build' shell
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    //  click 'OK' button to close 'Export' shell
    bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

    // wait the shell to close before checking creation of files
    bot.waitUntil(Conditions.shellCloses(shell));

    // check pools files exist
    for (int i = 1; i < poolTitleListSize; i++) {
      final String tmpPoolTitle = poolTitleList.get(i);
      final String poolFileName =
          getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar";
      final File poolFile = new File(tmpBarFolderPath, poolFileName);

      assertTrue("Error: The Pool export must exist", poolFile.exists());
      assertTrue("Error: The Pool export must be a file", poolFile.isFile());
    }
  }