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

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

Introduction

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

Prototype

@Deprecated
public static ISWTObservableValue observeEnabled(Control control) 

Source Link

Document

Returns an observable value tracking the enabled state of the given control

Usage

From source file:ch.acanda.eclipse.pmd.properties.PMDPropertyPage.java

License:Open Source License

private DataBindingContext initDataBindings() {
    final DataBindingContext bindingContext = new DataBindingContext();
    ////from   ww w  .  j a  v a 2s .  co m
    final IObservableValue btnEnablePmdForObserveSelectionObserveWidget = SWTObservables
            .observeSelection(enablePMDCheckbox);
    final IObservableValue modelPMDEnabledObserveValue = BeansObservables.observeValue(controller.getModel(),
            "PMDEnabled");
    bindingContext.bindValue(btnEnablePmdForObserveSelectionObserveWidget, modelPMDEnabledObserveValue, null,
            null);
    //
    final IObservableValue addObserveEnabledObserveWidget = SWTObservables.observeEnabled(addRuleSet);
    bindingContext.bindValue(addObserveEnabledObserveWidget, modelPMDEnabledObserveValue, null, null);
    //
    return bindingContext;
}

From source file:ch.acanda.eclipse.pmd.properties.RuleSetConfigurationTable.java

License:Open Source License

private void initDataBindings() {
    final DataBindingContext bindingContext = new DataBindingContext();
    ///*from   w w w .  j a  va2s  .  c  om*/
    final ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
    tableViewer.setContentProvider(listContentProvider);
    //
    final IObservableList ruleSetsObserveList = BeansObservables.observeList(Realm.getDefault(), model,
            "ruleSets");
    tableViewer.setInput(ruleSetsObserveList);
    //
    final IObservableValue tableObserveEnabledObserveWidget = SWTObservables.observeEnabled(table);
    final IObservableValue modelPMDEnabledObserveValue = BeansObservables.observeValue(model, "PMDEnabled");
    bindingContext.bindValue(tableObserveEnabledObserveWidget, modelPMDEnabledObserveValue, null, null);
    //
    final IObservableList tableViewerObserveMultiSelection = ViewersObservables
            .observeMultiSelection(tableViewer);
    final IObservableList selectedRuleSetsObserveList = BeansObservables.observeList(Realm.getDefault(), model,
            "selectedRuleSets");
    bindingContext.bindList(tableViewerObserveMultiSelection, selectedRuleSetsObserveList, null, null);
    //
    final IObservableSet tableViewerObserveCheckedElements = ViewersObservables
            .observeCheckedElements(tableViewer, RuleSetViewModel.class);
    final IObservableSet activeConfigurationsObserveSet = BeansObservables.observeSet(Realm.getDefault(), model,
            "activeRuleSets");
    bindingContext.bindSet(tableViewerObserveCheckedElements, activeConfigurationsObserveSet, null, null);
}

From source file:com.muratools.eclipse.wizard.newTheme.NewThemePage.java

License:Apache License

protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    ////from  www .  j a  va2 s  .co  m
    IObservableValue themeSelectObserveEnabledObserveWidget = SWTObservables.observeEnabled(themeSelect);
    IObservableValue btnUseExistingThemeObserveSelectionObserveWidget = SWTObservables
            .observeSelection(btnUseExistingTheme);
    bindingContext.bindValue(themeSelectObserveEnabledObserveWidget,
            btnUseExistingThemeObserveSelectionObserveWidget, null, null);
    //
    return bindingContext;
}

From source file:com.netxforge.netxstudio.screens.f4.AbstractFileBasedMapping.java

License:Open Source License

