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: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);// w w  w .j a va2  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.console.ui.launching.RConsoleOptionsTab.java

License:Open Source License

@Override
protected void addBindings(final DataBindingContext dbc, final Realm realm) {
    fPinValue = new WritableValue(realm, Boolean.class);
    dbc.bindValue(SWTObservables.observeSelection(fPinControl), fPinValue, null, null);

    fTrackingList = new WritableList(realm, new ArrayList<Object>(), TrackingConfiguration.class);
    fTrackingTable.setContentProvider(new ObservableListContentProvider());
    fTrackingTable.setInput(fTrackingList);

    fStartupSnippetValue = new WritableValue(realm, String.class);
    dbc.bindValue(new SnippetEditorObservable(realm, fStartupSnippetEditor, SWT.Modify), fStartupSnippetValue,
            null, null);//from   w  ww. j a v  a  2 s . c om

    fRHelpByStatetValue = new WritableValue(realm, Boolean.class);
    fRGraphicsByStatetValue = new WritableValue(realm, Boolean.class);
    fRDbgExtValue = new WritableValue(realm, Boolean.class);
    dbc.bindValue(SWTObservables.observeSelection(fRHelpByStatetControl), fRHelpByStatetValue, null, null);
    dbc.bindValue(SWTObservables.observeSelection(fRGraphicsByStatetControl), fRGraphicsByStatetValue, null,
            null);
    dbc.bindValue(SWTObservables.observeSelection(fRDbgExtControl), fRDbgExtValue, null, null);

    fObjectDBEnabledValue = new WritableValue(realm, Boolean.class);
    fObjectDBAutoEnabledValue = new WritableValue(realm, Boolean.class);
    fObjectDBListsChildrenValue = new WritableValue(realm, Integer.class);
    fObjectDBEnvsChildrenValue = new WritableValue(realm, Integer.class);
    final ISWTObservableValue dbObs = SWTObservables.observeSelection(fObjectDBEnabledControl);
    dbc.bindValue(dbObs, fObjectDBEnabledValue, null, null);
    dbc.bindValue(SWTObservables.observeSelection(fObjectDBAutoEnabledControl), fObjectDBAutoEnabledValue, null,
            null);
    dbc.bindValue(SWTObservables.observeText(fObjectDBListsChildrenControl, SWT.Modify),
            fObjectDBListsChildrenValue,
            new UpdateValueStrategy().setAfterGetValidator(new IntegerValidator(100, Integer.MAX_VALUE,
                    "Invalid max value for length of R lists to fetch (100-).")),
            null);
    dbc.bindValue(SWTObservables.observeText(fObjectDBEnvsChildrenControl, SWT.Modify),
            fObjectDBEnvsChildrenValue, new UpdateValueStrategy().setAfterGetValidator(new IntegerValidator(100,
                    Integer.MAX_VALUE, "Invalid max value for length of R environments to fetch (100-).")),
            null);

    dbc.bindValue(new SWTMultiEnabledObservable(realm, new Control[] { fObjectDBAutoEnabledControl,
            fObjectDBEnvsChildrenControl, fObjectDBListsChildrenControl, }, null), dbObs, null, null);

    fTrackingButtons.connectTo(fTrackingTable,
            new DataAdapter.ListAdapter<TrackingConfiguration>(fTrackingList, null) {
                @Override
                public boolean isDeleteAllowed(final Object element) {
                    return (super.isDeleteAllowed(element)
                            && ((TrackingConfiguration) element).getId().startsWith(CUSTOM_TRACKING_ID_PREFIX));
                }
            });

    fTrackingEnabledSet = new WritableSet(realm, new HashSet<Object>(), TrackingConfiguration.class);
    fTrackingButtons.setCheckedModel(fTrackingEnabledSet);
    dbc.bindSet(ViewersObservables.observeCheckedElements(fTrackingTable, TrackingConfiguration.class),
            fTrackingEnabledSet);
}

From source file:de.walware.statet.r.internal.console.ui.launching.RHistoryConfigurationComposite.java

License:Open Source License

@Override
protected void addBindings(final DataBindingSupport db) {
    super.addBindings(db);

    db.getContext().bindValue(SWTObservables.observeSelection(fAutoloadControl),
            BeansObservables.observeValue(getInput(), "loadHistory"));
}

From source file:de.walware.statet.r.internal.console.ui.launching.RRemoteConsoleMainTab.java

