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

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

Introduction

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

Prototype

String CANCEL_LABEL

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

Click Source Link

Document

The label for cancel buttons.

Usage

From source file:org.bonitasoft.studio.groovy.tests.TestBonitaGroovyEditorDialog.java

License:Open Source License

@Test
public void testOpenBonitaGroovyEditorDialog() throws ExecutionException, CoreException, IOException {
    bot.menu("Development").menu("Manage Groovy scripts...").click();
    bot.waitUntil(Conditions.shellIsActive("Manage Groovy scripts"));
    bot.tree().setFocus();//from w w w.  j a  v a2  s .  co m
    bot.button("Create...").click();
    bot.waitUntil(Conditions.shellIsActive("Create new Groovy script"));
    bot.text().setText("MyTestScript");
    bot.button(IDialogConstants.OK_LABEL).click();
    bot.tree().getTreeItem("MyTestScript").doubleClick();
    bot.waitUntil(Conditions.shellIsActive("Edit expression"));
    bot.styledText().setText("\"test me\"");
    bot.button("Evaluate").click();
    bot.waitUntil(Conditions.shellIsActive(selectMissingJarTitle));
    bot.button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(Conditions.shellIsActive("Evaluation results"), 30000);
    boolean groovyEvaluateOK = "test me".equals(bot.text().getText());
    if (!groovyEvaluateOK) {
        bot.button(IDialogConstants.CANCEL_LABEL).click();
        bot.button(IDialogConstants.OK_LABEL).click();
    }
    assertTrue("Error while evaluating groovy script", groovyEvaluateOK);
    bot.button(IDialogConstants.OK_LABEL).click();
    if (!FileActionDialog.getDisablePopup()) {
        bot.button(IDialogConstants.OK_LABEL).click();
    }
    bot.button(IDialogConstants.CANCEL_LABEL);
}

From source file:org.bonitasoft.studio.groovy.tests.TestBonitaGroovyEditorDialog.java

License:Open Source License

@After
public void closeDialog() throws Exception {
    SWTBotButton button = bot.button(IDialogConstants.CANCEL_LABEL);
    if (button.isEnabled()) {
        button.click();/*w  w  w.j  a  v  a 2s  .c o m*/
    }
    button = bot.button(IDialogConstants.CANCEL_LABEL);
    if (button.isEnabled()) {
        button.click();
    }
}

From source file:org.bonitasoft.studio.parameters.property.section.ParameterPropertySection.java

License:Open Source License

protected void createRemoveParameterButton(final Composite buttonsComposite) {
    removeButton = widgetFactory.createButton(buttonsComposite, Messages.remove, SWT.FLAT);
    removeButton.setLayoutData(GridDataFactory.fillDefaults().hint(85, SWT.DEFAULT).create());
    removeButton.addSelectionListener(new SelectionAdapter() {

        @Override//www  . j a  v a 2 s. c om
        public void widgetSelected(final SelectionEvent e) {
            final IStructuredSelection selection = (IStructuredSelection) parameterTableViewer.getSelection();
            final StringBuilder sb = new StringBuilder();
            for (final Object selectionElement : selection.toList()) {
                if (selectionElement instanceof Parameter) {
                    sb.append(((Parameter) selectionElement).getName() + "\n");
                }
            }
            if (sb.length() > 0) {
                sb.delete(sb.length() - 1, sb.length());
            }
            final String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
            final List<Object> selectionList = ((IStructuredSelection) parameterTableViewer.getSelection())
                    .toList();
            final OutlineDialog dialog = new OutlineDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    removalConfirmationDialogTitle, Display.getCurrent().getSystemImage(SWT.ICON_WARNING),
                    NLS.bind(Messages.areYouSureMessage, sb.toString()), MessageDialog.CONFIRM, buttonList, 1,
                    selectionList);
            final int ok = 0;
            if (ok == dialog.open()) {
                for (final Object parameter : selection.toList()) {
                    final RemoveParametersOperation op = new RemoveParametersOperation((Parameter) parameter,
                            (AbstractProcess) getEObject());
                    op.setEditingDomain(getEditingDomain());
                    op.setAskConfirmation(true);
                    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
                    try {
                        service.busyCursorWhile(op);
                    } catch (final InvocationTargetException ex) {
                        BonitaStudioLog.error(ex);
                    } catch (final InterruptedException ex) {
                        BonitaStudioLog.error(ex);
                    }
                }
                parameterTableViewer.refresh();
                try {
                    RepositoryManager.getInstance().getCurrentRepository().getProject().build(
                            IncrementalProjectBuilder.FULL_BUILD, XtextProjectHelper.BUILDER_ID,
                            Collections.<String, String>emptyMap(), null);
                } catch (final CoreException e1) {
                    BonitaStudioLog.error(e1, ParameterPlugin.PLUGIN_ID);
                }
            }
        }
    });

}

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