protected void initDataMappingBinding(EMFDataBindingContext context) {
    // DATA MAPPING COLUMN

    // data row mapping

    IObservableValue firstDataRowObservableValue = SWTObservables.observeText(txtFirstDataRow, SWT.Modify);

    IEMFValueProperty firstDataRowProperty = EMFEditProperties.value(editingService.getEditingDomain(),
            MetricsPackage.Literals.MAPPING__FIRST_DATA_ROW);
    context.bindValue(firstDataRowObservableValue, firstDataRowProperty.observe(mapping), null, null);

    // data columns mapping.
    {/*from   w  w w.j  av  a2s.c om*/
        ObservableListContentProvider listContentProvider = new ObservableListContentProvider();
        this.tblViewerDataColumnMapping.setContentProvider(listContentProvider);

        IObservableSet set = listContentProvider.getKnownElements();

        List<IObservableMap> mapList = Lists.newArrayList();

        mapList.add(
                EMFEditProperties
                        .value(editingService.getEditingDomain(),
                                FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE,
                                        MetricsPackage.Literals.VALUE_DATA_KIND__METRIC_REF))
                        .observeDetail(set));

        mapList.add(
                EMFEditProperties
                        .value(editingService.getEditingDomain(),
                                FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE,
                                        MetricsPackage.Literals.VALUE_DATA_KIND__KIND_HINT))
                        .observeDetail(set));

        mapList.add(
                EMFEditProperties
                        .value(editingService.getEditingDomain(),
                                FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE,
                                        MetricsPackage.Literals.VALUE_DATA_KIND__VALUE_KIND))
                        .observeDetail(set));

        mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
                FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE,
                        MetricsPackage.Literals.VALUE_DATA_KIND__FORMAT))
                .observeDetail(set));

        mapList.add(EMFEditProperties
                .value(editingService.getEditingDomain(),
                        FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE,
                                MetricsPackage.Literals.IDENTIFIER_DATA_KIND__OBJECT_PROPERTY))
                .observeDetail(set));

        mapList.add(EMFEditProperties
                .value(editingService.getEditingDomain(), MetricsPackage.Literals.MAPPING_COLUMN__COLUMN)
                .observeDetail(set));

        IObservableMap[] map = new IObservableMap[mapList.size()];
        mapList.toArray(map);

        this.tblViewerDataColumnMapping.setLabelProvider(new ColumnObservableMapLabelProvider(map));
        IEMFListProperty l = EMFEditProperties.list(editingService.getEditingDomain(),
                MetricsPackage.Literals.MAPPING__DATA_MAPPING_COLUMNS);

        IObservableList dataColumnMappingObservableList = l.observe(mapping);
        this.tblViewerDataColumnMapping.setInput(dataColumnMappingObservableList);
    }

    IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(tblViewerDataColumnMapping);

    ISWTObservableValue observeEnabled = SWTObservables.observeEnabled(dataMappingUpButton);

    context.bindValue(observeSingleSelection, observeEnabled, new UpdateValueStrategy() {

        @Override
        protected IStatus doSet(IObservableValue observableValue, Object value) {

            if (value instanceof MappingColumn) {

                // Find the index of our object on the parent
                @SuppressWarnings("unchecked")
                List<MappingColumn> dataMappingColumns = (List<MappingColumn>) ((MappingColumn) value)
                        .eContainer().eGet(MetricsPackage.Literals.MAPPING__DATA_MAPPING_COLUMNS);

                int indexOf = dataMappingColumns.indexOf(value);

                DataKind dataType = ((MappingColumn) value).getDataType();
                if (dataType instanceof IdentifierDataKind && indexOf > 0) {
                    return super.doSet(observableValue, true);
                }
            }

            return super.doSet(observableValue, false);
        }

    }, null);

    ISWTObservableValue observeEnabledDown = SWTObservables.observeEnabled(dataMappingDownButton);

    context.bindValue(observeSingleSelection, observeEnabledDown, new UpdateValueStrategy() {

        @Override
        protected IStatus doSet(IObservableValue observableValue, Object value) {

            if (value instanceof MappingColumn) {

                // Find the index of our object on the parent
                @SuppressWarnings("unchecked")
                List<MappingColumn> dataMappingColumns = (List<MappingColumn>) ((MappingColumn) value)
                        .eContainer().eGet(MetricsPackage.Literals.MAPPING__DATA_MAPPING_COLUMNS);

                int indexOf = dataMappingColumns.indexOf(value);

                DataKind dataType = ((MappingColumn) value).getDataType();
                if (dataType instanceof IdentifierDataKind && indexOf < dataMappingColumns.size() - 1) {
                    return super.doSet(observableValue, true);
                }
            }

            return super.doSet(observableValue, false);
        }

    }, null);

}

From source file:com.rcpcompany.uibindings.uiAttributes.SimpleUIAttribute.java

License:Open Source License