License:Open Source License

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

    final MultiValidator validator = new MultiValidator() {
        @Override//from   ww w. j a  va  2  s .com
        protected IStatus validate() {
            // Calculate the validation status
            if (!getType().getId().equals(REMOTE_RJS_RECONNECT)) {
                final String text = (String) fAddressValue.getValue();
                if (text == null || text.isEmpty()) {
                    return ValidationStatus
                            .error("Missing address for R remote engine ('//host[:port]/rsessionname').");
                }
                try {
                    RMIAddress.validate(text);
                } catch (final MalformedURLException e) {
                    return ValidationStatus
                            .error("Invalid address for R remote engine: " + e.getLocalizedMessage());
                }
            }
            return ValidationStatus.ok();
        }
    };

    final WritableValue addressValue1 = new WritableValue("", String.class); //$NON-NLS-1$
    dbc.bindValue(SWTObservables.observeText(fAddressControl, SWT.Modify), addressValue1, null, null);
    validator.observeValidatedValue(addressValue1);
    fAddressValue = new WritableValue("", String.class);
    dbc.bindValue(addressValue1, fAddressValue, null, null);

    fUserValue = new WritableValue("", String.class);
    dbc.bindValue(SWTObservables.observeText(fUsernameControl, SWT.Modify), fUserValue, null, null);

    fSshPortValue = new WritableValue(null, Integer.class);
    dbc.bindValue(SWTObservables.observeText(fSshPortControl, SWT.Modify), fSshPortValue,
            new UpdateValueStrategy().setAfterGetValidator(
                    new IntegerValidator(0, 65535, true, "Invalid SSH port number specified (0-65535).")),
            null);
    fSshTunnelValue = new WritableValue(false, Boolean.TYPE);
    dbc.bindValue(SWTObservables.observeSelection(fSshTunnelControl), fSshTunnelValue, null, null);

    fCommandValue = new WritableValue("", String.class);
    dbc.bindValue(SWTObservables.observeText(fCommandControl, SWT.Modify), fCommandValue, null, null);

    fSshAddressValue = new WritableValue();
    dbc.bindValue(SWTObservables.observeText(fSshAddress, SWT.Modify), fSshAddressValue, null, null);

    fAddressValue.addValueChangeListener(fUpdateJob);
    fUserValue.addValueChangeListener(fUpdateJob);
    fSshPortValue.addValueChangeListener(fUpdateJob);

    dbc.addValidationStatusProvider(validator);
    validator.observeValidatedValue(getTypeValue());
}

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(/*from  w  w  w . 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);
}

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

License:Open Source License

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

    fEntryValue = new WritableValue(realm, Boolean.FALSE, Boolean.class);
    fExitValue = new WritableValue(realm, Boolean.FALSE, Boolean.class);

    enableAutosave(dbc.bindValue(SWTObservables.observeSelection(fEntryControl), fEntryValue));
    enableAutosave(dbc.bindValue(SWTObservables.observeSelection(fExitControl), fExitValue));
}

From source file:de.walware.statet.r.internal.debug.ui.preferences.REnvPreferencePage.java

License:Open Source License

@Override
protected void addBindings(final DataBindingSupport db) {
    db.getContext().bindValue(ViewersObservables.observeSingleSelection(fIndexConsoleViewer),
            createObservable(RRunDebugPreferenceConstants.PREF_RENV_CHECK_UPDATE));
    db.getContext().bindValue(SWTObservables.observeSelection(fNetworkEclipseControl),
            createObservable(RCorePreferenceNodes.PREF_RENV_NETWORK_USE_ECLIPSE));
}

From source file:de.walware.statet.r.internal.sweave.processing.TexTab.java

License:Open Source License

@Override
protected void addBindings(final DataBindingContext dbc, final Realm realm) {
    fOpenTexEnabledValue = new WritableValue(realm, false, Boolean.class);
    fOpenTexOnErrorsEnabledValue = new WritableValue(realm, false, Boolean.class);
    fOutputDirValue = new WritableValue(realm, null, String.class);
    fBuildTexTypeValue = new WritableValue(realm, 0, Integer.class);
    fBuildTexBuilderIdValue = new WritableValue(realm, 0, Integer.class);
    fBuildTexRCommandsValue = new WritableValue(realm, "", String.class); //$NON-NLS-1$
    fOutputFormatValue = new WritableValue(realm, "", String.class); //$NON-NLS-1$

    final ISWTObservableValue openObs = SWTObservables.observeSelection(fOpenTexFileControl);
    dbc.bindValue(openObs, fOpenTexEnabledValue, null, null);
    dbc.bindValue(SWTObservables.observeSelection(fOpenTexFileOnErrorsControl), fOpenTexOnErrorsEnabledValue,
            null, null);/*from w w  w.j a  v  a  2 s .co  m*/
    dbc.bindValue(new RadioGroupObservable(realm,
            new Button[] { fBuildTexFileDisabledControl, fBuildTexFileEclipseControl, fBuildTexFileRControl }),
            fBuildTexTypeValue, null, null);
    dbc.bindValue(new BuildChooserObservable(fBuildTexTypeChooser), fBuildTexBuilderIdValue, null, null);
    dbc.bindValue(SWTObservables.observeText(fConsoleCommandEditor.getTextControl(), SWT.Modify),
            fBuildTexRCommandsValue, null, null);
    dbc.bindValue(SWTObservables.observeText(fOutputFormatControl), fOutputFormatValue);

    fBuildTexBuilderIdValue.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            updateFormat();
        }
    });
    fBuildTexTypeValue.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Object newValue = event.diff.getNewValue();
            final int typeId = (newValue instanceof Integer) ? ((Integer) newValue).intValue() : -1;
            switch (typeId) {
            case BUILDTEX_TYPE_ECLIPSE:
                updateFormat();
                break;
            case BUILDTEX_TYPE_RCONSOLE:
                if (RweaveTexLaunchDelegate.DEFAULT_BUILDTEX_R_COMMANDS
                        .equals(fBuildTexRCommandsValue.getValue())) {
                    fOutputFormatValue.setValue(RweaveTexLaunchDelegate.DEFAULT_BUILDTEX_FORMAT);
                }
                break;
            }

        }
    });

    // Enablement
    dbc.bindValue(SWTObservables.observeEnabled(fOpenTexFileOnErrorsControl), openObs, null, null);
    final Composite group = fBuildTexTypeChooser.getControl();
    dbc.bindValue(new SWTMultiEnabledObservable(realm, group.getChildren(), null),
            new ComputedValue(realm, Boolean.class) {
                @Override
                protected Object calculate() {
                    return (((Integer) fBuildTexTypeValue
                            .getValue()) == RweaveTexLaunchDelegate.BUILDTEX_TYPE_ECLIPSE);
                }
            }, null, null);
    dbc.bindValue(
            new SWTMultiEnabledObservable(realm, new Control[] { fConsoleCommandEditor.getControl() }, null),
            new ComputedValue(realm, Boolean.class) {
                @Override
                protected Object calculate() {
                    return (((Integer) fBuildTexTypeValue
                            .getValue()) == RweaveTexLaunchDelegate.BUILDTEX_TYPE_RCONSOLE);
                }
            }, null, null);
    dbc.bindValue(new SWTMultiEnabledObservable(realm, new Control[] { fOutputFormatControl }, null),
            new ComputedValue(realm, Boolean.class) {
                @Override
                protected Object calculate() {
                    return (((Integer) fBuildTexTypeValue
                            .getValue()) != RweaveTexLaunchDelegate.BUILDTEX_TYPE_ECLIPSE);
                }
            }, null, null);

    dbc.bindValue(fOutputDirControl.getObservable(), fOutputDirValue,
            new UpdateValueStrategy().setAfterGetValidator(fOutputDirControl.getValidator()), null);
}