License:Open Source License

public void testCantCreateDuplicateCategory() {
    createProcessAndGotoUserXPTab();/*w w w  . j a va 2s  .c o  m*/
    final String categoryName = "categoryCantDuplicated";
    addCategory(categoryName);

    bot.button("+").click();
    bot.waitUntil(Conditions.shellIsActive(Messages.newCategory));
    bot.text().setText(categoryName);
    final boolean okEnabled = bot.button(IDialogConstants.OK_LABEL).isEnabled();
    bot.button(IDialogConstants.CANCEL_LABEL).click();
    assertFalse("We can create duplicate categories", okEnabled);
}

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

License:Open Source License

private void testUnvalidConditionExpression(String condition, String expressionType, boolean leftError,
        boolean rightError) throws OperationCanceledException, InterruptedException {
    SWTBotTestUtil.initializeComparisonExpression(bot, condition);
    Point p1 = getLeftExpressionColumnLength(condition);
    StyleRange styles = SWTBotTestUtil.getTextStyleInEditExpressionDialog(bot,
            ExpressionConstants.CONDITION_TYPE, 0, p1.x);
    if (leftError) {
        assertTrue(unvalidErrorMessage + " expression = " + condition, styles.underline);
    } else {//from   w  ww .  j  a v  a  2s  .  c  om
        assertFalse(validErrorMessage + " expression = " + condition, styles.underline);
    }
    Point p2 = getRighExpressionColumnLength(condition);
    bot.sleep(500);
    styles = SWTBotTestUtil.getTextStyleInEditExpressionDialog(bot, ExpressionConstants.CONDITION_TYPE, 0,
            p2.x);
    if (rightError) {
        assertTrue(unvalidErrorMessage + " expression = " + condition, styles.underline);
    } else {
        assertFalse(validErrorMessage + " expression = " + condition, styles.underline);
    }
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}

From source file:org.bonitasoft.studio.tests.data.DataWizardIT.java

License:Open Source License

@Test
public void testProcessDataCanBeInitializedWithProcessContractInput() throws ExecutionException {
    final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    final BotProcessDiagramPerspective diagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
    final BotGefProcessDiagramEditor activeProcessDiagramEditor = diagramPerspective
            .activeProcessDiagramEditor();
    final Pool pool = (Pool) activeProcessDiagramEditor.getSelectedSemanticElement();
    Display.getDefault().syncExec(new Runnable() {

        @Override//ww  w  .j a v a2  s . c o  m
        public void run() {
            try {
                new AbstractEMFOperation(TransactionUtil.getEditingDomain(pool),
                        "Prepare Pool with Contract Input") {

                    @Override
                    protected IStatus doExecute(final IProgressMonitor monitor, final IAdaptable info)
                            throws ExecutionException {
                        final Contract contract = ProcessFactory.eINSTANCE.createContract();
                        final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
                        contractInput.setName("input1");
                        contractInput.setType(ContractInputType.TEXT);
                        contract.getInputs().add(contractInput);
                        pool.setContract(contract);
                        return Status.OK_STATUS;
                    }
                }.execute(null, null);
            } catch (final ExecutionException e) {
                e.printStackTrace();
            }
        }
    });

    final BotDataPropertySection botDataPropertySection = diagramPerspective.getDiagramPropertiesPart()
            .selectDataTab().selectPoolDataTab();
    final BotAddDataWizardPage addData = botDataPropertySection.addData();
    addData.editDefaultValueExpression().selectContractInputType().selectContractInput("input1 -- TEXT").ok();
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}

From source file:org.bonitasoft.studio.tests.data.DataWizardIT.java

