Example usage for org.eclipse.jface.dialogs IDialogConstants FINISH_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants FINISH_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants FINISH_LABEL.

Prototype

String FINISH_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants FINISH_LABEL.

Click Source Link

Document

The label for finish buttons.

Usage

From source file:org.bonitasoft.studio.data.ui.wizard.DataWizardDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    if (dataSection != null) {
        createAndNewButton = super.createButton(parent, CREATE_AND_NEW_ID, Messages.createAndNewButton, true);
        setButtonLayoutData(createAndNewButton);
    }/*  ww w .j  av a  2  s.c  om*/
    Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
    cancelButton.setText(IDialogConstants.CANCEL_LABEL);
    Button finishButton = getButton(IDialogConstants.FINISH_ID);

    cancelButton.moveBelow(null);
    if (dataSection != null) {
        createAndNewButton.moveAbove(cancelButton);
        finishButton.setText(IDialogConstants.FINISH_LABEL);
    } else {
        finishButton.setText(IDialogConstants.OK_LABEL);

    }
    finishButton.moveAbove(createAndNewButton);
}

From source file:org.bonitasoft.studio.diagram.test.DiagramTests.java

License:Open Source License

/** Create & run a 4 tasks process
 * @author Florine Boudin//www  .j a  v  a 2  s.c o  m
 * @throws Exception
 */
@Test
public void test4TasksDiagram() throws Exception {

    // create a new process
    SWTBotTestUtil.createNewDiagram(bot);

    //Create 3 variables
    SWTBotEditor botEditor = bot.activeEditor();
    SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());
    gmfEditor.click(200, 200);

    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");

    // Create 3 new variables
    setNewVariable("varText", "Text", false);
    setNewVariable("varBoolean", "Boolean", false);
    setNewVariable("varInteger", "Integer", false);

    // check 3 variables where created
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");

    // check the table has 3 variables
    SWTBotTable table = bot.table(0);
    Assert.assertEquals("Error: wrong number of variable created", 3, table.rowCount());

    final Vector<String> taskNameList = new Vector<String>(
            Arrays.asList(new String[] { "Step1", "Step2", "Step3", "Step4" }));
    // Create 3 human tasks
    int i = 400;
    for (String taskName : taskNameList) {

        setTaskAsHuman(gmfEditor, taskName);

        if (taskName != "Step4") {
            // create new Task
            System.out.println("s = " + taskName);
            Assert.assertNotNull("Error: No " + taskName + " task found.", gmfEditor.getEditPart(taskName));
            SWTBotTestUtil.selectTaskFromSelectedElementAndDragIt(gmfEditor, taskName, new Point(i, 110));
            i += 200;
        }

    }
    bot.menu("Diagram").menu("Save");

    // check the gmfEditor has 4 human tasks
    IGraphicalEditPart ig = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    MainProcess mp = (MainProcess) ig.resolveSemanticElement();

    int nbHumanTasks = ModelHelper.getAllItemsOfType(mp, ProcessPackage.Literals.TASK).size();
    Assert.assertEquals("Error: wrong number of tasks in the process.", 4, nbHumanTasks);

    int nbTransistions = ModelHelper.getAllItemsOfType(mp, ProcessPackage.Literals.CONNECTION).size();
    Assert.assertEquals("Error: wrong number of connections in the process.", 4, nbTransistions);

    // For the 3 first tasks, add a form
    int itmp = 0;
    // create a form
    for (String nametask : taskNameList) {

        if (nametask != "Step4") {
            //System.out.println("s = "+s);
            gmfEditor.getEditPart(nametask).click();
            bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_APPLICATION).show();
            SWTBotTestUtil.selectTabbedPropertyView(bot, PAGEFLOW_LABEL);

            // add a form
            bot.button(addForm, 0).click();
            // first shell "Add form..."
            bot.waitUntil(Conditions.shellIsActive(addFormTitle));

            if (SWTBotTestUtil.testingBosSp()) {
                //second shell "Add form..."
                List<Button> buttons = bot.getFinder().findControls(new BaseMatcher<Button>() {

                    public void describeTo(Description description) {

                    }

                    public boolean matches(Object item) {
                        if (item instanceof Button) {
                            return IDialogConstants.NEXT_LABEL.equals(((Button) item).getText());
                        }
                        return false;
                    }

                });
                if (!buttons.isEmpty()) {
                    SWTBotButton nextButton = bot.button(IDialogConstants.NEXT_LABEL);
                    if (nextButton != null) {
                        nextButton.click();
                    }
                }
            }

            // remove 2 of 3 variables in the form
            for (int j = 0; j < 3; j++) {
                if (j != itmp) {
                    bot.checkBox(j).deselect();
                }
            }
            // last shell "Add form..."
            bot.button(IDialogConstants.FINISH_LABEL).click();

            // add script to conver to an integer on "Step3"
            if (nametask.equals("Step2")) {
                SWTBotGefEditor formEditor = bot.gefEditor(bot.activeEditor().getTitle());
                formEditor.getEditPart("Var Integer").click();
                bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_FORM_GENERAL).show();
                SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");
                bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click();
                String valueOf = "Integer.valueOf(field_varInteger1)";
                SWTBotTestUtil.setScriptExpression(bot, "theInteger", valueOf, Integer.class.getName());
                bot.waitUntil(new ICondition() {

                    public boolean test() throws Exception {
                        return bot.textWithId(ExpressionViewer.SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 2).getText()
                                .equals("theInteger");
                    }

                    public void init(SWTBot bot) {

                    }

                    public String getFailureMessage() {
                        return "Expression not set properly";
                    }
                });
            }

            bot.activeEditor().saveAndClose();
            itmp++;
        }
    }

    // Create the form for the 4th task
    gmfEditor.getEditPart("Step4").click();

    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_APPLICATION).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, PAGEFLOW_LABEL);

    bot.button(addForm, 0).click();

    // first shell "Add form..."
    bot.waitUntil(Conditions.shellIsActive(addFormTitle));

    if (SWTBotTestUtil.testingBosSp()) {
        //second shell "Add form..."
        bot.button(IDialogConstants.NEXT_LABEL).click();
    }

    // last shell "Add form..."
    bot.button(IDialogConstants.FINISH_LABEL).click();

    SWTBotGefEditor formEditor = bot.gefEditor(bot.activeEditor().getTitle());

    final String[] varTab = new String[] { "Var Text", "Var Boolean", "Var Integer" };
    for (String s : varTab) {

        formEditor.getEditPart(s).click();
        bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_FORM_GENERAL).show();
        SWTBotTestUtil.selectTabbedPropertyView(bot, "General");

        // "Field type"
        bot.comboBoxWithLabel(formFieldType).setSelection("Text");
        bot.activeEditor().save();
    }

    bot.activeEditor().saveAndClose();
    IStatus status = SWTBotTestUtil.selectAndRunFirstPoolFound(bot);
    assertTrue(status.getMessage(), status.isOK());

}

