Example usage for org.eclipse.jface.databinding.swt SWTObservables observeSelection

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables observeSelection.

Prototype

@Deprecated
public static ISWTObservableValue observeSelection(Control control) 

Source Link

Document

Returns an observable observing the selection attribute of the provided control.

Usage

From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java

License:Open Source License

private Control createGroupComposite(Group widget) {
    final Composite mainComposite = new Composite(section, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create());

    final Label itemsLabel = new Label(mainComposite, SWT.NONE);
    itemsLabel.setLayoutData(/*w  ww  .  j  a  v a  2 s  . co m*/
            GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).indent(70, SWT.DEFAULT).create());

    final Button isCollapsed = new Button(mainComposite, SWT.CHECK);
    isCollapsed.setLayoutData(GridDataFactory.fillDefaults().create());
    isCollapsed.setText(Messages.isCollapsed);

    context.bindValue(SWTObservables.observeSelection(isCollapsed),
            EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.GROUP__OPTIONAL));

    return mainComposite;
}

From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java

License:Open Source License

private Control createArrayComposite(final Array widget) {
    final Composite mainComposite = new Composite(section, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create());

    final Label nbColLabel = new Label(mainComposite, SWT.NONE);
    nbColLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    nbColLabel.setText(Messages.nbColumn);

    final Combo columnCombo = new Combo(mainComposite, SWT.BORDER | SWT.READ_ONLY);
    columnCombo.setLayoutData(GridDataFactory.fillDefaults().create());
    for (int i = 1; i < 11; i++) {
        columnCombo.add(String.valueOf(i));
    }//www .ja v  a2s. co  m

    if (widget.getCols() == null) {
        widget.setCols(new BigInteger("1"));
    }

    UpdateValueStrategy targetToModel = new UpdateValueStrategy();
    targetToModel.setConverter(new Converter(String.class, BigInteger.class) {

        @Override
        public Object convert(Object from) {
            return new BigInteger((String) from);
        }
    });

    UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
    modelToTarget.setConverter(new Converter(BigInteger.class, String.class) {

        @Override
        public Object convert(Object from) {
            return String.valueOf(((BigInteger) from).intValue());
        }
    });

    context.bindValue(SWTObservables.observeText(columnCombo),
            EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.ARRAY__COLS), targetToModel,
            modelToTarget);

    final Label fixedColLabel = new Label(mainComposite, SWT.NONE);
    fixedColLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());

    final Button fixedColButton = new Button(mainComposite, SWT.CHECK);
    fixedColButton.setLayoutData(GridDataFactory.fillDefaults().create());
    fixedColButton.setText(Messages.fixedColumn);

    context.bindValue(SWTObservables.observeSelection(fixedColButton),
            EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.ARRAY__FIXED_COLS));

    final Label colHeadersLabel = new Label(mainComposite, SWT.NONE);
    colHeadersLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create());
    colHeadersLabel.setText(Messages.columnHeaders);

    final Composite itemComposite = new Composite(mainComposite, SWT.NONE);
    itemComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    itemComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create());

    final TableViewer itemViewer = new TableViewer(itemComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    itemViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).create());
    itemViewer.setContentProvider(new ArrayContentProvider());
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100));
    itemViewer.getTable().setLayout(layout);

    final TableViewerColumn inputNameColumn = new TableViewerColumn(itemViewer, SWT.FILL);
    inputNameColumn.getColumn().setText(Messages.input);
    inputNameColumn.setEditingSupport(new CaptionEditingSupport(itemViewer, widget));
    inputNameColumn.setLabelProvider(new ColumnLabelProvider());

    context.bindValue(ViewersObservables.observeInput(itemViewer),
            EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.ARRAY__COLS_CAPTION));

    final Composite buttonComposite = new Composite(itemComposite, SWT.NONE);
    buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
    buttonComposite
            .setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create());

    final Button addButton = new Button(buttonComposite, SWT.FLAT);
    addButton.setText(Messages.Add);
    addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    addButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            String item = generateCaption(widget);
            widget.getColsCaption().add(item);
            itemViewer.editElement(item, 0);
        }

    });

    final Button upButton = new Button(buttonComposite, SWT.FLAT);
    upButton.setText(Messages.up);
    upButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    upButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            String selected = (String) ((IStructuredSelection) itemViewer.getSelection()).getFirstElement();
            int i = widget.getColsCaption().indexOf(selected);
            if (i > 0) {
                widget.getColsCaption().move(i - 1, selected);
                itemViewer.refresh();
            }
        }
    });

    final Button downButton = new Button(buttonComposite, SWT.FLAT);
    downButton.setText(Messages.down);
    downButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    downButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            String selected = (String) ((IStructuredSelection) itemViewer.getSelection()).getFirstElement();
            int i = widget.getColsCaption().indexOf(selected);
            if (i < widget.getColsCaption().size() - 1) {
                widget.getColsCaption().move(i + 1, selected);
                itemViewer.refresh();
            }
        }
    });

    final Button removeButton = new Button(buttonComposite, SWT.FLAT);
    removeButton.setText(Messages.remove);
    removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    removeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            widget.getColsCaption().removeAll(((IStructuredSelection) itemViewer.getSelection()).toList());
            itemViewer.refresh();
        }
    });

    return mainComposite;
}

