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.properties.form.sections.actions.table.DynamicTableDataPropertySection.java

License:Open Source License

protected void bindRow(DynamicTable dynamicTable) {
    dataBindingContext.bindValue(SWTObservables.observeSelection(allowAddRemoveRowButton),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW));

    if (dynamicTable != null) {
        Expression minNumberOfRow = dynamicTable.getMinNumberOfColumn();
        if (minNumberOfRow == null) {
            minNumberOfRow = ExpressionFactory.eINSTANCE.createExpression();
            minNumberOfRow.setReturnType(Integer.class.getName());
            minNumberOfRow.setReturnTypeFixed(true);
            getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__MIN_NUMBER_OF_ROW, minNumberOfRow));
        }//  w w  w .  j  a v a2s  . com
    }

    if (dynamicTable != null) {
        Expression maxNumberOfRow = dynamicTable.getMaxNumberOfRow();
        if (maxNumberOfRow == null) {
            maxNumberOfRow = ExpressionFactory.eINSTANCE.createExpression();
            maxNumberOfRow.setReturnType(Integer.class.getName());
            maxNumberOfRow.setReturnTypeFixed(true);
            getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__MAX_NUMBER_OF_ROW, maxNumberOfRow));
        }
    }

    /*
     * Synchronize with the model.
     * */
    dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(textOrDataMinRow),
            EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.DYNAMIC_TABLE__MIN_NUMBER_OF_ROW)
                    .observe(dynamicTable));
    dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(textOrDataMaxRow),
            EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.DYNAMIC_TABLE__MAX_NUMBER_OF_ROW)
                    .observe(dynamicTable));
    dataBindingContext.bindValue(SWTObservables.observeSelection(limitMinRowButton),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__LIMIT_MIN_NUMBER_OF_ROW));
    dataBindingContext.bindValue(SWTObservables.observeSelection(limitMaxRowButton),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__LIMIT_MAX_NUMBER_OF_ROW));

    /*
     * Enable the combo only if we want to set a number limitation.
     * */
    dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinRow.getControl()),
            SWTObservables.observeSelection(limitMinRowButton));
    dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinRow.getTextControl()),
            SWTObservables.observeSelection(limitMinRowButton));
    dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMinRow.getToolbar()),
            SWTObservables.observeSelection(limitMinRowButton));
    dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxRow.getControl()),
            SWTObservables.observeSelection(limitMaxRowButton));
    dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxRow.getTextControl()),
            SWTObservables.observeSelection(limitMaxRowButton));
    dataBindingContext.bindValue(SWTObservables.observeEnabled(textOrDataMaxRow.getToolbar()),
            SWTObservables.observeSelection(limitMaxRowButton));

    dataBindingContext.bindValue(SWTObservables.observeVisible(limitMinRowButton),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    dataBindingContext.bindValue(SWTObservables.observeVisible(limitMaxRowButton),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    dataBindingContext.bindValue(SWTObservables.observeVisible(textOrDataMinRow.getControl()),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
    dataBindingContext.bindValue(SWTObservables.observeVisible(textOrDataMaxRow.getControl()),
            EMFEditObservables.observeValue(getEditingDomain(), dynamicTable,
                    FormPackage.Literals.DYNAMIC_TABLE__ALLOW_ADD_REMOVE_ROW),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);

    textOrDataMinRow.setInput(dynamicTable);
    textOrDataMaxRow.setInput(dynamicTable);
}

From source file:org.bonitasoft.studio.properties.form.sections.actions.table.TableDataPropertySection.java

License:Open Source License

@Override
protected void refreshDataBinding() {
    super.refreshDataBinding();
    if (getEObject() != null) {
        UpdateValueStrategy not = new UpdateValueStrategy()
                .setConverter(new Converter(Boolean.class, Boolean.class) {

                    public Object convert(Object fromObject) {
                        return !((Boolean) fromObject);
                    }/*from ww  w .  j ava2  s .  c o  m*/
                });
        dataBindingContext.bindValue(SWTObservables.observeSelection(allowSelectionButton), EMFEditObservables
                .observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.TABLE__ALLOW_SELECTION));
        dataBindingContext.bindValue(SWTObservables.observeSelection(allowSingleSelection),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__SELECTION_MODE_IS_MULTIPLE),
                not, not);
        dataBindingContext.bindValue(SWTObservables.observeSelection(allowMultipleSelection),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__SELECTION_MODE_IS_MULTIPLE));

        Expression maxRowForPagination = getEObject().getMaxRowForPagination();
        if (maxRowForPagination == null) {
            maxRowForPagination = ExpressionFactory.eINSTANCE.createExpression();
            getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), getEObject(),
                    FormPackage.Literals.TABLE__MAX_ROW_FOR_PAGINATION, maxRowForPagination));
        }
        dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(paginationMaxNumber),
                EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.TABLE__MAX_ROW_FOR_PAGINATION)
                        .observe(getEObject()));
        paginationMaxNumber.setInput(getEObject());
        paginationMaxNumber.setEditingDomain(getEditingDomain());
        dataBindingContext.bindValue(SWTObservables.observeEnabled(paginationMaxNumber.getTextControl()),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__ALLOW_SELECTION),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), not);
        dataBindingContext.bindValue(SWTObservables.observeEnabled(paginationMaxNumber.getButtonControl()),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__ALLOW_SELECTION),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), not);
        Expression selectedValues = getEObject().getMaxRowForPagination();
        if (selectedValues == null) {
            selectedValues = ExpressionFactory.eINSTANCE.createExpression();
            getEditingDomain().getCommandStack().execute(SetCommand.create(getEditingDomain(), getEObject(),
                    FormPackage.Literals.TABLE__SELECTED_VALUES, selectedValues));
        }
        dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(initialSelectedValues),
                EMFEditProperties.value(getEditingDomain(), FormPackage.Literals.TABLE__SELECTED_VALUES)
                        .observe(getEObject()));
        initialSelectedValues.setInput(getEObject());
        initialSelectedValues.setEditingDomain(getEditingDomain());

        Expression columnForInitialSelectionIndex = getEObject().getColumnForInitialSelectionIndex();
        if (columnForInitialSelectionIndex == null) {
            columnForInitialSelectionIndex = ExpressionFactory.eINSTANCE.createExpression();
            getEditingDomain().getCommandStack()
                    .execute(SetCommand.create(getEditingDomain(), getEObject(),
                            FormPackage.Literals.TABLE__COLUMN_FOR_INITIAL_SELECTION_INDEX,
                            columnForInitialSelectionIndex));
        }
        dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(initialFromColumn),
                EMFEditProperties
                        .value(getEditingDomain(),
                                FormPackage.Literals.TABLE__COLUMN_FOR_INITIAL_SELECTION_INDEX)
                        .observe(getEObject()));
        initialFromColumn.setInput(getEObject());
        initialFromColumn.setEditingDomain(getEditingDomain());

        /*Hide if no selection allowed*/
        dataBindingContext.bindValue(SWTObservables.observeVisible(allowedSelectionCompo),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__ALLOW_SELECTION),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
        dataBindingContext.bindValue(SWTObservables.observeVisible(allowSingleSelection),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__ALLOW_SELECTION),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
        dataBindingContext.bindValue(SWTObservables.observeVisible(allowMultipleSelection),
                EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                        FormPackage.Literals.TABLE__ALLOW_SELECTION),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);
        contrib.setEditingDomain(getEditingDomain());
        contrib.setEObject(getEObject());
        contrib.superBind();
    }
}

