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.switchyard.tools.ui.editor.components.camel.netty.CamelNettyUDPComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelNettyUdpBindingType.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("Netty binding name should not be empty", Status.WARNING)),
            null);//from   ww w  . j a  v  a  2s .co  m
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding = context.bindValue(SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("Netty binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_hostText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    NettyPackage.Literals.CAMEL_NETTY_BINDING_TYPE__HOST),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new StringEmptyValidator(Messages.error_emptyHost)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    CompoundValidator portValidator = new CompoundValidator(new StringEmptyValidator(Messages.error_emptyPort),
            new EscapedPropertyIntegerValidator(
                    "Port must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}')."));

    binding = context.bindValue(SWTObservables.observeText(_portText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    NettyPackage.Literals.CAMEL_NETTY_BINDING_TYPE__PORT),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(portValidator),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_broadcastCheckbox),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    NettyPackage.Literals.CAMEL_NETTY_UDP_BINDING_TYPE__BROADCAST),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    if (_opSelectorComposite != null) {
        _opSelectorComposite.bindControls(domain, context);
    }
}

From source file:org.switchyard.tools.ui.editor.components.camel.rss.CamelRSSConsumerComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelRSSBindingType.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("RSS binding name should not be empty", Status.WARNING)),
            null);// w  w w  . j  a v a  2  s  .c o m
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding = context.bindValue(SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("RSS binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    CompoundValidator uriValidator = new CompoundValidator(
            new StringEmptyValidator("Feed URI may not be empty."),
            new URLValidator("Potential problem with Feed URI"));

    binding = context.bindValue(SWTObservables.observeText(_feedURIText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__FEED_URI),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(uriValidator),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    final IObservableValue splitEntriesCheckboxValue = SWTObservables.observeSelection(_splitEntriesCheckbox);
    final IObservableValue filterValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__FILTER);
    final IObservableValue lastUpdateValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__LAST_UPDATE);
    final IObservableValue sortEntriesValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__SORT_ENTRIES);

    binding = context.bindValue(splitEntriesCheckboxValue,
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__SPLIT_ENTRIES),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    _splitEntriesCheckbox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            _filterCheckbox.setEnabled(_splitEntriesCheckbox.getSelection());
            _lastUpdateText.setEnabled(_splitEntriesCheckbox.getSelection());
            _sortEntriesCheckbox.setEnabled(_splitEntriesCheckbox.getSelection());
            if (!_splitEntriesCheckbox.getSelection()) {
                filterValue.setValue(Boolean.TRUE); // default
                lastUpdateValue.setValue(null); // default
                sortEntriesValue.setValue(Boolean.FALSE); // default
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    binding = context.bindValue(SWTObservables.observeSelection(_filterCheckbox), filterValue,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_lastUpdateText, new int[] { SWT.Modify }),
            lastUpdateValue,
            new EMFUpdateValueStrategyNullForEmptyString(
                    "Last Update must match the format yyyy-MM-ddTHH:mm:ss",
                    UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_sortEntriesCheckbox), sortEntriesValue,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    FeaturePath path = FeaturePath.fromList(RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__CONSUME,
            RssPackage.Literals.RSS_SCHEDULED_POLL_CONSUMER_TYPE__DELAY);
    binding = context.bindValue(SWTObservables.observeText(_delayText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);
}

From source file:org.switchyard.tools.ui.editor.components.camel.rss.CamelRSSProducerComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelRSSBindingType.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("RSS binding name should not be empty", Status.WARNING)),
            null);/*from ww  w .ja  v a2 s  . c  om*/
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding = context.bindValue(SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("RSS binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    CompoundValidator uriValidator = new CompoundValidator(
            new StringEmptyValidator("Feed URI may not be empty."),
            new URLValidator("Potential problem with Feed URI"));

    binding = context.bindValue(SWTObservables.observeText(_feedURIText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__FEED_URI),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(uriValidator),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    final IObservableValue splitEntriesCheckboxValue = SWTObservables.observeSelection(_splitEntriesCheckbox);
    final IObservableValue filterValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__FILTER);
    final IObservableValue lastUpdateValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__LAST_UPDATE);
    final IObservableValue sortEntriesValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__SORT_ENTRIES);

    binding = context.bindValue(splitEntriesCheckboxValue,
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    RssPackage.Literals.CAMEL_RSS_BINDING_TYPE__SPLIT_ENTRIES),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    _splitEntriesCheckbox.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            _filterCheckbox.setEnabled(_splitEntriesCheckbox.getSelection());
            _lastUpdateText.setEnabled(_splitEntriesCheckbox.getSelection());
            _sortEntriesCheckbox.setEnabled(_splitEntriesCheckbox.getSelection());
            if (!_splitEntriesCheckbox.getSelection()) {
                filterValue.setValue(Boolean.TRUE); // default
                lastUpdateValue.setValue(null); // default
                sortEntriesValue.setValue(Boolean.FALSE); // default
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });

    binding = context.bindValue(SWTObservables.observeSelection(_filterCheckbox), filterValue,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_lastUpdateText, new int[] { SWT.Modify }),
            lastUpdateValue,
            new EMFUpdateValueStrategyNullForEmptyString(
                    "Last Update must match the format yyyy-MM-ddTHH:mm:ss",
                    UpdateValueStrategy.POLICY_CONVERT),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_sortEntriesCheckbox), sortEntriesValue,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);
}