@Override
public IObservableValue getEnabledValue() {
    Assert.isTrue(!isDisposed());/*from w w  w. j a v a 2 s  .  c  om*/
    if (myWidget instanceof Control) {
        final Control c = (Control) myWidget;
        return addObservable(SWTObservables.observeEnabled(c));
    }
    return null;
}

From source file:de.uniluebeck.itm.spyglass.gui.configuration.BasicGroupComposite.java

License:Open Source License

/**
 * Sets the parameters necessary for data binding
 * /*from www . j  a v  a  2s  .  com*/
 * @param dbc
 *            the data binding context
 * @param config
 *            the configuration
 * @param owner
 * @param manager
 *            the plug-in managing instance
 * @param isInstancePage
 *            <code>true</code> indicates that this widget is used to set parameters for a
 *            plug-in instance, <code>false</code> indicates that this widget is used to set
 *            parameters for a plug-in type.
 * 
 */
public void setDatabinding(final DataBindingContext dbc, final PluginXMLConfig config, final Plugin owner,
        final PluginManager manager, final boolean isInstancePage) {

    // plugin name
    {
        final IObservableValue modelObservable = BeansObservables.observeValue(dbc.getValidationRealm(), config,
                PluginXMLConfig.PROPERTYNAME_NAME);
        final ISWTObservableValue fieldObservableText = SWTObservables.observeText(pluginName, SWT.Modify);

        if (isInstancePage) {
            dbc.bindValue(fieldObservableText, modelObservable,
                    new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                            .setAfterConvertValidator(new PluginNameValidator(manager, owner)),
                    null);

        } else {
            dbc.bindValue(fieldObservableText, modelObservable,
                    new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);

        }
    }

    // semantic types
    {
        final IObservableValue modelObservable2 = BeansObservables.observeValue(dbc.getValidationRealm(),
                config, PluginXMLConfig.PROPERTYNAME_SEMANTIC_TYPES);
        final UpdateValueStrategy strToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        final UpdateValueStrategy strFromModel = new UpdateValueStrategy();
        strFromModel.setConverter(new IntListToStringConverter());
        strToModel.setConverter(new StringToIntListConverter());
        strToModel.setAfterConvertValidator(new IntegerRangeValidator("Semantic types", -1, 255));
        strToModel.setAfterGetValidator(new StringToIntListValidator("Semantic types"));
        dbc.bindValue(SWTObservables.observeText(this.semanticTypes, SWT.Modify), modelObservable2, strToModel,
                strFromModel);
    }

    // all semTypes
    {
        final IObservableValue observableAllSemTypes = BeansObservables.observeValue(dbc.getValidationRealm(),
                config, PluginXMLConfig.PROPERTYNAME_ALL_SEMANTIC_TYPES);
        final IObservableValue observableAllSemTypesCheckbox = SWTObservables.observeSelection(this.allTypes);
        dbc.bindValue(observableAllSemTypesCheckbox, observableAllSemTypes,
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);
    }

    // is visible
    {
        final IObservableValue observableVisible = BeansObservables.observeValue(dbc.getValidationRealm(),
                config, PluginXMLConfig.PROPERTYNAME_VISIBLE);
        dbc.bindValue(SWTObservables.observeSelection(this.isVisible), observableVisible,
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);
    }

    // is active
    {
        final IObservableValue observableActive = BeansObservables.observeValue(dbc.getValidationRealm(),
                config, PluginXMLConfig.PROPERTYNAME_ACTIVE);

        final IObservableValue observableActiveButton = SWTObservables.observeSelection(this.isActive);
        dbc.bindValue(observableActiveButton, observableActive,
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);
    }

    // disable the visibility field if plug-in is inactive
    {
        // ... but only if it's visibility button is not to be disabled all the time
        if (!basicOptions.equals(BasicOptions.ALL_BUT_VISIBLE)
                && !basicOptions.equals(BasicOptions.ALL_BUT_VISIBLE_AND_SEMANTIC_TYPES)) {
            dbc.bindValue(SWTObservables.observeEnabled(this.isVisible),
                    SWTObservables.observeSelection(this.isActive), null, null);
        }

    }
}