License:Open Source License

@Test
public void testTaskDataCantBeInitializedWithTaskContractInput() throws ExecutionException {
    final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    final BotProcessDiagramPerspective diagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
    final BotGefProcessDiagramEditor activeProcessDiagramEditor = diagramPerspective
            .activeProcessDiagramEditor();
    final Task task = (Task) activeProcessDiagramEditor.selectElement("Step1").getSelectedSemanticElement();
    Display.getDefault().syncExec(new Runnable() {

        @Override//from w w  w .j a  va2  s.  co  m
        public void run() {
            try {
                new AbstractEMFOperation(TransactionUtil.getEditingDomain(task),
                        "Prepare Task with Contract Input") {

                    @Override
                    protected IStatus doExecute(final IProgressMonitor monitor, final IAdaptable info)
                            throws ExecutionException {
                        final Contract contract = ProcessFactory.eINSTANCE.createContract();
                        final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
                        contractInput.setName("input1");
                        contractInput.setType(ContractInputType.TEXT);
                        contract.getInputs().add(contractInput);
                        task.setContract(contract);
                        return Status.OK_STATUS;
                    }
                }.execute(null, null);
            } catch (final ExecutionException e) {
                e.printStackTrace();
            }
        }
    });

    final BotDataPropertySection botDataPropertySection = diagramPerspective.getDiagramPropertiesPart()
            .selectDataTab().selectLocalDataTab();
    final BotAddDataWizardPage addData = botDataPropertySection.addData();
    final BotExpressionEditorDialog editDefaultValueExpression = addData.editDefaultValueExpression();
    Assertions
            .assertThat(editDefaultValueExpression.listAvailableTypes()
                    .containsItem(org.bonitasoft.studio.contract.i18n.Messages.contractInputTypeLabel))
            .isFalse();
    editDefaultValueExpression.cancel();
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}

From source file:org.bonitasoft.studio.tests.data.DataWizardIT.java

License:Open Source License