From source file:org.switchyard.tools.ui.editor.components.camel.sap.CamelSAPComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelSqlBindingType.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new StringEmptyValidator(
                            Messages.CamelSAPComposite_Binding_name_empty_warning, Status.WARNING)),
            null);// ww  w.j a v  a  2 s  .  com
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding = context.bindValue(SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new StringEmptyValidator(
                            Messages.CamelSAPComposite_Binding_name_empty_warning, Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    if (_serverText != null && !_serverText.isDisposed()) {
        binding = context.bindValue(SWTObservables.observeText(_serverText, new int[] { SWT.Modify }),
                ObservablesUtil.observeDetailValue(domain, _bindingValue,
                        SapPackage.Literals.CAMEL_SAP_BINDING_TYPE__SERVER),
                new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                        .setAfterConvertValidator(
                                new StringEmptyValidator(Messages.CamelSAPComposite_Server_name_empty_error)),
                null);
        ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);
    }

    if (_destinationText != null && !_destinationText.isDisposed()) {
        binding = context.bindValue(SWTObservables.observeText(_destinationText, new int[] { SWT.Modify }),
                ObservablesUtil.observeDetailValue(domain, _bindingValue,
                        SapPackage.Literals.CAMEL_SAP_BINDING_TYPE__DESTINATION),
                new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                        .setAfterConvertValidator(new StringEmptyValidator(
                                Messages.CamelSAPComposite_Destination_name_empty_error)),
                null);
        ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);
    }

    binding = context.bindValue(SWTObservables.observeText(_rfcNameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    SapPackage.Literals.CAMEL_SAP_BINDING_TYPE__RFC_NAME),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator(Messages.CamelSAPComposite_RFC_name_empty_error)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_transactedCheckbox),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    SapPackage.Literals.CAMEL_SAP_BINDING_TYPE__TRANSACTED),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);
}

From source file:org.switchyard.tools.ui.editor.components.camel.sftp.CamelSFTPConsumerComposite.java

License:Open Source License