From source file:de.uniluebeck.itm.spyglass.gui.SelectPacketSourceDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    startArea = new Composite(parent, SWT.NONE);
    final FillLayout thisLayout = new FillLayout(org.eclipse.swt.SWT.HORIZONTAL);
    startArea.setLayout(thisLayout);/*from   ww  w . jav  a  2s.co  m*/
    final GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    startArea.setLayoutData(gridData);

    final Group group1 = new Group(startArea, SWT.NONE);
    final GridLayout group1Layout = new GridLayout();
    group1Layout.makeColumnsEqualWidth = false;
    group1Layout.numColumns = 3;
    group1.setLayout(group1Layout);
    group1.setText("Sources");

    buttoniShell = new Button(group1, SWT.RADIO);
    buttoniShell.setText("iShell");

    new Label(group1, SWT.NONE);
    new Label(group1, SWT.NONE);

    buttonWiseBed = new Button(group1, SWT.RADIO);
    buttonWiseBed.setText("Testbed");

    new Label(group1, SWT.NONE);
    new Label(group1, SWT.NONE);

    buttonFile = new Button(group1, SWT.RADIO);
    buttonFile.setText("File");

    // disable the button if we're running standalone
    if (!SpyglassEnvironment.isIshellPlugin()) {
        buttoniShell.setEnabled(false);
    }

    final Composite wrapper = new Composite(group1, SWT.BORDER);
    wrapper.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    textPath2File = new Text(wrapper, SWT.BORDER);
    textPath2File.setEditable(false);
    final GC gc = new GC(textPath2File);
    final FontMetrics fm = gc.getFontMetrics();
    final int width = 60 * fm.getAverageCharWidth();
    final int height = fm.getHeight();
    gc.dispose();
    textPath2File.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
    textPath2File.setSize(textPath2File.computeSize(width, height));

    buttonOpenFileDialog = new Button(group1, SWT.NONE);
    buttonOpenFileDialog.setText("...");
    buttonOpenFileDialog.addListener(SWT.Selection, new Listener() {
        @SuppressWarnings("synthetic-access")
        public void handleEvent(final Event event) {
            final FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
            fd.setFilterExtensions(new String[] { "*.rec" });
            fd.setFilterPath(new File(defaultDir).getAbsoluteFile().toString());
            final String path = fd.open();
            if (path != null) {
                textPath2File.setText(path);
            }
        }
    });

    // set up data-binding
    {

        myvalues.setUseIShell(!(spyglass.getPacketReader().getSourceType().equals(SOURCE_TYPE.FILE)));
        final DataBindingContext dbc = new DataBindingContext(
                SWTObservables.getRealm(getParentShell().getDisplay()));

        // binding of select button to use a file and text file with its path
        dbc.bindValue(SWTObservables.observeSelection(buttonFile), SWTObservables.observeEnabled(textPath2File),
                null, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));

        // binding of select button to use a file and open a file selection dialog
        dbc.bindValue(SWTObservables.observeSelection(buttonFile),
                SWTObservables.observeEnabled(buttonOpenFileDialog), null,
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));

        // binding of select button to use a file and the select button to use iShell
        dbc.bindValue(SWTObservables.observeSelection(buttonFile),
                SWTObservables.observeSelection(buttoniShell),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                        .setConverter(new BooleanInversionConverter()),
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT)
                        .setConverter(new BooleanInversionConverter()));

        // bind the button to select iShell to the corresponding property
        final IObservableValue modelObservableIsIshell = BeansObservables.observeValue(dbc.getValidationRealm(),
                myvalues, "useIShell");
        final IObservableValue modelObservableIsTestbed = BeansObservables
                .observeValue(dbc.getValidationRealm(), myvalues, "useTestbed");
        dbc.bindValue(SWTObservables.observeSelection(buttoniShell), modelObservableIsIshell, null, null);
        dbc.bindValue(SWTObservables.observeSelection(buttonWiseBed), modelObservableIsTestbed, null, null);

        // binding of the text field which contains the path to the file to the corresponding
        // string value
        final IObservableValue modelObservable1 = BeansObservables.observeValue(dbc.getValidationRealm(),
                myvalues, "path2File");
        dbc.bindValue(SWTObservables.observeText(textPath2File, SWT.Modify), modelObservable1, null, null);
    }
    initializeValues();
    group1.pack();
    startArea.pack();
    return startArea;
}