From source file:org.bonitasoft.studio.properties.form.sections.appearance.AppearancePropertySection.java

License:Open Source License

/**
 * @param left//  ww w  .j a v  a 2 s.c o m
 * @param right
 * @param up
 * @param down
 */
protected void bindLabelPositionGroup(Button left, Button right, Button up, Button down) {
    if (databindingContext != null) {
        databindingContext.dispose();
    }
    databindingContext = new EMFDataBindingContext();

    UpdateValueStrategy rightToEnum = new UpdateValueStrategy()
            .setConverter(new Converter(Boolean.class, LabelPosition.class) {
                public Object convert(Object fromObject) {
                    return LabelPosition.RIGHT;
                }
            });
    UpdateValueStrategy enumToRight = new UpdateValueStrategy()
            .setConverter(new Converter(LabelPosition.class, Boolean.class) {
                public Object convert(Object fromObject) {
                    return fromObject.equals(LabelPosition.RIGHT);
                }
            });
    UpdateValueStrategy leftToEnum = new UpdateValueStrategy()
            .setConverter(new Converter(Boolean.class, LabelPosition.class) {
                public Object convert(Object fromObject) {
                    return LabelPosition.LEFT;
                }
            });
    UpdateValueStrategy enumToLeft = new UpdateValueStrategy()
            .setConverter(new Converter(LabelPosition.class, Boolean.class) {
                public Object convert(Object fromObject) {
                    return fromObject.equals(LabelPosition.LEFT);
                }
            });
    UpdateValueStrategy upToEnum = new UpdateValueStrategy()
            .setConverter(new Converter(Boolean.class, LabelPosition.class) {
                public Object convert(Object fromObject) {

                    return LabelPosition.UP;
                }
            });
    UpdateValueStrategy enumToUp = new UpdateValueStrategy()
            .setConverter(new Converter(LabelPosition.class, Boolean.class) {
                public Object convert(Object fromObject) {
                    return fromObject.equals(LabelPosition.UP);
                }
            });
    UpdateValueStrategy downToEnum = new UpdateValueStrategy()
            .setConverter(new Converter(Boolean.class, LabelPosition.class) {
                public Object convert(Object fromObject) {

                    return LabelPosition.DOWN;
                }
            });
    UpdateValueStrategy enumToDown = new UpdateValueStrategy()
            .setConverter(new Converter(LabelPosition.class, Boolean.class) {
                public Object convert(Object fromObject) {
                    return fromObject.equals(LabelPosition.DOWN);
                }
            });

    databindingContext
            .bindValue(
                    SWTObservables.observeSelection(right), EMFEditObservables.observeValue(getEditingDomain(),
                            getEObject(), FormPackage.Literals.WIDGET__LABEL_POSITION),
                    rightToEnum, enumToRight);
    databindingContext.bindValue(SWTObservables.observeSelection(left), EMFEditObservables
            .observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.WIDGET__LABEL_POSITION),
            leftToEnum, enumToLeft);
    databindingContext.bindValue(SWTObservables.observeSelection(up), EMFEditObservables.observeValue(
            getEditingDomain(), getEObject(), FormPackage.Literals.WIDGET__LABEL_POSITION), upToEnum, enumToUp);
    databindingContext.bindValue(SWTObservables.observeSelection(down), EMFEditObservables
            .observeValue(getEditingDomain(), getEObject(), FormPackage.Literals.WIDGET__LABEL_POSITION),
            downToEnum, enumToDown);
}