private void bindConsumerControls(final DataBindingContext context, final EditingDomain domain) {
    FeaturePath path = FeaturePath.fromList(FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__CONSUME,
            FtpPackage.Literals.REMOTE_FILE_CONSUMER_TYPE__INCLUDE);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_includeText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path = FeaturePath.fromList(FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__CONSUME,
            FtpPackage.Literals.REMOTE_FILE_CONSUMER_TYPE__EXCLUDE);

    binding = context.bindValue(SWTObservables.observeText(_excludeText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path = FeaturePath.fromList(FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__CONSUME,
            FtpPackage.Literals.REMOTE_FILE_CONSUMER_TYPE__DELETE);
    binding = context.bindValue(SWTObservables.observeSelection(_deleteButton),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path = FeaturePath.fromList(FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__CONSUME,
            FtpPackage.Literals.REMOTE_FILE_CONSUMER_TYPE__RECURSIVE);
    binding = context.bindValue(SWTObservables.observeSelection(_recursiveButton),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

}

From source file:org.switchyard.tools.ui.editor.components.camel.sftp.CamelSFTPConsumerComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelSftpBindingType.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("SFTP binding name should not be empty", Status.WARNING)),
            null);/*from  w ww . j  ava  2 s .  c  om*/
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding = context.bindValue(SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("SFTP binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_directoryText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__DIRECTORY),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new StringEmptyValidator(Messages.error_emptyDirectory)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_fileNameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__FILE_NAME),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_hostText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__HOST),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_portText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PORT),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new EscapedPropertyIntegerValidator(
                            "Port must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').")),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_usernameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__USERNAME),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_pwdText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PASSWORD),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_autoCreateButton),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__AUTO_CREATE),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_binaryButton),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__BINARY),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    bindConsumerControls(context, domain);

    _opSelectorComposite.bindControls(domain, context);
}

From source file:org.switchyard.tools.ui.editor.components.camel.sftp.CamelSFTPProducerComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_nameText.getDisplay());

    _bindingValue = new WritableValue(realm, null, CamelFtpsBindingType.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("SFTP binding name should not be empty", Status.WARNING)),
            null);//from   www.j a v a 2s .  co  m
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    /*
     * we also want to bind the name field to the binding name. note that
     * the model to target updater is configured to NEVER update. we want
     * the camel binding name to be the definitive source for this field.
     */
    binding = context.bindValue(SWTObservables.observeText(_nameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_Name()),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(
                            new StringEmptyValidator("SFTP binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_directoryText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__DIRECTORY),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new StringEmptyValidator(Messages.error_emptyDirectory)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_fileNameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__FILE_NAME),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_hostText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__HOST),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_portText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PORT),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_usernameText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__USERNAME),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_pwdText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PASSWORD),
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_autoCreateButton),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__AUTO_CREATE),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeSelection(_binaryButton),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__BINARY),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    FeaturePath path = FeaturePath.fromList(FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PRODUCE,
            FtpPackage.Literals.REMOTE_FILE_PRODUCER_TYPE__TEMP_PREFIX);

    binding = context.bindValue(SWTObservables.observeText(_tempPrefixText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    path = FeaturePath.fromList(FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PRODUCE,
            FtpPackage.Literals.REMOTE_FILE_PRODUCER_TYPE__FILE_EXIST);

    binding = context.bindValue(SWTObservables.observeText(_fileExistText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

}

From source file:org.switchyard.tools.ui.editor.components.http.HttpAuthenticationComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_authTypeCombo.getCombo().getDisplay());

    _bindingValue = new WritableValue(realm, null, HTTPBindingType.class);
    final IObservableValue authType = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthUser = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthPwd = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthRealm = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthHost = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthPort = new WritableValue(realm, null, String.class);
    final IObservableValue ntlmAuthDomain = new WritableValue(realm, null, String.class);

    org.eclipse.core.databinding.Binding binding = context
            .bindValue(SWTObservables.observeSelection(_authTypeCombo.getCombo()), authType);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authUserText, SWT.Modify), basicAuthUser,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authPasswordText, SWT.Modify), basicAuthPwd,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authRealmText, SWT.Modify), basicAuthRealm,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authHostText, SWT.Modify), basicAuthHost,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authPortText, SWT.Modify), basicAuthPort,
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new EscapedPropertyIntegerValidator(
                            "Port must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').")),
            null);//from  ww  w  .ja v  a  2s .c o  m
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authDomainText, SWT.Modify), ntlmAuthDomain,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    final IObservableValue computed = new AuthComputedValue(authType, basicAuthUser, basicAuthPwd,
            basicAuthRealm, basicAuthHost, basicAuthPort, ntlmAuthDomain);
    final IObservableValue ntlmValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            HttpPackage.Literals.HTTP_BINDING_TYPE__NTLM);
    final IObservableValue basicValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            HttpPackage.Literals.HTTP_BINDING_TYPE__BASIC);
    final org.eclipse.core.databinding.Binding ntlmBinding = context.bindValue(computed, ntlmValue,
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST),
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST));
    final org.eclipse.core.databinding.Binding basicBinding = context.bindValue(computed, basicValue,
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST),
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST));

    final IValueChangeListener changeListener = new IValueChangeListener() {
        private boolean _updating = false;

        public void handleValueChange(ValueChangeEvent event) {
            if (!_updating) {
                _updating = true;
                if (event.getSource() == ntlmValue || event.getSource() == basicValue) {
                    if (ntlmValue.getValue() == null) {
                        // default to basic
                        basicBinding.updateModelToTarget();
                    } else {
                        ntlmBinding.updateModelToTarget();
                    }
                } else {
                    // computed
                    // we might want to do this using a command if domain != null, so the changes are atomic
                    if (computed.getValue() instanceof NTLMAuthenticationType) {
                        ntlmBinding.updateTargetToModel();
                        basicValue.setValue(null);
                    } else {
                        basicBinding.updateTargetToModel();
                        ntlmValue.setValue(null);
                    }
                }
                _updating = false;
            }
        }
    };

    IDisposeListener disposeListener = new IDisposeListener() {
        public void handleDispose(DisposeEvent event) {
            ((IObservableValue) event.getSource()).removeValueChangeListener(changeListener);
        }
    };

    computed.addValueChangeListener(changeListener);
    ntlmValue.addValueChangeListener(changeListener);
    basicValue.addValueChangeListener(changeListener);

    computed.addDisposeListener(disposeListener);
    ntlmValue.addDisposeListener(disposeListener);
    basicValue.addDisposeListener(disposeListener);
}