From source file:de.uniluebeck.itm.spyglass.plugin.simpleglobalinformation.SimpleGlobalInformationOptionsComposite.java

License:Open Source License

/**
 * Sets the parameters necessary for data binding
 * /*from  w w  w .  j  a  va  2  s .c  om*/
 * @param dbc
 *            the data binding context
 * @param config
 *            the configuration
 */
public void setDatabinding(final DataBindingContext dbc, final SimpleGlobalInformationXMLConfig config) {

    stringFormatter.setDataBinding(dbc);

    // show the total number of available nodes

    final IObservableValue observableshowNN = BeansObservables.observeValue(dbc.getValidationRealm(), config,
            "showNumNodes");
    dbc.bindValue(SWTObservables.observeSelection(this.showNumNodes), observableshowNN,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);

    // semantic types
    {
        final IObservableValue modelObservable2 = BeansObservables.observeValue(dbc.getValidationRealm(),
                config, "semanticTypes4Neighborhoods");
        final UpdateValueStrategy strFromModel = new UpdateValueStrategy();
        strFromModel.setConverter(new IntListToStringConverter());
        final UpdateValueStrategy strToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT);
        strToModel.setConverter(new StringToIntListConverter());
        strToModel.setAfterConvertValidator(new IntegerRangeValidator("Semantic types", -1, 255));
        strToModel.setAfterGetValidator(new StringToIntListValidator("Semantic types"));
        dbc.bindValue(SWTObservables.observeText(this.semanticTypes, SWT.Modify), modelObservable2, strToModel,
                strFromModel);
    }

    // show the average node degree
    final IObservableValue observableshowAVGND = BeansObservables.observeValue(dbc.getValidationRealm(), config,
            "showNodeDegree");
    dbc.bindValue(SWTObservables.observeSelection(this.showAVGNodeDegree), observableshowAVGND,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null);

    // if the average node degree is not to be shown, disable the semantic types field
    {
        dbc.bindValue(SWTObservables.observeSelection(this.showAVGNodeDegree),
                SWTObservables.observeEnabled(this.semanticTypes), null,
                new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));

        semanticTypes.setEnabled(showAVGNodeDegree.getSelection());
    }

}

From source file:de.walware.statet.nico.ui.util.TrackingConfigurationComposite.java

License:Open Source License