From source file:org.bonitasoft.studio.diagram.test.DiagramTests.java

License:Open Source License

/** Add and set a new variable in the data entry of the General tab of a Task
 * @param varName name of the variable/*from   ww w  .j  av  a  2  s.  co  m*/
 * @param varType type of the variable : "Text", "Integer", "String", "Boolean", etc...
 * @param autoGenerateForm  BOS-SP only : true if the checkBox must be selected, else false
 */
private void setNewVariable(String varName, String varType, boolean autoGenerateForm) {
    bot.button("Add...").click();

    // open shell "New variable"
    bot.waitUntil(Conditions.shellIsActive(newVariable));

    // "Name"
    bot.textWithLabel(DATA_NAME_LABEL).setText(varName);

    // "Data type"
    bot.comboBoxWithLabel(datatypeLabel).setSelection(varType);

    if (SWTBotTestUtil.testingBosSp()) {
        SWTBotCheckBox cb = bot.checkBox("Auto-generate form");
        if (cb.isChecked() && !autoGenerateForm) {
            cb.deselect();
        } else if (!cb.isChecked() && autoGenerateForm) {
            cb.select();
        }
    }

    bot.button(IDialogConstants.FINISH_LABEL).click();
}

From source file:org.bonitasoft.studio.engine.test.bar.BarExporterTest.java

License:Open Source License