From source file:de.walware.statet.r.internal.sweave.ui.preferences.SweaveEditorPreferencePage.java

License:Open Source License

@Override
protected void addBindings(final DataBindingSupport db) {
    db.getContext().bindValue(SWTObservables.observeSelection(fMarkOccurrencesControl),
            createObservable(SweaveEditorOptions.MARKOCCURRENCES_ENABLED_PREF));

    db.getContext().bindValue(SWTObservables.observeSelection(fSpellEnableControl),
            createObservable(SweaveEditorOptions.PREF_SPELLCHECKING_ENABLED));
}

From source file:de.walware.statet.r.internal.ui.datafilterview.IntervalClient.java

License:Open Source License

@Override
protected void addBindings(final DataBindingSupport db) {
    if (fFilter.getColumn().getDataStore().getStoreType() == RStore.NUMERIC) {
        final IConverter text2value = new Text2NumConverter();
        final IConverter value2text = new Num2TextConverter();
        //         {   RDataFormatter colFormatter = fFilter.getColumn().getDefaultFormat();
        //            if (colFormatter != null && colFormatter.hasNumFormat()) {
        //               RDataFormatter textFormatter = new RDataFormatter();
        //               textFormatter.initNumFormat(colFormatter.getMaxFractionalDigits() + 1,
        //                     colFormatter.getMaxExponentDigits() );
        //               value2text = new RDataFormatterConverter(Double.TYPE, textFormatter);
        //            }
        //         }
        final IntValue2Double2TextBinding.LowerUpperGroup group = new IntValue2Double2TextBinding.LowerUpperGroup(
                fScaleControl, fLowerBoundControl, fUpperBoundControl, db.getRealm(), value2text, text2value);
        db.getContext().bindValue(group.getLower(), fFilter.getSelectedLowerValue());
        db.getContext().bindValue(group.getUpper(), fFilter.getSelectedUpperValue());
        fLowerUpperGroup = group;/*from  w w  w .j av  a  2 s. com*/
    } else {
        final IConverter text2value = new Text2IntConverter();
        final IConverter value2text = new Int2TextConverter();
        final IntValue2TextBinding.LowerUpperGroup group = new IntValue2TextBinding.LowerUpperGroup(
                fScaleControl, fLowerBoundControl, fUpperBoundControl, db.getRealm(), value2text, text2value);
        db.getContext().bindValue(group.getLower(), fFilter.getSelectedLowerValue());
        db.getContext().bindValue(group.getUpper(), fFilter.getSelectedUpperValue());
        fLowerUpperGroup = group;
    }
    db.getContext().bindValue(SWTObservables.observeSelection(fNAControl), fFilter.getSelectedNA());
}