From source file:org.bonitasoft.studio.connectors.ui.wizard.page.ExportConnectorWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    context = new EMFDataBindingContext();
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(10, 10, 10, 0).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Text serachBox = new Text(composite, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH);
    serachBox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create());
    serachBox.setMessage(Messages.search);

    tableViewer = new TableViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    tableViewer.getTable().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).span(3, 1).hint(SWT.DEFAULT, 280).create());
    tableViewer.setContentProvider(contentProvider);
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.addSelectionChangedListener(this);
    tableViewer.addDoubleClickListener(this);
    tableViewer.addFilter(new ViewerFilter() {

        @Override//from  w  ww. j a  va2s  .  com
        public boolean select(Viewer arg0, Object parentElement, Object element) {
            String search = serachBox.getText();
            return search == null || search.isEmpty()
                    || labelProvider.getText(element).toLowerCase().contains(search.toLowerCase());
        }
    });
    tableViewer.setInput(new Object());
    tableViewer.getTable().setFocus();

    serachBox.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            tableViewer.refresh();
        }
    });

    IValidator selectionValidator = new IValidator() {
        @Override
        public IStatus validate(Object value) {
            if (value == null) {
                return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID,
                        Messages.selectAConnectorImplWarning);
            }
            if (value instanceof ConnectorImplementation) {
                String id = ((ConnectorImplementation) value).getDefinitionId();
                String version = ((ConnectorImplementation) value).getDefinitionVersion();
                if (id == null || id.isEmpty()) {
                    return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID,
                            Messages.selectAValidConnectorImplWarning);
                }
                if (version == null || version.isEmpty()) {
                    return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID,
                            Messages.selectAValidConnectorImplWarning);
                }
                if (defStore.getDefinition(id, version, definitions) == null) {
                    return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID,
                            Messages.selectAValidConnectorImplWarning);
                }

                if (((ConnectorImplementation) value).getImplementationClassname() == null
                        || ((ConnectorImplementation) value).getImplementationClassname().isEmpty()) {
                    return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID,
                            Messages.selectAValidConnectorImplWarning);
                }
            }
            return Status.OK_STATUS;
        }
    };

    UpdateValueStrategy selectionStrategy = new UpdateValueStrategy();
    selectionStrategy.setBeforeSetValidator(selectionValidator);

    final Label inculeSourcesLabel = new Label(composite, SWT.NONE);
    inculeSourcesLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    inculeSourcesLabel.setText(Messages.inculeSourcesLabel);

    final Button includeSourceCheckbox = new Button(composite, SWT.CHECK);
    includeSourceCheckbox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());

    final Label addDependenciesLabel = new Label(composite, SWT.NONE);
    addDependenciesLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    addDependenciesLabel.setText(Messages.addDependencies);

    final Button addDependenciesCheckbox = new Button(composite, SWT.CHECK);
    addDependenciesCheckbox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());

    final Label destDirectoryLabel = new Label(composite, SWT.NONE);
    destDirectoryLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    destDirectoryLabel.setText(Messages.destinationLabel + " *");

    final Text destDirectoryText = new Text(composite, SWT.BORDER);
    destDirectoryText.setLayoutData(
            GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());

    Button destFileButton = new Button(composite, SWT.PUSH);
    destFileButton.setLayoutData(GridDataFactory.fillDefaults().hint(85, SWT.DEFAULT).create());
    destFileButton.setText(Messages.browsePackages);
    destFileButton.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event event) {
            String defaultName = generateDefaultName();
            selectDirectory(destDirectoryText, defaultName);
        }
    });
    Label destFileNameLabel = new Label(composite, SWT.NONE);
    destFileNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    destFileNameLabel.setText(Messages.destFileNameLabel);
    destFileNameText = new Text(composite, SWT.BORDER);
    destFileNameText.setText(generateDefaultName());
    destFileNameText.setLayoutData(
            GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
    UpdateValueStrategy pathStrategy = new UpdateValueStrategy();
    final EmptyInputValidator emptyValidator = new EmptyInputValidator(Messages.destinationLabel);
    pathStrategy.setBeforeSetValidator(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            IStatus status = emptyValidator.validate(value);
            if (!status.isOK()) {
                return status;
            }
            File target = new File((String) value);
            if (!target.exists()) {
                return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID, Messages.targetPathIsInvalid);
            }
            return Status.OK_STATUS;
        }
    });

    UpdateValueStrategy nameStrategy = new UpdateValueStrategy();
    nameStrategy.setBeforeSetValidator(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            if (!value.toString().endsWith(".zip")) {
                return new Status(IStatus.ERROR, ConnectorPlugin.PLUGIN_ID, Messages.notAZipFile);
            }
            return Status.OK_STATUS;
        }
    });
    context.bindValue(ViewersObservables.observeSingleSelection(tableViewer),
            PojoProperties.value(ExportConnectorWizardPage.class, "selectedImplementation").observe(this),
            selectionStrategy, null);
    context.bindValue(SWTObservables.observeSelection(includeSourceCheckbox),
            PojoProperties.value(ExportConnectorWizardPage.class, "includeSources").observe(this));
    context.bindValue(SWTObservables.observeSelection(addDependenciesCheckbox),
            PojoProperties.value(ExportConnectorWizardPage.class, "addDependencies").observe(this));
    context.bindValue(SWTObservables.observeText(destDirectoryText, SWT.Modify),
            PojoProperties.value(ExportConnectorWizardPage.class, "destFilePath").observe(this), pathStrategy,
            null);
    context.bindValue(SWTObservables.observeText(destFileNameText, SWT.Modify),
            PojoProperties.value(ExportConnectorWizardPage.class, "destFileName").observe(this), nameStrategy,
            null);

    pageSupport = WizardPageSupport.create(this, context);

    setControl(composite);
}