@Test
public void testServerBuild() {

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

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

    // Create 2 Pools
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 500);//from   w w  w . j  av  a  2 s.  co  m
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 800);

    // 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
    SWTBotTree tree = bot.treeWithLabel("Select processes to export");
    SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle);

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

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

    // unselect the first pool of the list

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

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

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

        // test the good pool is checked
        Assert.assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked());
        Assert.assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i));
    }
    // create tmp directory to write diagrams
    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(Conditions.shellIsActive(Messages.exportSuccessTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

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

    // check directory exists
    String diagramDir1 = getItemName(editorTitle) + "--" + getItemVersion(editorTitle);
    //System.out.println("diagramDir1 = "+diagramDir1);

    // check pools files exist
    for (int i = 1; i < poolTitleListSize; i++) {
        String tmpPoolTitle = poolTitleList.get(i);
        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());
    }
}

From source file:org.bonitasoft.studio.properties.test.TestDecisionTable.java

License:Open Source License

@Test
public void testConditionExpressions() throws IOException, InterruptedException {

    SWTBotTestUtil.importProcessWIthPathFromClass(bot, "TestDecisionTable-1.0.bos", "Bonita 6.x",
            "TestDecisionTable", getClass(), false);

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

    gmfEditor.getEditPart("sf1").click();

    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();/*ww w  .  ja va2  s.co m*/
    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);

    bot.saveAllEditors();

}

From source file:org.bonitasoft.studio.properties.test.TestMultiInstantiation.java

License:Open Source License

/** Test the Cardinality case of multiInstance Task
 * @throws ExecutionException//w ww  . j a  v a2 s . c  o m
 * 
 */
@Test
public void testMultiInstanceCardinality() throws ExecutionException {

    // create Diagram
    SWTBotTestUtil.createNewDiagram(bot);
    SWTBotEditor botEditor = bot.activeEditor();
    SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    AbstractProcess proc = ModelHelper.getParentProcess(
            ((IGraphicalEditPart) gmfEditor.getEditPart("Step1").part()).resolveSemanticElement());
    gmfEditor.getEditPart(proc.getName()).click();

    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();

    // DATA
    addIntegerData("nbTicketsAvailable", "20");

    SWTBotTestUtil.selectInitiatorinActor(bot, defaultEmployeeActor);

    gmfEditor.getEditPart("Step1").click();

    SWTBotView propertyBot = bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL);
    propertyBot.show();
    propertyBot.setFocus();

    SWTBotTestUtil.selectActorInHumanTask(bot, defaultEmployeeActor + " -- " + defaultEmployeeActorDefinition);

    // MULTI-INSTANCIATION PROPERTIES
    SWTBotTestUtil.selectTabbedPropertyView(bot, loopMultiInstanceSection);

    // select the multi-instantiate radio button
    bot.radio(Messages.isMultiInstantiated).click();

    // set the cardinality
    bot.radio(Messages.multiInstance_useCardinality).click();
    bot.text(1).setText("15");

    // set completion condition
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click();

    setScriptBooleanExpression("isThereTickets", "nbTicketsAvailable==0");

    // Set local variable of the number of tickets asked
    // MULTI-INSTANCIATION PROPERTIES

    addIntegerData("nbTickets", "0");

    // FILL THE FORM
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_APPLICATION).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, PAGEFLOW_LABEL);

    // Add a new Form
    bot.button("Add...").click();
    bot.waitUntil(Conditions.shellIsActive(addFormTitle));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    gmfEditor = bot.gefEditor("Step1");

    // configure the nbTicketsAvailable widget to a Message field
    setWidgetProperties(gmfEditor, "Nb Tickets Available", null, "Message", null, 0, null, null);
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "nbTicketsAvailable",
            "\"Only \"+nbTicketsAvailable+\" tickets available.\"", "java.lang.String");

    // configure the nbTickets widget to a text field
    setWidgetProperties(gmfEditor, "Nb Tickets", "Nbr de Tickets  reserver", "Text field", "0", 1,
            "nbTickets", "java.lang.Integer");
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click();
    SWTBotTestUtil.setScriptExpression(bot, "nbTickets", "Integer.valueOf(field_nbTickets1)",
            "java.lang.Integer");

    // Save the form
    bot.saveAllEditors();
    IStatus status = SWTBotTestUtil.selectAndRunFirstPoolFound(bot);
    assertTrue(status.getMessage(), status.isOK());
}

From source file:org.bonitasoft.studio.properties.test.TestMultiInstantiation.java

License:Open Source License

/** Test the Collection case of multiInstance Task
 * //w  w w .  j av  a  2 s  . c om
 */