@Test
public void testDatacantBeInitializeByItself() {
    final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    final BotProcessDiagramPerspective diagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
    diagramPerspective.activeProcessDiagramEditor().selectDiagram();
    diagramPerspective.getDiagramPropertiesPart().selectGeneralTab().selectDiagramTab().setName("DataInit");

    final EObject selectedSemanticElement = diagramPerspective.activeProcessDiagramEditor()
            .selectElement("Step1").getSelectedSemanticElement();
    final AbstractProcess proc = ModelHelper.getParentProcess(selectedSemanticElement);

    // add data to Process
    diagramPerspective.activeProcessDiagramEditor().selectElement(proc.getName());
    BotDataPropertySection botDataPropertySection = diagramPerspective.getDiagramPropertiesPart()
            .selectDataTab().selectPoolDataTab();
    BotAddDataWizardPage addData = botDataPropertySection.addData();
    addData.setName("procVar_1").setType("Text").finishAndAdd().setName("procVar_2").setType("Integer")
            .finish();//from ww  w  .j  a v a2  s .c  o  m

    diagramPerspective.activeProcessDiagramEditor().addElementAfter("Step1",
            SWTBotTestUtil.CONTEXTUALPALETTE_STEP, PositionConstants.EAST);

    // set data on step1 Task
    diagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
    botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab().selectLocalDataTab();
    addData = botDataPropertySection.addData();
    addData.setName("varS1_1").setType("Text").finishAndAdd().setName("varS1_2").setType("Integer").finish();

    // set data on step2 Task
    diagramPerspective.activeProcessDiagramEditor().selectElement("Step2");
    botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab().selectLocalDataTab();
    addData = botDataPropertySection.addData();
    addData.setName("varS2_1").setType("Text").finishAndAdd().setName("varS2_2").setType("Integer").finish();
    botApplicationWorkbenchWindow.save();

    // check only process variables are available in tasks data edit expression
    diagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
    botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab().selectLocalDataTab();

    // Test on var varS1_1
    botDataPropertySection.processDataList().select("varS1_1" + " -- " + "Text");
    BotEditDataDialog editDataWizardPage = botDataPropertySection.edit();
    BotExpressionEditorDialog editDefaultValueExpression = editDataWizardPage.editDefaultValueExpression();
    BotTableWidget variableList = editDefaultValueExpression.selectVariableTab().variableList();

    assertThat(variableList.containsItem("varS1_1" + " -- " + "Text"))
            .overridingErrorMessage("Error: Task data can't be initialized by itself").isFalse();
    assertThat(variableList.containsItem("varS1_2" + " -- " + "Integer"))
            .overridingErrorMessage("Error: Task data can't be initialized by a sibling task data").isFalse();

    assertThat(variableList.containsItem("varS2_1" + " -- " + "Text"))
            .overridingErrorMessage("Error: Task data can't be initialized by task data").isFalse();
    assertThat(variableList.containsItem("varS2_2" + " -- " + "Integer"))
            .overridingErrorMessage("Error: Task data can't be initialized by task data").isFalse();

    assertThat(variableList.containsItem("procVar_1" + " -- " + "Text"))
            .overridingErrorMessage("Error:  Task data sould be initialized by Process data",
                    variableList.getSWTBotWidget().rowCount())
            .isTrue();
    assertThat(variableList.containsItem("procVar_2" + " -- " + "Integer"))
            .overridingErrorMessage("Error:  Task data sould be initialized by Process data",
                    variableList.getSWTBotWidget().rowCount())
            .isTrue();

    editDefaultValueExpression.cancel();
    editDataWizardPage.cancel();

    // Test on var varS1_2
    botDataPropertySection.processDataList().select("varS1_2" + " -- " + "Integer");
    editDataWizardPage = botDataPropertySection.edit();
    editDefaultValueExpression = editDataWizardPage.editDefaultValueExpression();
    variableList = editDefaultValueExpression.selectVariableTab().variableList();

    assertThat(variableList.containsItem("varS1_2" + " -- " + "Integer"))
            .overridingErrorMessage("Error: Task data can't be initialized by itself").isFalse();
    assertThat(variableList.containsItem("varS1_1" + " -- " + "Text"))
            .overridingErrorMessage("Error: Task data can't be initialized by a sibling task data").isFalse();

    assertThat(variableList.containsItem("varS2_1" + " -- " + "Text"))
            .overridingErrorMessage("Error: Task data can't be initialized by task data").isFalse();
    assertThat(variableList.containsItem("procVar_1" + " -- " + "Text"))
            .overridingErrorMessage("Error:  Task data sould be initialized by Process data").isTrue();

    assertThat(variableList.containsItem("varS2_2" + " -- " + "Integer"))
            .overridingErrorMessage("Error: Task data can't be initialized by task data").isFalse();
    assertThat(variableList.containsItem("procVar_2" + " -- " + "Integer"))
            .overridingErrorMessage("Error:  Task data sould be initialized by Process data").isTrue();

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

From source file:org.bonitasoft.studio.tests.data.DataWizardIT.java

License:Open Source License

@Test
public void testMaxLengthDescription() {
    final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    final BotProcessDiagramPerspective diagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
    final BotProcessDiagramPropertiesViewFolder diagramPropertiesPart = diagramPerspective
            .getDiagramPropertiesPart();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_DATA).show();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_DATA).setFocus();
    final BotDataPropertySection dataTab = diagramPropertiesPart.selectDataTab().selectPoolDataTab();

    final BotAddDataWizardPage addDataDialog = dataTab.addData();

    addDataDialog.setName("MyName");
    assertThat(bot.button(IDialogConstants.FINISH_LABEL).isEnabled()).isFalse().overridingErrorMessage(
            "We shouldn't be able to create a data with an Uppercase as first charater");
    addDataDialog.setName("myName");
    String text270 = "";
    for (int i = 0; i < 270; i++) {
        text270 += "a";
    }/*ww w  . java 2s . c  om*/
    addDataDialog.setDescription(text270);
    assertThat(bot.button(IDialogConstants.FINISH_LABEL).isEnabled()).isFalse()
            .overridingErrorMessage("We shouldn't be able to put more than 255 characters");
    String text255 = "";
    for (int i = 0; i < 254; i++) {
        text255 += "b";
    }
    addDataDialog.setDescription(text255);
    assertThat(bot.button(IDialogConstants.FINISH_LABEL).isEnabled()).isTrue()
            .overridingErrorMessage("We should be able to put at least 254 characters");
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}