From source file:org.bonitasoft.studio.connectors.ui.wizard.page.MoveConnectorWizardPage.java

License:Open Source License

private void createActionControl(final EMFDataBindingContext dbc, final Composite parent) {
    final Label actionLabel = new Label(parent, SWT.NONE);
    actionLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
    actionLabel.setText(Messages.selectMoveOrCopyAction);

    final Composite actionRadioGroup = new Composite(parent, SWT.NONE);
    actionRadioGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    actionRadioGroup//from  w w w .j a va2  s.com
            .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).extendedMargins(20, 0, 0, 5).create());

    final Button moveRadio = createRadioButton(actionRadioGroup, Messages.move);
    final Button copyRadio = createRadioButton(actionRadioGroup, Messages.copy);

    final SelectObservableValue actionObservable = new SelectObservableValue(Boolean.class);
    actionObservable.addOption(Boolean.FALSE, SWTObservables.observeSelection(moveRadio));
    actionObservable.addOption(Boolean.TRUE, SWTObservables.observeSelection(copyRadio));
    dbc.bindValue(actionObservable, PojoObservables.observeValue(this, "copy"));
}

From source file:org.bonitasoft.studio.connectors.ui.wizard.page.MoveConnectorWizardPage.java

License:Open Source License

private void createExecutionEventControl(final EMFDataBindingContext dbc, final Composite parent) {
    final Label eventLabel = new Label(parent, SWT.NONE);
    eventLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
    eventLabel.setText(Messages.connectorEventLabel);

    final Composite eventRadioGroup = new Composite(parent, SWT.NONE);
    eventRadioGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    eventRadioGroup/*from  w ww .  ja  va2  s . co m*/
            .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).extendedMargins(20, 0, 0, 15).create());

    final Button inRadio = createRadioButton(eventRadioGroup,
            Messages.bind(Messages.connectorInChoice, ConnectorEvent.ON_ENTER.name()));
    final Button outRadio = createRadioButton(eventRadioGroup,
            Messages.bind(Messages.connectorOutChoice, ConnectorEvent.ON_FINISH.name()));

    final SelectObservableValue eventObservable = new SelectObservableValue(String.class);
    eventObservable.addOption(ConnectorEvent.ON_ENTER.name(), SWTObservables.observeSelection(inRadio));
    eventObservable.addOption(ConnectorEvent.ON_FINISH.name(), SWTObservables.observeSelection(outRadio));
    dbc.bindValue(eventObservable, connectorEventObservable);
}

From source file:org.bonitasoft.studio.connectors.ui.wizard.page.SelectDatabaseOutputTypeWizardPage.java

License:Open Source License