From source file:org.switchyard.tools.ui.editor.components.jca.JCAInteractionDetailsComposite.java

License:Open Source License

private void bindControls(DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_stackComposite.getDisplay());

    _bindingValue = new WritableValue(realm, null, JCABinding.class);

    final FeaturePath batchSizeFeaturePath = FeaturePath.fromList(
            JcaPackage.Literals.JCA_BINDING__INBOUND_INTERACTION,
            JcaPackage.Literals.JCA_INBOUND_INTERACTION__BATCH_COMMIT,
            JcaPackage.Literals.BATCH_COMMIT__BATCH_SIZE);
    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_batchSizeText, SWT.Modify),
            EMFProperties.value(batchSizeFeaturePath).observeDetail(_bindingValue),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT, domain,
                    _bindingValue, batchSizeFeaturePath, true),
            null);//ww  w  . j  ava2s .  co m
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    final FeaturePath batchTimeoutFeaturePath = FeaturePath.fromList(
            JcaPackage.Literals.JCA_BINDING__INBOUND_INTERACTION,
            JcaPackage.Literals.JCA_INBOUND_INTERACTION__BATCH_COMMIT,
            JcaPackage.Literals.BATCH_COMMIT__BATCH_TIMEOUT);
    binding = context.bindValue(SWTObservables.observeText(_batchTimeoutText, SWT.Modify),
            EMFProperties.value(batchTimeoutFeaturePath).observeDetail(_bindingValue),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT, domain,
                    _bindingValue, batchTimeoutFeaturePath, true),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    final FeaturePath transactedFeaturePath = FeaturePath.fromList(
            JcaPackage.Literals.JCA_BINDING__INBOUND_INTERACTION,
            JcaPackage.Literals.JCA_INBOUND_INTERACTION__TRANSACTED);
    binding = context.bindValue(SWTObservables.observeSelection(_transactedButton),
            EMFProperties.value(transactedFeaturePath).observeDetail(_bindingValue),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_UPDATE, domain,
                    _bindingValue, transactedFeaturePath, false),
            null);

    IObservableValue endpointType = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            FeaturePath.fromList(JcaPackage.Literals.JCA_BINDING__INBOUND_INTERACTION,
                    JcaPackage.Literals.JCA_INBOUND_INTERACTION__ENDPOINT, JcaPackage.Literals.ENDPOINT__TYPE));
    endpointType.addValueChangeListener(new IValueChangeListener() {
        @Override
        public void handleValueChange(ValueChangeEvent event) {
            final EndpointType newExtension = EndpointType.fromEndpointType((String) event.diff.getNewValue());
            if (newExtension != _activeExtension) {
                swapExtensionComposites(newExtension, false);
                _endpointMappingTypeCombo.setSelection(new StructuredSelection(newExtension), true);
            }
        }
    });
}