From source file:org.bonitasoft.studio.properties.form.sections.appearance.TableHeadersAppearanceSection.java

License:Open Source License

/**
 * @param leftHeaderButton/*w  ww. j  ava 2 s. co m*/
 * @param topHeaderButton
 * @param rightHeaderButton
 * @param bottomHeaderButton
 */
protected void bindHeaderButtons() {
    databindingContext.bindValue(SWTObservables.observeSelection(topHeaderButton),
            EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                    FormPackage.Literals.ABSTRACT_TABLE__FIRST_ROW_IS_HEADER));
    databindingContext.bindValue(SWTObservables.observeSelection(leftHeaderButton),
            EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                    FormPackage.Literals.ABSTRACT_TABLE__LEFT_COLUMN_IS_HEADER));
    databindingContext.bindValue(SWTObservables.observeSelection(rightHeaderButton),
            EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                    FormPackage.Literals.ABSTRACT_TABLE__RIGHT_COLUMN_IS_HEADER));
    databindingContext.bindValue(SWTObservables.observeSelection(bottomHeaderButton),
            EMFEditObservables.observeValue(getEditingDomain(), getEObject(),
                    FormPackage.Literals.ABSTRACT_TABLE__LAST_ROW_IS_HEADER));
}

From source file:org.bonitasoft.studio.properties.form.sections.general.contributions.ShowLabelGridPropertySectionContribution.java

License:Open Source License