@Override
protected Control doCreateControl(Composite parent, EMFDataBindingContext context) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0)
            .extendedMargins(10, 10, 5, 0).create());

    createSelectModeLabelControl(mainComposite);

    scriptExpression = (Expression) getConnectorParameter(getInput(SCRIPT_KEY)).getExpression();
    IObservableValue scriptContentValue = EMFObservables.observeValue(scriptExpression,
            ExpressionPackage.Literals.EXPRESSION__CONTENT);
    scriptContentValue.addValueChangeListener(this);
    outputTypeExpression = (Expression) getConnectorParameter(getInput(OUTPUT_TYPE_KEY)).getExpression();
    outputTypeExpression.setName(OUTPUT_TYPE_KEY);

    final Composite choicesComposite = createGraphicalModeControl(mainComposite, context);
    final Button singleModeRadio = createSingleChoice(choicesComposite, context);
    final Button oneRowModeRadio = createOneRowNColsChoice(choicesComposite, context);
    final Button nRowModeRadio = createNRowsOneColChoice(choicesComposite, context);
    final Button tableModeRadio = createTableChoice(choicesComposite, context);
    final Button scriptModeRadio = createScriptModeControl(mainComposite);

    final IObservableValue singleValue = SWTObservables.observeSelection(singleModeRadio);
    final IObservableValue oneRowValue = SWTObservables.observeSelection(oneRowModeRadio);
    final IObservableValue oneColValue = SWTObservables.observeSelection(nRowModeRadio);
    final IObservableValue tableValue = SWTObservables.observeSelection(tableModeRadio);
    scriptValue = SWTObservables.observeSelection(scriptModeRadio);
    graphicalModeSelectionValue = SWTObservables.observeSelection(gModeRadio);

    radioGroupObservable = new SelectObservableValue(String.class);
    radioGroupObservable.addOption(SINGLE, singleValue);
    radioGroupObservable.addOption(ONE_ROW, oneRowValue);
    radioGroupObservable.addOption(N_ROW, oneColValue);
    radioGroupObservable.addOption(TABLE, tableValue);
    radioGroupObservable.addOption(null, scriptValue);

    context.bindValue(SWTObservables.observeEnabled(alwaysUseScriptCheckbox), scriptValue);
    final UpdateValueStrategy deselectStrategy = new UpdateValueStrategy();
    deselectStrategy.setConverter(new Converter(Boolean.class, Boolean.class) {

        @Override// w  w w  .j a  v a 2  s.com
        public Object convert(Object fromObject) {
            return false;
        }
    });

    context.bindValue(graphicalModeSelectionValue, SWTObservables.observeSelection(alwaysUseScriptCheckbox),
            deselectStrategy, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    context.bindValue(graphicalModeSelectionValue, SWTObservables.observeEnabled(choicesComposite));

    final UpdateValueStrategy disabledStrategy = new UpdateValueStrategy();
    disabledStrategy.setConverter(new Converter(Boolean.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            if ((outputTypeExpression.getContent() == null && !(Boolean) fromObject)
                    || SQLQueryUtil.getSelectedColumns(scriptExpression).size() != 1
                            && !SQLQueryUtil.useWildcard(scriptExpression)) {
                return false;
            }
            return fromObject;
        }
    });

    final UpdateValueStrategy disabledStrategy2 = new UpdateValueStrategy();
    disabledStrategy2.setConverter(new Converter(Boolean.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            if ((outputTypeExpression.getContent() == null && !(Boolean) fromObject)
                    || SQLQueryUtil.useWildcard(scriptExpression)) {
                return false;
            }
            return fromObject;
        }
    });

    radioGroupObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            IWizardPage p = getNextPage();
            if (p instanceof DatabaseConnectorOutputWizardPage) {
                ((DatabaseConnectorOutputWizardPage) p)
                        .updateOutputs((String) event.getObservableValue().getValue());
            }
        }
    });

    context.bindValue(radioGroupObservable,
            EMFObservables.observeValue(outputTypeExpression, ExpressionPackage.Literals.EXPRESSION__CONTENT));
    graphicalModeSelectionValue.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            if ((Boolean) event.getObservableValue().getValue()) {
                if (singleModeRadio.getSelection()) {
                    radioGroupObservable.setValue(SINGLE);
                } else if (oneRowModeRadio.getSelection()) {
                    radioGroupObservable.setValue(ONE_ROW);
                } else if (nRowModeRadio.getSelection()) {
                    radioGroupObservable.setValue(N_ROW);
                } else {
                    radioGroupObservable.setValue(TABLE);
                }
                updateEnabledChoices();
            } else {
                singleModeRadioObserveEnabled.setValue(false);
                nRowsOneColModeRadioObserveEnabled.setValue(false);
                oneRowNColModeRadioObserveEnabled.setValue(false);
                tableObserveEnabled.setValue(false);
            }

        }
    });

    parseQuery();

    return mainComposite;
}