protected void addBindings(final DataBindingSupport db) {
    if (fNameControl != null) {
        db.getContext().bindValue(SWTObservables.observeText(fNameControl, SWT.Modify),
                BeansObservables.observeValue(fInput, "name"), //$NON-NLS-1$
                new UpdateValueStrategy().setAfterGetValidator(
                        new NotEmptyValidator(Messages.Tracking_Name_error_Missing_message)),
                null);/*from   ww w.j a va  2  s .  c  o m*/
    }

    final IObservableValue infoUIObs = SWTObservables.observeSelection(fStreamInfoControl);
    db.getContext().bindValue(infoUIObs, BeansObservables.observeValue(fInput, "trackStreamInfo")); //$NON-NLS-1$

    final IObservableValue inputUIObs = SWTObservables.observeSelection(fStreamInputControl);
    db.getContext().bindValue(inputUIObs, BeansObservables.observeValue(fInput, "trackStreamInput")); //$NON-NLS-1$
    if (fStreamInputHistoryOnlyControl != null) {
        db.getContext().bindValue(SWTObservables.observeEnabled(fStreamInputHistoryOnlyControl), inputUIObs);
        db.getContext().bindValue(SWTObservables.observeSelection(fStreamInputHistoryOnlyControl),
                BeansObservables.observeValue(fInput, "trackStreamInputHistoryOnly")); //$NON-NLS-1$
    }

    final IObservableValue outputUIObs = SWTObservables.observeSelection(fStreamOutputErrorControl);
    final IObservableValue outputModelObs = BeansObservables.observeValue(fInput, "trackStreamOutput"); //$NON-NLS-1$
    db.getContext().bindValue(outputUIObs, outputModelObs);
    if (fStreamOutputErrorTruncateControl != null) {
        final IObservableValue outputTruncateUIObs = SWTObservables
                .observeSelection(fStreamOutputErrorTruncateControl);
        final IObservableValue outputTruncateModelObs = BeansObservables.observeValue(fInput,
                "trackStreamOutputTruncate"); //$NON-NLS-1$
        db.getContext().bindValue(SWTObservables.observeEnabled(fStreamOutputErrorTruncateControl),
                outputUIObs);
        db.getContext().bindValue(outputTruncateUIObs, outputTruncateModelObs);
        db.getContext().bindValue(SWTObservables.observeEnabled(fStreamOutputErrorTruncateLinesControl),
                new ComputedOnChangeValue(Boolean.class, outputModelObs, outputTruncateModelObs) {
                    @Override
                    protected Object calculate() {
                        final Boolean one = (Boolean) outputModelObs.getValue();
                        final Boolean two = (Boolean) outputTruncateModelObs.getValue();
                        return Boolean.valueOf(one.booleanValue() && two.booleanValue());
                    }
                });
        db.getContext().bindValue(
                SWTObservables.observeText(fStreamOutputErrorTruncateLinesControl, SWT.Modify),
                BeansObservables.observeValue(fInput, "trackStreamOutputTruncateLines"), //$NON-NLS-1$
                new UpdateValueStrategy().setAfterGetValidator(new IntegerValidator(2, 1000000,
                        Messages.Tracking_OutputStream_TruncateLines_error_Invalid_message)),
                null);
    }

    if (fSubmitTypeControl != null) {
        db.getContext().bindValue(fSubmitTypeControl.getObservable(),
                BeansObservables.observeValue(fInput, "submitTypes")); //$NON-NLS-1$
    }

    db.getContext().bindValue(fFilePathControl.getObservable(),
            BeansObservables.observeValue(fInput, "filePath"), //$NON-NLS-1$
            new UpdateValueStrategy().setAfterGetValidator(fFilePathControl.getValidator()), null);
    final IObservableValue fileModeModelObs = BeansObservables.observeValue(fInput, "fileMode"); //$NON-NLS-1$
    db.getContext().bindValue(SWTObservables.observeSelection(fFileAppendControl),
            new ComputedOnChangeValue(Boolean.class, fileModeModelObs) {
                @Override
                protected Object calculate() {
                    final Integer mode = (Integer) fileModeModelObs.getValue();
                    return Boolean.valueOf((mode.intValue() & EFS.APPEND) == EFS.APPEND);
                }

                @Override
                protected void extractAndSet(final Object value) {
                    final Boolean selected = (Boolean) value;
                    fileModeModelObs.setValue(selected.booleanValue() ? EFS.APPEND : EFS.NONE);
                }
            });
    db.getContext().bindValue(SWTObservables.observeSelection(fFileOverwriteControl),
            new ComputedOnChangeValue(Boolean.class, fileModeModelObs) {
                @Override
                protected Object calculate() {
                    final Integer mode = (Integer) fileModeModelObs.getValue();
                    return Boolean.valueOf((mode.intValue() & EFS.OVERWRITE) == EFS.OVERWRITE);
                }

                @Override
                protected void extractAndSet(final Object value) {
                    final Boolean selected = (Boolean) value;
                    fileModeModelObs.setValue(selected.booleanValue() ? EFS.OVERWRITE : EFS.NONE);
                }
            });

    if (fPrependTimestampControl != null) {
        db.getContext().bindValue(SWTObservables.observeSelection(fPrependTimestampControl),
                BeansObservables.observeValue(fInput, "prependTimestamp")); //$NON-NLS-1$
    }
}

From source file:de.walware.statet.r.internal.debug.ui.breakpoints.RLineBreakpointDetailEditor.java

License:Open Source License

@Override
protected void addBindings(final DataBindingContext dbc, final Realm realm) {
    super.addBindings(dbc, realm);

    fConditionEnabledValue = new WritableValue(realm, Boolean.FALSE, Boolean.class);
    fConditionCodeValue = new WritableValue(realm, "", String.class);

    enableAutosave(// www  .  j a  va 2s .c o m
            dbc.bindValue(SWTObservables.observeSelection(fConditionEnabledControl), fConditionEnabledValue));
    dbc.bindValue(SWTObservables.observeText(fConditionCodeEditor.getTextControl(), SWT.Modify),
            fConditionCodeValue);
    dbc.bindValue(SWTObservables.observeEnabled(fConditionCodeEditor.getTextControl()), fConditionEnabledValue);
}