@Test
public void testMultiInstanceCollection() {

    // create Diagram
    SWTBotTestUtil.createNewDiagram(bot);
    SWTBotEditor botEditor = bot.activeEditor();
    SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    // get the pool
    AbstractProcess proc = ModelHelper.getParentProcess(
            ((IGraphicalEditPart) gmfEditor.getEditPart("Step1").part()).resolveSemanticElement());
    gmfEditor.getEditPart(proc.getName()).click();

    // set the actor
    SWTBotTestUtil.selectInitiatorinActor(bot, defaultEmployeeActor);

    // Add a new Data java.util.List type to add a user list
    addIntegerData("nbTicketsAvailable", "20");

    addJavaObjectData("vip", null, "java.util.List");
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "vipScript", "[\"Armelle\",\"Ben\",\"Cedric\",\"Damien\"]",
            "java.util.List");
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    addJavaObjectData("alreadyVip", null, "java.util.List");
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "alreadyVipScript", "[null]", "java.util.List");
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.button(IDialogConstants.FINISH_LABEL).click();

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

    // Add MultiInstance on The human Task
    gmfEditor.getEditPart("Step1").click();

    SWTBotView propertyBot = bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL);
    propertyBot.show();
    propertyBot.setFocus();

    // Add a Integer Data in the Human Task
    addIntegerData("nbTickets", "0");

    // Add a Text Data in the Human Task
    addTextData("vipName", "");

    // Set properties of Multi-Instance
    propertyBot.show();
    propertyBot.setFocus();

    SWTBotTestUtil.selectActorInHumanTask(bot, defaultEmployeeActor + " -- " + defaultEmployeeActorDefinition);

    bot.menu("Diagram").menu("Save").click();
    SWTBotTestUtil.selectTabbedPropertyView(bot, loopMultiInstanceSection);

    // select the multi-instantiate radio buton
    bot.radio(Messages.isMultiInstantiated).click();

    bot.radio(Messages.multiInstance_useCollection).click();

    Assert.assertTrue(bot.comboBox(0).isEnabled());
    bot.comboBox(0).setSelection("vip -- java.util.List");
    bot.sleep(500);
    // set Input Data
    bot.comboBoxWithLabel(Messages.multiInstance_inputData).setSelection("vipName -- Text");
    // set ouput data
    bot.comboBoxWithLabel(Messages.multiInstance_outputData).setSelection("vipName -- Text");
    // set output results
    bot.comboBoxWithLabel(Messages.multiInstance_listOutputDataLabel)
            .setSelection("alreadyVip -- java.util.List");

    // Edit the Completion condition

    // check the button to edit completion condition exists
    Assert.assertTrue(bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).isEnabled());
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 1).click();

    setScriptBooleanExpression("isOK", "(vip.isEmpty())||(nbTicketsAvailable==0)");

    // Add operation to update the number of available tickets
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Operations");
    bot.button("Add").click();

    SWTBotTestUtil.setOutputStorageExpressionByName(bot, "vip", "java.util.List", 0);
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    String expressionScript = "List vipList = new ArrayList(vip)\nvipList.remove(vipName)\nreturn vipList";
    SWTBotTestUtil.setScriptExpression(bot, "removeUser", expressionScript, "java.util.List");

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

}

From source file:org.bonitasoft.studio.properties.test.TestMultiInstantiation.java

License:Open Source License

/** Test the erase possibility in comboBox in Collection case of MultiInstance
 * /*w w w .j  av a  2 s. c  om*/
 */
