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

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

Introduction

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

Prototype

@Deprecated
public static Realm getRealm(final Display display) 

Source Link

Document

Returns the realm representing the UI thread for the given display.

Usage

From source file:org.switchyard.tools.ui.editor.components.camel.sap.CamelSAPProducerComposite.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, CamelSapBindingType.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);/*from   w  w w  .j  a  va  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(
                            Messages.CamelSAPComposite_Binding_name_empty_warning, Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    bindIdocControls(context, domain, realm);
    bindIdocListControls(context, domain, realm);
    bindqIdocControls(context, domain, realm);
    bindQIdocListControls(context, domain, realm);
    bindQRFCControls(context, domain, realm);
    bindSRFCControls(context, domain, realm);
    bindTRFCControls(context, domain, realm);
}

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);/*ww  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("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.CamelSFTPConsumerMoveAndPollComposite.java

License:Open Source License

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

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

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

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_preMoveText, 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__MOVE);

    binding = context.bindValue(SWTObservables.observeText(_moveText, 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__MOVE_FAILED);

    binding = context.bindValue(SWTObservables.observeText(_moveFailedText, 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__DELAY);

    binding = context.bindValue(SWTObservables.observeText(_delayText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new EscapedPropertyIntegerValidator(
                            "Delay must be a valid numeric value or follow the pattern for escaped properties (i.e. '${propName}').")),
            null);//w w  w. j av  a2 s  .c  o m
    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__MAX_MESSAGES_PER_POLL);

    binding = context.bindValue(SWTObservables.observeText(_maxMessagesPerPollText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue, path),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new EscapedPropertyIntegerValidator(
                            "Max Messages per Poll 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);
}

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);// w  w  w . jav 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("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.camel.sftp.CamelSFTPSecurityComposite.java

License:Open Source License

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

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

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

    binding = context.bindValue(//from   ww  w .  j  ava  2 s .  c om
            SWTObservables.observeText(_privateKeyFilePassphraseText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    FtpPackage.Literals.CAMEL_SFTP_BINDING_TYPE__PRIVATE_KEY_FILE_PASSPHRASE),
            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.sql.CamelSQLComposite.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("SQL binding name should not be empty", Status.WARNING)),
            null);//from w w w  . j  ava  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("SQL 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(_queryText, new int[] { SWT.Modify }),
            ObservablesUtil.observeDetailValue(domain, _bindingValue,
                    SqlPackage.Literals.CAMEL_SQL_BINDING_TYPE__QUERY),
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                    .setAfterConvertValidator(new StringEmptyValidator(Messages.error_emptyQuery)),
            null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

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

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

    if (_periodText != null && !_periodText.isDisposed()) {
        binding = context.bindValue(SWTObservables.observeText(_periodText, new int[] { SWT.Modify }),
                ObservablesUtil.observeDetailValue(domain, _bindingValue,
                        SqlPackage.Literals.CAMEL_SQL_BINDING_TYPE__PERIOD),
                new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT)
                        .setAfterConvertValidator(new StringEmptyValidator("Period may not be empty.")),
                null);
        ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);
    }

    if (_initialDelayText != null && !_initialDelayText.isDisposed()) {
        binding = context.bindValue(SWTObservables.observeText(_initialDelayText, new int[] { SWT.Modify }),
                ObservablesUtil.observeDetailValue(domain, _bindingValue,
                        SqlPackage.Literals.CAMEL_SQL_BINDING_TYPE__INITIAL_DELAY),
                new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT)
                        .setAfterConvertValidator(new EscapedPropertyLongValidator(
                                "Initial Delay 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);
    }

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

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);/*  w  w w  .j a va  2 s .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.http.HttpBindingComposite.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, HTTPBindingType.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("HTTP binding name should not be empty", Status.WARNING)),
            null);// w w  w. j  a v a 2s  .  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("HTTP binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

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

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

    } else if (getTargetObject() instanceof Reference) {
        binding = context.bindValue(ViewersObservables.observeSingleSelection(_methodCombo), ObservablesUtil
                .observeDetailValue(domain, _bindingValue, HttpPackage.Literals.HTTP_BINDING_TYPE__METHOD));
        ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

        binding = context.bindValue(SWTObservables.observeText(_mAddressURLText, new int[] { SWT.Modify }),
                ObservablesUtil.observeDetailValue(domain, _bindingValue,
                        HttpPackage.Literals.HTTP_BINDING_TYPE__ADDRESS),
                new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
        // TODO: Validate the URL to make sure it's ok
        ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

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

        binding = context.bindValue(SWTObservables.observeText(_requestTimeoutText, new int[] { SWT.Modify }),
                ObservablesUtil.observeDetailValue(domain, _bindingValue,
                        HttpPackage.Literals.HTTP_BINDING_TYPE__TIMEOUT),
                new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT)
                        .setAfterConvertValidator(new EscapedPropertyIntegerValidator(
                                "Request Timeout 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);
    }
}

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

License:Open Source License

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

    _bindingValue = new WritableValue(realm, null, HTTPBindingType.class);
    final IObservableValue hostValue = new WritableValue(realm, null, String.class);
    final IObservableValue passwordValue = new WritableValue(realm, null, String.class);
    final IObservableValue portValue = new WritableValue(realm, null, String.class);
    final IObservableValue userValue = new WritableValue(realm, null, String.class);

    org.eclipse.core.databinding.Binding binding = context.bindValue(
            SWTObservables.observeText(_proxyHostText, SWT.Modify), hostValue,
            new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null);
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

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

    binding = context.bindValue(SWTObservables.observeText(_proxyPortText, SWT.Modify), portValue,
            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.j  a  v  a 2s .c om
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

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

    ComputedValue computedProxy = new ComputedValue() {
        @Override
        protected Object calculate() {
            final String host = (String) hostValue.getValue();
            final String pwd = (String) passwordValue.getValue();
            final String port = (String) portValue.getValue();
            final String user = (String) userValue.getValue();
            if (host != null || pwd != null || port != null || user != null) {
                final ProxyType proxy = HttpFactory.eINSTANCE.createProxyType();
                proxy.setHost(host);
                proxy.setPassword(pwd);
                proxy.setPort(port);
                proxy.setUser(user);
                return proxy;
            }
            return null;
        }

        protected void doSetValue(Object value) {
            if (value instanceof ProxyType) {
                final ProxyType proxy = (ProxyType) value;
                hostValue.setValue(proxy.getHost());
                passwordValue.setValue(proxy.getPassword());
                portValue.setValue(proxy.getPort());
                userValue.setValue(proxy.getUser());
            } else {
                hostValue.setValue(null);
                passwordValue.setValue(null);
                portValue.setValue(null);
                userValue.setValue(null);
            }
            getValue();
        }
    };

    // now bind the proxy into the binding
    binding = context.bindValue(computedProxy, ObservablesUtil.observeDetailValue(domain, _bindingValue,
            HttpPackage.Literals.HTTP_BINDING_TYPE__PROXY));

}

From source file:org.switchyard.tools.ui.editor.components.jca.JCABindingInboundComposite.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, JCABinding.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("JCA binding name should not be empty", Status.WARNING)),
            null);/*from  w ww.ja  va  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("JCA binding name should not be empty", Status.WARNING)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
    ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT);

    _opSelectorComposite.bindControls(domain, context);
}