public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory,
        ExtensibleGridPropertySection extensibleGridPropertySection) {

    composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    composite.setLayout(new GridLayout(3, false));
    if (dataBindingContext != null) {
        dataBindingContext.dispose();/*from ww w.  ja  v  a 2s  .com*/
    }
    dataBindingContext = new EMFDataBindingContext();
    Button enableLabel = null;

    if (!(element instanceof FormButton)) {
        /* Create the checkbox to hide/show the label */
        enableLabel = widgetFactory.createButton(composite, "", SWT.CHECK); //$NON-NLS-1$
        enableLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
        enableLabel.setToolTipText(Messages.GeneralSection_EnableLabel_tooltip);
        dataBindingContext.bindValue(SWTObservables.observeSelection(enableLabel), EMFEditObservables
                .observeValue(editingDomain, element, FormPackage.Literals.WIDGET__SHOW_DISPLAY_LABEL));
    }

    ExpressionViewer displayLabelViewer = new ExpressionViewer(composite, SWT.BORDER, widgetFactory,
            editingDomain, FormPackage.Literals.WIDGET__DISPLAY_LABEL);
    displayLabelViewer.addFilter(new AvailableExpressionTypeFilter(new String[] {
            ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.I18N_TYPE, ExpressionConstants.SCRIPT_TYPE,
            ExpressionConstants.PARAMETER_TYPE, ExpressionConstants.VARIABLE_TYPE }));
    Expression displayLabelExpression = element.getDisplayLabel();
    if (displayLabelExpression == null) {
        displayLabelExpression = ExpressionFactory.eINSTANCE.createExpression();
        editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, element,
                FormPackage.Literals.WIDGET__DISPLAY_LABEL, displayLabelExpression));
    }

    // add validator on the show label field when it is a form button - expression can't be empty
    if (element instanceof FormButton) {
        displayLabelViewer.addExpressionValidator(ExpressionConstants.CONSTANT_TYPE,
                new ExpressionNotEmptyValidator());
    }

    displayLabelViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(300, SWT.DEFAULT).create());

    displayLabelViewer.setInput(element);
    dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(displayLabelViewer),
            EMFEditProperties.value(editingDomain, FormPackage.Literals.WIDGET__DISPLAY_LABEL)
                    .observe(element));

    if (!(element instanceof FormButton)) {

        /* Create the chekbox to allow HTML for the label or not */
        Button allowHtmlButton = widgetFactory.createButton(composite, Messages.GeneralSection_allowHTML,
                SWT.CHECK);
        dataBindingContext.bindValue(SWTObservables.observeSelection(allowHtmlButton),
                EMFEditObservables.observeValue(editingDomain, element,
                        FormPackage.Literals.WIDGET__ALLOW_HTML_FOR_DISPLAY_LABEL));
        dataBindingContext.bindValue(SWTObservables.observeEnabled(allowHtmlButton),
                SWTObservables.observeSelection(enableLabel));

        /* Enable/disable the combo for the text and the allow html */
        dataBindingContext.bindValue(SWTObservables.observeEnabled(displayLabelViewer.getControl()),
                SWTObservables.observeSelection(enableLabel));
        dataBindingContext.bindValue(SWTObservables.observeEnabled(displayLabelViewer.getTextControl()),
                SWTObservables.observeSelection(enableLabel));
        dataBindingContext.bindValue(SWTObservables.observeEnabled(displayLabelViewer.getButtonControl()),
                SWTObservables.observeSelection(enableLabel));
    }
}

From source file:org.bonitasoft.studio.properties.form.sections.general.contributions.ShowPageLabelContribution.java

License:Open Source License

public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory,
        ExtensibleGridPropertySection extensibleGridPropertySection) {
    //      composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false,2,1));
    composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    composite.setLayout(new GridLayout(3, false));
    if (dataBindingContext != null) {
        dataBindingContext.dispose();// w  w  w .  ja  v a 2  s . c o m
    }
    dataBindingContext = new EMFDataBindingContext();

    Button enableLabel = widgetFactory.createButton(composite, "", SWT.CHECK); //$NON-NLS-1$
    enableLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    enableLabel.setToolTipText(Messages.GeneralSection_EnableLabel_tooltip);
    dataBindingContext.bindValue(SWTObservables.observeSelection(enableLabel), EMFEditObservables
            .observeValue(editingDomain, element, FormPackage.Literals.FORM__SHOW_PAGE_LABEL));

    enableLabel.setSelection(element.getShowPageLabel() == null || element.getShowPageLabel());

    GridData gData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
    gData.widthHint = 250;

    ExpressionViewer pageLabelExpresssionViewer = new ExpressionViewer(composite, SWT.BORDER, widgetFactory,
            FormPackage.Literals.FORM__PAGE_LABEL);
    final Expression pageLabel = element.getPageLabel();
    if (pageLabel == null) {
        editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, element,
                FormPackage.Literals.FORM__PAGE_LABEL, ExpressionFactory.eINSTANCE.createExpression()));
    }
    if (ModelHelper.isAnEntryPageFlowOnAPool(element)) {
        pageLabelExpresssionViewer
                .addFilter(new AvailableExpressionTypeFilter(new String[] { ExpressionConstants.CONSTANT_TYPE,
                        ExpressionConstants.PARAMETER_TYPE, ExpressionConstants.SCRIPT_TYPE }));
    }

    pageLabelExpresssionViewer.setInput(element);
    dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(pageLabelExpresssionViewer),
            EMFEditProperties.value(editingDomain, FormPackage.Literals.FORM__PAGE_LABEL).observe(element));

    pageLabelExpresssionViewer.setMessage(Messages.GeneralSection_EnablePageLabel_tooltip, IStatus.INFO);
    pageLabelExpresssionViewer.getControl().setLayoutData(gData);

    Button allowHTMLButton = widgetFactory.createButton(composite, Messages.GeneralSection_allowHTML,
            SWT.CHECK);
    dataBindingContext.bindValue(SWTObservables.observeSelection(allowHTMLButton), EMFEditObservables
            .observeValue(editingDomain, element, FormPackage.Literals.FORM__ALLOW_HTML_IN_PAGE_LABEL));

    /*Enable/disable the combo for the text and the allow html*/
    dataBindingContext.bindValue(SWTObservables.observeEnabled(pageLabelExpresssionViewer.getControl()),
            SWTObservables.observeSelection(enableLabel));
    dataBindingContext.bindValue(SWTObservables.observeEnabled(allowHTMLButton),
            SWTObservables.observeSelection(enableLabel));
}