From source file:org.switchyard.tools.ui.editor.components.resteasy.ResteasyAuthenticationComposite.java

License:Open Source License

private void bindControls(final DataBindingContext context) {
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject());
    final Realm realm = SWTObservables.getRealm(_authTypeCombo.getCombo().getDisplay());

    _bindingValue = new WritableValue(realm, null, RESTBindingType.class);
    final IObservableValue authType = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthUser = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthPwd = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthRealm = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthHost = new WritableValue(realm, null, String.class);
    final IObservableValue basicAuthPort = new WritableValue(realm, null, String.class);
    final IObservableValue ntlmAuthDomain = new WritableValue(realm, null, String.class);

    org.eclipse.core.databinding.Binding binding = context
            .bindValue(SWTObservables.observeSelection(_authTypeCombo.getCombo()), authType);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authUserText, SWT.Modify), basicAuthUser,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authPasswordText, SWT.Modify), basicAuthPwd,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authRealmText, SWT.Modify), basicAuthRealm,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authHostText, SWT.Modify), basicAuthHost,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authPortText, SWT.Modify), basicAuthPort,
            new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new EscapedPropertyIntegerValidator(
                            "Port must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').")),
            null);//w  ww . ja  v a 2 s  .c om
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    binding = context.bindValue(SWTObservables.observeText(_authDomainText, SWT.Modify), ntlmAuthDomain,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    final IObservableValue computed = new AuthComputedValue(authType, basicAuthUser, basicAuthPwd,
            basicAuthRealm, basicAuthHost, basicAuthPort, ntlmAuthDomain);
    final IObservableValue ntlmValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            ResteasyPackage.Literals.REST_BINDING_TYPE__NTLM);
    final IObservableValue basicValue = ObservablesUtil.observeDetailValue(domain, _bindingValue,
            ResteasyPackage.Literals.REST_BINDING_TYPE__BASIC);
    final org.eclipse.core.databinding.Binding ntlmBinding = context.bindValue(computed, ntlmValue,
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST),
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST));
    final org.eclipse.core.databinding.Binding basicBinding = context.bindValue(computed, basicValue,
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST),
            new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST));

    final IValueChangeListener changeListener = new IValueChangeListener() {
        private boolean _updating = false;

        public void handleValueChange(ValueChangeEvent event) {
            if (!_updating) {
                _updating = true;
                if (event.getSource() == ntlmValue || event.getSource() == basicValue) {
                    if (ntlmValue.getValue() == null) {
                        // default to basic
                        basicBinding.updateModelToTarget();
                    } else {
                        ntlmBinding.updateModelToTarget();
                    }
                } else {
                    // computed
                    // we might want to do this using a command if domain != null, so the changes are atomic
                    if (computed.getValue() instanceof NTLMAuthenticationType) {
                        ntlmBinding.updateTargetToModel();
                        basicValue.setValue(null);
                    } else {
                        basicBinding.updateTargetToModel();
                        ntlmValue.setValue(null);
                    }
                }
                _updating = false;
            }
        }
    };

    IDisposeListener disposeListener = new IDisposeListener() {
        public void handleDispose(DisposeEvent event) {
            ((IObservableValue) event.getSource()).removeValueChangeListener(changeListener);
        }
    };

    computed.addValueChangeListener(changeListener);
    ntlmValue.addValueChangeListener(changeListener);
    basicValue.addValueChangeListener(changeListener);

    computed.addDisposeListener(disposeListener);
    ntlmValue.addDisposeListener(disposeListener);
    basicValue.addDisposeListener(disposeListener);
}