From source file:org.bonitasoft.studio.contract.ui.wizard.CreateContractInputFromBusinessObjectWizardPage.java

License:Open Source License

private void createReminderText(final EMFDataBindingContext dbc, final Composite composite) {
    final CLabel reminder = new CLabel(composite, SWT.NONE);
    final Display d = Display.getCurrent();
    final Image img = d.getSystemImage(SWT.ICON_WARNING);
    reminder.setImage(img);/*from w w w. j  a  va  2 s  .  c om*/
    reminder.setLayoutData(GridDataFactory.fillDefaults().hint(600, SWT.DEFAULT).create());
    final Button autoGeneratedOperationButton = new Button(composite, SWT.RADIO);
    final Button manuallyDefinedOperationButton = new Button(composite, SWT.RADIO);
    actionObservable = new SelectObservableValue(Boolean.class);
    actionObservable.addOption(Boolean.TRUE, SWTObservables.observeSelection(autoGeneratedOperationButton));
    actionObservable.addOption(Boolean.FALSE, SWTObservables.observeSelection(manuallyDefinedOperationButton));
    if (contract.eContainer() instanceof Task) {
        reminder.setText(Messages.reminderForStepMessage);
        autoGeneratedOperationButton.setText(Messages.autoGeneratedOperationStepButton);
        manuallyDefinedOperationButton.setText(Messages.manuallyDefinedOperationStepButton);
    } else {
        reminder.setText(Messages.reminderForProcessMessage);
        autoGeneratedOperationButton.setText(Messages.autoGeneratedOperationProcessButton);
        manuallyDefinedOperationButton.setText(Messages.manuallyDefinedOperationProcessButton);
    }
    dbc.bindValue(actionObservable, PojoObservables.observeValue(generationOptions, "autogeneratedScript"));
}

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

License:Open Source License

protected void bindIsMultipleData() {
    emfDatabindingContext.bindValue(SWTObservables.observeSelection(multiplicityButton),
            EMFObservables.observeValue(data, ProcessPackage.Literals.DATA__MULTIPLE));
    final UpdateValueStrategy startegy = new UpdateValueStrategy();
    final IObservableValue returnTypeObservable = EMFObservables.observeValue(data.getDefaultValue(),
            ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE);
    final IObservableValue typeObservable = EMFObservables.observeValue(data.getDefaultValue(),
            ExpressionPackage.Literals.EXPRESSION__TYPE);
    final IObservableValue interpreterObservable = EMFObservables.observeValue(data.getDefaultValue(),
            ExpressionPackage.Literals.EXPRESSION__INTERPRETER);
    startegy.setConverter(new Converter(Boolean.class, String.class) {

        private Object previousExpressionType;

        @Override//from   ww w  . ja v a2  s  . co m
        public Object convert(Object input) {
            if ((Boolean) input) {
                previousExpressionType = typeObservable.getValue();
                typeObservable.setValue(ExpressionConstants.SCRIPT_TYPE);
                interpreterObservable.setValue(ExpressionConstants.GROOVY);
                defaultValueViewer.refresh();
                return multipleReturnType;
            } else {
                if (previousExpressionType != null) {
                    typeObservable.setValue(previousExpressionType);
                    if (!ExpressionConstants.SCRIPT_TYPE.equals(previousExpressionType)) {
                        interpreterObservable.setValue(null);
                    }
                    defaultValueViewer.refresh();
                }
                return getSelectedReturnType();
            }
        }

    });

    emfDatabindingContext.bindValue(SWTObservables.observeSelection(multiplicityButton), returnTypeObservable,
            startegy, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
}

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

License:Open Source License

protected void bindGenerateDataCheckbox() {
    if (generateDataCheckbox != null) {
        emfDatabindingContext.bindValue(SWTObservables.observeSelection(generateDataCheckbox),
                EMFObservables.observeValue(data, ProcessPackage.Literals.DATA__GENERATED));
    }//from   w w w  .  j  av a  2 s  . c  o  m
}

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

License:Open Source License

protected void bindTransientButton() {
    if (isTransientButton != null && !isTransientButton.isDisposed()) {
        emfDatabindingContext.bindValue(SWTObservables.observeSelection(isTransientButton),
                EMFObservables.observeValue(data, ProcessPackage.Literals.DATA__TRANSIENT));
    }//from w ww .  ja  va  2s . c  o m
}