From source file:org.bonitasoft.studio.properties.form.sections.options.contributions.ReadOnlyContribution.java

License:Open Source License

public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory,
        ExtensibleGridPropertySection extensibleGridPropertySection) {
    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, false, true);
    composite.setLayoutData(gridData);//from   w  w w.j  a  v  a 2  s.c o m
    composite.setLayout(new GridLayout(1, false));
    check = widgetFactory.createButton(composite, "", SWT.CHECK);
    if (dataBinding != null) {
        dataBinding.dispose();
        dataBinding = null;
    }
    if (ModelHelper.getForm((Widget) eObject) instanceof ViewForm) {
        check.setEnabled(false);
        check.setSelection(true);
    } else {
        dataBinding = new DataBindingContext();
        dataBinding.bindValue(SWTObservables.observeSelection(check), EMFEditObservables
                .observeValue(editingDomain, eObject, FormPackage.Literals.WIDGET__READ_ONLY));
    }
}

From source file:org.bonitasoft.studio.properties.sections.document.DocumentPropertySection.java

License:Open Source License

protected void bindDetails(final IObservableValue documentSelected) {
    if (nameBinding != null) {
        nameBinding.dispose();/*from  w w  w .j  a v  a2  s  .c o  m*/
    }
    if (decorationSupport != null) {
        decorationSupport.dispose();
    }
    IObservableValue externalUrlObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.DOCUMENT__URL).observeDetail(documentSelected);
    emfDataBindingContext.bindValue(ViewerProperties.singleSelection().observe(documentUrlViewer),
            externalUrlObserved);
    documentUrlViewer.setInput(documentSelected);

    IObservableValue mimeTypeObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.DOCUMENT__MIME_TYPE)
            .observeDetail(documentSelected);
    emfDataBindingContext.bindValue(ViewerProperties.singleSelection().observe(documentMimeTypeViewer),
            mimeTypeObserved);
    documentMimeTypeViewer.setInput(documentSelected);

    final UpdateValueStrategy targetToModel = new UpdateValueStrategy();

    targetToModel.setAfterGetValidator(new InputLengthValidator(Messages.name, 50));
    targetToModel.setBeforeSetValidator(new DocumentNameValidator(documentListViewer));

    final IObservableValue nameObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.ELEMENT__NAME).observeDetail(documentSelected);

    nameBinding = emfDataBindingContext.bindValue(
            SWTObservables.observeDelayedValue(500, SWTObservables.observeText(documentNameText, SWT.Modify)),
            nameObserved, targetToModel, null);

    decorationSupport = ControlDecorationSupport.create(nameBinding, SWT.LEFT);

    nameObserved.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(ValueChangeEvent event) {
            if (documentListViewer != null && !documentListViewer.getList().isDisposed()) {
                documentListViewer.refresh();
            }
        }
    });

    IObservableValue descriptionObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.ELEMENT__DOCUMENTATION)
            .observeDetail(documentSelected);
    emfDataBindingContext.bindValue(SWTObservables.observeDelayedValue(500,
            SWTObservables.observeText(documentDescriptionText, SWT.Modify)), descriptionObserved);

    IObservableValue internalTypeObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.DOCUMENT__IS_INTERNAL)
            .observeDetail(documentSelected);
    emfDataBindingContext.bindValue(SWTObservables.observeSelection(internalCheckbox), internalTypeObserved);

    IObservableValue documentInternalIDObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.DOCUMENT__DEFAULT_VALUE_ID_OF_DOCUMENT_STORE)
            .observeDetail(documentSelected);
    emfDataBindingContext.bindValue(
            SWTObservables.observeDelayedValue(500, SWTObservables.observeText(documentTextId, SWT.Modify)),
            documentInternalIDObserved);

    IObservableValue externalTypeObserved = EMFEditProperties
            .value(getEditingDomain(), ProcessPackage.Literals.DOCUMENT__IS_INTERNAL)
            .observeDetail(documentSelected);
    emfDataBindingContext.bindValue(SWTObservables.observeSelection(externalCheckbox), externalTypeObserved,
            new UpdateValueStrategy() {
                @Override
                public Object convert(Object value) {
                    return super.convert(!(Boolean) value);
                }
            }, new UpdateValueStrategy() {
                @Override
                public Object convert(Object value) {
                    return super.convert(!(Boolean) value);
                }
            });

    emfDataBindingContext.bindValue(SWTObservables.observeEnabled(documentUrlViewer.getTextControl()),
            externalTypeObserved, new UpdateValueStrategy() {
                @Override
                public Object convert(Object value) {
                    return super.convert(!(Boolean) value);
                }
            }, new UpdateValueStrategy() {
                @Override
                public Object convert(Object value) {
                    return super.convert(!(Boolean) value);
                }
            });
    emfDataBindingContext.bindValue(SWTObservables.observeEnabled(documentUrlViewer.getButtonControl()),
            externalTypeObserved, new UpdateValueStrategy() {
                @Override
                public Object convert(Object value) {
                    return super.convert(!(Boolean) value);
                }
            }, new UpdateValueStrategy() {
                @Override
                public Object convert(Object value) {
                    return super.convert(!(Boolean) value);
                }
            });

    emfDataBindingContext.bindValue(SWTObservables.observeEnabled(documentTextId), internalTypeObserved);
    emfDataBindingContext.bindValue(SWTObservables.observeEnabled(browseButton), internalTypeObserved);
}