@Test
public void testMultiInstanceEraseButton() {

    // create Diagram
    SWTBotTestUtil.createNewDiagram(bot);
    SWTBotEditor botEditor = bot.activeEditor();
    SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    // get the pool
    AbstractProcess proc = ModelHelper.getParentProcess(
            ((IGraphicalEditPart) gmfEditor.getEditPart("Step1").part()).resolveSemanticElement());
    gmfEditor.getEditPart(proc.getName()).click();

    addJavaObjectData("vip", null, "java.util.List");
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "vipScript", "[\"Armelle\",\"Ben\",\"Cedric\",\"Damien\"]",
            "java.util.List");
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.button(IDialogConstants.FINISH_LABEL).click();

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

    // Add MultiInstance on The human Task
    gmfEditor.getEditPart("Step1").click();

    SWTBotView propertyBot = bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL);
    propertyBot.show();
    propertyBot.setFocus();

    // Add a Text Data in the Human Task
    addTextData("vipName", "");

    // Set properties of Multi-Instance
    propertyBot.show();
    propertyBot.setFocus();

    bot.menu("Diagram").menu("Save").click();
    SWTBotTestUtil.selectTabbedPropertyView(bot, loopMultiInstanceSection);
    bot.sleep(2000);
    // select the multi-instantiate radio buton
    bot.radio(Messages.isMultiInstantiated).click();

    bot.radio(Messages.multiInstance_useCollection).click();

    // set collection
    Assert.assertTrue(bot.comboBox(0).isEnabled());
    bot.comboBox(0).setSelection("vip -- java.util.List");
    // set Input Data
    bot.comboBoxWithLabel(Messages.multiInstance_inputData).setSelection("vipName -- Text");
    // set ouput data
    bot.comboBoxWithLabel(Messages.multiInstance_outputData).setSelection("vipName -- Text");
    // set output results
    bot.comboBoxWithLabel(Messages.multiInstance_listOutputDataLabel).setSelection("vip -- java.util.List");

    // erase collection
    Assert.assertTrue(bot.toolbarButtonWithTooltip(Messages.clearSelection, 0).isEnabled());
    bot.toolbarButtonWithTooltip(Messages.clearSelection, 0).click();
    Assert.assertTrue("Error: Collection is not erased !", bot.comboBox(0).getText().isEmpty());

    // erase input data
    Assert.assertTrue(bot.toolbarButtonWithTooltip(Messages.clearSelection, 1).isEnabled());
    bot.toolbarButtonWithTooltip(Messages.clearSelection, 1).click();
    Assert.assertTrue("Error: Input Data is not erased !", bot.comboBox(1).getText().isEmpty());

    // erase ouput Data
    Assert.assertTrue(bot.toolbarButtonWithTooltip(Messages.clearSelection, 2).isEnabled());
    bot.toolbarButtonWithTooltip(Messages.clearSelection, 2).click();
    Assert.assertTrue("Error: Output Data is not erased !", bot.comboBox(2).getText().isEmpty());

    // erase output Collection
    Assert.assertTrue(bot.toolbarButtonWithTooltip(Messages.clearSelection, 3).isEnabled());
    bot.toolbarButtonWithTooltip(Messages.clearSelection, 3).click();
    Assert.assertTrue("Error: Output Collection is not erased !", bot.comboBox(3).getText().isEmpty());

    bot.menu("Diagram").menu("Save").click();
    bot.menu("Diagram").menu("Close").click();
}

From source file:org.bonitasoft.studio.properties.test.TestMultiInstantiation.java

License:Open Source License

/** Test the erase possibility in comboBox in Collection case of MultiInstance
 * //from w  w w . j a  v a 2s  .  c  o m
 */