From source file:org.bonitasoft.studio.properties.sections.forms.EntryFormsSection.java

License:Open Source License

protected void refreshDataBinding() {
    if (thisContext != null) {
        thisContext.dispose();/*from   ww  w . j  a va2 s .  c  o  m*/
    }
    thisContext = new DataBindingContext();

    showOrHideComposite(pageFlowComposite, true);

    IObservableValue isAutoLogin = EMFEditObservables.observeValue(getEditingDomain(), getPageFlow(),
            ProcessPackage.Literals.PROCESS_APPLICATION__AUTO_LOGIN);

    context.bindValue(SWTObservables.observeSelection(autoLoginCheckbox), isAutoLogin);
    activateAutoLoginWarning();
    boolean visible = getPageFlow() instanceof AbstractProcess;
    autoLoginCheckbox.setVisible(visible);
}

From source file:org.bonitasoft.studio.properties.sections.forms.ProcessEntryFormsSection.java

License:Open Source License

@Override
protected void refreshDataBinding() {
    super.refreshDataBinding();

    context.bindValue(/*from  ww w. j  a va2 s .  c  om*/
            SWTObservables.observeSelection(pageFlowRadio), EMFEditObservables.observeValue(getEditingDomain(),
                    getPageFlow(), ProcessPackage.Literals.PAGE_FLOW__ENTRY_PAGE_FLOW_TYPE),
            new UpdateValueStrategy() {
                @Override
                public Object convert(Object object) {
                    return getPageFlowType();
                }
            }, new UpdateValueStrategy() {
                @Override
                public Object convert(Object object) {
                    return object == EntryPageFlowType.PAGEFLOW;
                }
            });
    context.bindValue(
            SWTObservables.observeSelection(skipRadio), EMFEditObservables.observeValue(getEditingDomain(),
                    getPageFlow(), ProcessPackage.Literals.PAGE_FLOW__ENTRY_PAGE_FLOW_TYPE),
            new UpdateValueStrategy() {
                @Override
                public Object convert(Object object) {
                    return getPageFlowType();
                }
            }, new UpdateValueStrategy() {
                @Override
                public Object convert(Object object) {
                    return object == EntryPageFlowType.SKIP;
                }
            });

    showOrHideComposite(pageFlowComposite, getPageFlow().getEntryPageFlowType() == EntryPageFlowType.PAGEFLOW);
}