@Test
public void testMultiInstanceUpdateComboBoxAfterDataRemoved() {

    // create Diagram
    SWTBotTestUtil.createNewDiagram(bot);
    SWTBotEditor botEditor = bot.activeEditor();
    SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    // get the pool
    final SWTBotGefEditPart editPart = gmfEditor.getEditPart("Step1");
    AbstractProcess proc = ModelHelper
            .getParentProcess(((IGraphicalEditPart) editPart.part()).resolveSemanticElement());
    gmfEditor.getEditPart(proc.getName()).click();

    addJavaObjectData("vip", null, "java.util.List");
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "vipScript", "[\"Armelle\",\"Ben\",\"Cedric\",\"Damien\"]",
            "java.util.List");
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    addJavaObjectData("vip2", null, "java.util.List");
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();
    SWTBotTestUtil.setScriptExpression(bot, "vip2Script", "[\"A\",\"B\",\"C\",\"D\"]", "java.util.List");
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.button(IDialogConstants.FINISH_LABEL).click();

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

    // Add MultiInstance on The human Task
    editPart.click();
    IGraphicalEditPart ep = (IGraphicalEditPart) editPart.part();
    Task task = (Task) ep.resolveSemanticElement();

    SWTBotView propertyBot = bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL);
    propertyBot.show();
    propertyBot.setFocus();

    // Add a Text Data in the Human Task
    addTextData("vipName", "");

    // Add a Text Data in the Human Task
    addIntegerData("nbTickets", "0");

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

    // Set properties of Multi-Instance
    propertyBot.show();
    propertyBot.setFocus();

    SWTBotTestUtil.selectTabbedPropertyView(bot, loopMultiInstanceSection);
    bot.sleep(2000);
    // select the multi-instantiate radio buton
    bot.radio(Messages.isMultiInstantiated).click();

    bot.radio(Messages.multiInstance_useCollection).click();

    // set collection
    Assert.assertTrue(bot.comboBox(0).isEnabled());
    bot.comboBox(0).setSelection("vip -- java.util.List");
    // set Input Data
    bot.comboBoxWithLabel(Messages.multiInstance_inputData).setSelection("vipName -- Text");
    // set ouput data
    bot.comboBoxWithLabel(Messages.multiInstance_outputData).setSelection("vipName -- Text");
    // set output results
    bot.comboBoxWithLabel(Messages.multiInstance_listOutputDataLabel).setSelection("vip -- java.util.List");

    // Check references of input collection, input data, outputdata and output result exist
    assertNotNull("Error: Input Collection used in the MultiInstantiation is not referenced in the Model.",
            task.getMultiInstantiation().getCollectionDataToMultiInstantiate());
    assertNotNull("Error: Input Data used in the MultiInstantiation is not referenced in the Model.",
            task.getMultiInstantiation().getInputData());
    assertNotNull("Error: Output Data used in the MultiInstantiation is not referenced in the Model.",
            task.getMultiInstantiation().getOutputData());
    assertNotNull("Error: Output Result used in the MultiInstantiation is not referenced in the Model.",
            task.getMultiInstantiation().getListDataContainingOutputResults());

    // remove vip collection and vipName Text
    gmfEditor.getEditPart(proc.getName()).click();
    bot.sleep(2000);
    propertyBot.show();
    propertyBot.setFocus();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");
    SWTBotTable table = bot.table();
    table.select("vip -- java.util.List -- Default value: vipScript");
    bot.button("Remove").click();
    bot.waitUntil(Conditions.shellIsActive(deleteDataDialogTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

    // Check empty comboBox in MultiInstance
    editPart.click();
    bot.sleep(2000);
    propertyBot.show();
    propertyBot.setFocus();
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");
    table = bot.table();
    table.select("vipName -- Text");
    bot.button("Remove").click();
    bot.waitUntil(Conditions.shellIsActive(deleteDataDialogTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

    assertNull(
            "Error: Input Collection is still referenced in the MultiInstantiation Model after being removed.",
            task.getMultiInstantiation().getCollectionDataToMultiInstantiate());
    assertNull("Error: Input Data is still referenced in the MultiInstantiation Model after being removed.",
            task.getMultiInstantiation().getInputData());
    assertNull("Error: Output Data is still referenced in the MultiInstantiation Model after being removed.",
            task.getMultiInstantiation().getOutputData());
    assertNull("Error: Output Result is still referenced in the MultiInstantiation Model after being removed.",
            task.getMultiInstantiation().getListDataContainingOutputResults());

    SWTBotTestUtil.selectTabbedPropertyView(bot, loopMultiInstanceSection);
    bot.sleep(2000);
    // check Collection empty
    Assert.assertTrue("Error: Collection is not empty !", bot.comboBox(0).getText().isEmpty());

    // check input data empty
    Assert.assertTrue("Error: Input Data is not empty !", bot.comboBox(1).getText().isEmpty());

    // check ouput Data empty
    Assert.assertTrue("Error: Output Data is not empty !", bot.comboBox(2).getText().isEmpty());

    // check output Collection empty
    Assert.assertTrue("Error: Output Collection is not empty !", bot.comboBox(3).getText().isEmpty());

    bot.menu("Diagram").menu("Save").click();
    bot.menu("Diagram").menu("Close").click();
}

From source file:org.bonitasoft.studio.properties.test.TestMultiInstantiation.java

License:Open Source License

/**
 * /*from   www. jav a2s .c  o  m*/
 * @param dataName
 * @param defaultValue
 * @param dataType
 */
public void addData(String dataName, String defaultValue, String dataType) {
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();

    // DATA
    SWTBotTestUtil.selectTabbedPropertyView(bot, "Data");

    // Add a new variable
    bot.button(addData).click();
    bot.waitUntil(Conditions.shellIsActive(newVariable));
    bot.shell(newVariable);

    // set global value
    bot.textWithLabel(DATA_NAME_LABEL).setText(dataName);
    bot.comboBoxWithLabel(datatypeLabel).setSelection(dataType);
    bot.textWithLabel(defaultValueLabel).setText(defaultValue);

    bot.button(IDialogConstants.FINISH_LABEL).click();
}