List of usage examples for org.eclipse.jface.databinding.swt SWTObservables getRealm
@Deprecated public static Realm getRealm(final Display display)
From source file:org.switchyard.tools.ui.editor.components.jca.JCABindingOutboundComposite.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); 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 ww w . j av a 2s .com*/ ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); final FeaturePath batchTimeoutFeaturePath = FeaturePath.fromList( JcaPackage.Literals.JCA_BINDING__OUTBOUND_CONNECTION, JcaPackage.Literals.JCA_OUTBOUND_CONNECTION__RESOURCE_ADAPTER, JcaPackage.Literals.RESOURCE_ADAPTER__NAME); binding = context.bindValue(SWTObservables.observeText(_resourceAdapterText), 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); IObservableValue processorType = ObservablesUtil.observeDetailValue(domain, _bindingValue, FeaturePath.fromList(JcaPackage.Literals.JCA_BINDING__OUTBOUND_INTERACTION, JcaPackage.Literals.JCA_OUTBOUND_INTERACTION__PROCESSOR, JcaPackage.Literals.PROCESSOR__TYPE)); processorType.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { final ProcessorType newExtension = ProcessorType .fromProcessorType((String) event.diff.getNewValue()); if (newExtension != _activeExtension) { swapExtensionComposites(newExtension, false); _processorMappingTypeCombo.setSelection(new StructuredSelection(newExtension), true); } else { _processorMappingTypeCombo.setSelection(new StructuredSelection(newExtension), true); } } }); }
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);//from w ww . j av a 2 s . 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.jca.JCAPropertyTable.java
License:Open Source License
/** * Constructor./*www. j av a 2 s . c o m*/ * * @param parent composite parent * @param style any SWT style bits * @param isReadOnly boolean flag * @param toolkit Form toolkit to use when creating controls * @param context the data binding context * @param featurePathToProperties the feature path to the Property list * @param domain the editing domain */ public JCAPropertyTable(Composite parent, int style, boolean isReadOnly, FormToolkit toolkit, DataBindingContext context, FeaturePath featurePathToProperties, EditingDomain domain) { super(parent, style); _isReadOnly = isReadOnly; _changeListeners = new ListenerList(); _bindingValue = new WritableValue(SWTObservables.getRealm(getDisplay()), null, JCABinding.class); int additionalStyles = SWT.NONE; if (isReadOnly) { additionalStyles = SWT.READ_ONLY; } final GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.numColumns = 2; setLayout(gridLayout); Composite tableComposite = new Composite(this, additionalStyles); GridData gd11 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 5); gd11.heightHint = 100; tableComposite.setLayoutData(gd11); TableColumnLayout tableLayout = new TableColumnLayout(); tableComposite.setLayout(tableLayout); _propertyTreeTable = new TableViewer(tableComposite, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.FULL_SELECTION | additionalStyles); _propertyTreeTable.getTable().setHeaderVisible(true); TableViewerColumn nameColumn = new TableViewerColumn(_propertyTreeTable, SWT.LEFT); nameColumn.getColumn().setText(Messages.label_name); tableLayout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(100, 150, true)); TableViewerColumn valueColumn = new TableViewerColumn(_propertyTreeTable, SWT.LEFT); valueColumn.getColumn().setText(Messages.label_value); tableLayout.setColumnData(valueColumn.getColumn(), new ColumnWeightData(100, 150, true)); IValueProperty nameProperty = domain == null ? EMFProperties.value(JcaPackage.Literals.PROPERTY__NAME) : EMFEditProperties.value(domain, JcaPackage.Literals.PROPERTY__NAME); IValueProperty valueProperty = domain == null ? EMFProperties.value(JcaPackage.Literals.PROPERTY__VALUE) : EMFEditProperties.value(domain, JcaPackage.Literals.PROPERTY__VALUE); IValueProperty cellEditorTextProperty = CellEditorProperties.control() .value(WidgetProperties.text(SWT.Modify)); final ObservableListContentProvider contentProvider; ObservableTracker.setIgnore(true); try { // ignore any observers created internally contentProvider = new ObservableListContentProvider(); } finally { ObservableTracker.setIgnore(false); } nameColumn.setEditingSupport(ObservableValueEditingSupport.create(_propertyTreeTable, context, new TextCellEditor(_propertyTreeTable.getTable()), cellEditorTextProperty, nameProperty)); nameColumn.setLabelProvider( new ObservableMapCellLabelProvider(nameProperty.observeDetail(contentProvider.getKnownElements()))); valueColumn.setEditingSupport(ObservableValueEditingSupport.create(_propertyTreeTable, context, new TextCellEditor(_propertyTreeTable.getTable()), cellEditorTextProperty, valueProperty)); valueColumn.setLabelProvider(new ObservableMapCellLabelProvider( valueProperty.observeDetail(contentProvider.getKnownElements()))); _propertyTreeTable.setContentProvider(contentProvider); _mAddButton = toolkit.createButton(this, Messages.button_add, SWT.NONE); _mAddButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); _mAddButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addPropertyToList(); } }); _mAddButton.setEnabled(false); _propertyTreeTable.getTable().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updatePropertyButtons(); } }); _mRemoveButton = toolkit.createButton(this, Messages.button_remove, SWT.NONE); _mRemoveButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); _mRemoveButton.setEnabled(false); _mRemoveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeFromList(); } }); final IObservableList propertiesList = (domain == null ? EMFProperties.list(featurePathToProperties) : EMFEditProperties.list(domain, featurePathToProperties)).observeDetail(_bindingValue); _propertyTreeTable.setInput(propertiesList); updatePropertyButtons(); }
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);// ww w. j a va 2s .co 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, 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); }
From source file:org.switchyard.tools.ui.editor.components.resteasy.ResteasyBindingComposite.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, RESTBindingType.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("REST binding name should not be empty", Status.WARNING)), null);//from w w w . ja va 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("REST binding name cannot be empty", Status.WARNING)), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); if (getTargetObject() instanceof Reference) { binding = context.bindValue(SWTObservables.observeText(_mAddressURLText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, ResteasyPackage.Literals.REST_BINDING_TYPE__ADDRESS), new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null); // TODO: Need to validate to make sure no spaces before/after address ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_requestTimeoutText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, ResteasyPackage.Literals.REST_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); } else { binding = context.bindValue(SWTObservables.observeText(_contextPathText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, ResteasyPackage.Literals.REST_BINDING_TYPE__CONTEXT_PATH), new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); } binding = context.bindValue( SWTObservables.observeText(_interfacesList.getHiddenText(), new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, ResteasyPackage.Literals.REST_BINDING_TYPE__INTERFACES), new EMFUpdateValueStrategyNullForEmptyString("", UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new StringEmptyValidator(Messages.error_noRestInterfaceOrClass)), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); }
From source file:org.switchyard.tools.ui.editor.components.resteasy.ResteasyProxyComposite.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, RESTBindingType.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 www . j a va2 s . 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 = ResteasyFactory.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, ResteasyPackage.Literals.REST_BINDING_TYPE__PROXY)); }
From source file:org.switchyard.tools.ui.editor.components.soap.InterceptorTable.java
License:Open Source License
/** * Constructor./*from ww w . j ava 2 s. c om*/ * * @param parent composite parent * @param style any SWT style bits * @param isReadOnly boolean flag * @param interceptorsListFeature list we're editing * @param interceptorsFeature actual interceptor list feature * @param interceptorType actual class for the interceptor type * @param context DataBindingContext to use */ public InterceptorTable(Composite parent, int style, boolean isReadOnly, EReference interceptorsListFeature, EReference interceptorsFeature, EClass interceptorType, DataBindingContext context) { super(parent, style); final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(getTargetObject()); this._isReadOnly = isReadOnly; this._changeListeners = new ListenerList(); _interceptorsListFeature = interceptorsListFeature; _interceptorsFeature = interceptorsFeature; _interceptorType = interceptorType; int additionalStyles = SWT.NONE; if (isReadOnly) { additionalStyles = SWT.READ_ONLY; } final GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.numColumns = 2; setLayout(gridLayout); Composite tableComposite = new Composite(this, additionalStyles); GridData gd11 = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 3); gd11.heightHint = 100; tableComposite.setLayoutData(gd11); _interceptorTable = new TableViewer(tableComposite, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.FULL_SELECTION | additionalStyles); this._interceptorTable.getTable().setHeaderVisible(true); TableColumnLayout tableLayout = new TableColumnLayout(); tableComposite.setLayout(tableLayout); TableViewerColumn nameColumn = new TableViewerColumn(_interceptorTable, SWT.LEFT); nameColumn.getColumn().setText(Messages.label_name); tableLayout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(100, 150, true)); IValueProperty nameProperty = domain == null ? EMFProperties.value(_interceptorType.getEStructuralFeature("class")) : EMFEditProperties.value(domain, _interceptorType.getEStructuralFeature("class")); IValueProperty cellEditorTextProperty = CellEditorProperties.control() .value(WidgetProperties.text(SWT.Modify)); final ObservableListContentProvider contentProvider; ObservableTracker.setIgnore(true); try { // ignore any observers created internally contentProvider = new ObservableListContentProvider(); } finally { ObservableTracker.setIgnore(false); } nameColumn.setEditingSupport(ObservableValueEditingSupport.create(_interceptorTable, context, new TextCellEditor(_interceptorTable.getTable()), cellEditorTextProperty, nameProperty)); nameColumn.setLabelProvider( new ObservableMapCellLabelProvider(nameProperty.observeDetail(contentProvider.getKnownElements()))); _interceptorTable.setContentProvider(contentProvider); this._mAddButton = new Button(this, SWT.NONE); this._mAddButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); this._mAddButton.setText(Messages.button_add); this._mAddButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addInterceptorTypeToList(); fireChangedEvent(e.getSource()); } }); this._mAddButton.setEnabled(false); _interceptorTable.getTable().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateInterceptorTypeButtons(); } }); this._mEditButton = new Button(this, SWT.NONE); this._mEditButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); this._mEditButton.setText(Messages.button_edit); this._mEditButton.setEnabled(false); this._mEditButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { editInterceptorType(); fireChangedEvent(e.getSource()); } }); this._mRemoveButton = new Button(this, SWT.NONE); this._mRemoveButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); this._mRemoveButton.setText(Messages.button_remove); this._mRemoveButton.setEnabled(false); this._mRemoveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeFromList(); fireChangedEvent(e.getSource()); } }); // set the input. we're observing a list on the binding value _bindingValue = new WritableValue(SWTObservables.getRealm(getDisplay()), null, SOAPBindingType.class); _interceptorTable .setInput(EMFProperties.list(FeaturePath.fromList(_interceptorsListFeature, _interceptorsFeature)) .observeDetail(_bindingValue)); updateInterceptorTypeButtons(); }
From source file:org.switchyard.tools.ui.editor.components.soap.SOAPAuthenticationComposite.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, SOAPBindingType.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 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(_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, ntlmAuthDomain);//from w ww. j av a 2 s .c o m final IObservableValue ntlmValue = ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__NTLM); final IObservableValue basicValue = ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_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.soap.SOAPBindingReferenceComposite.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, CamelFileBindingType.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("SOAP binding name should not be empty", Status.WARNING)), null);// w ww . j a 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("SOAP 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(_mWSDLURIText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__WSDL), new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new StringEmptyValidator(Messages.error_noUri)), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_portNameText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__WSDL_PORT), 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, SOAPPackage.Literals.SOAP_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); binding = context.bindValue(SWTObservables.observeText(_endpointAddressText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__ENDPOINT_ADDRESS), new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); final IObservableValue msgComposerUnwrappedValue = new WritableValue(realm, null, Boolean.class); binding = context.bindValue(SWTObservables.observeSelection(_unwrappedPayloadCheckbox), msgComposerUnwrappedValue, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); ComputedValue computedMessageComposer = new ComputedValue() { @Override protected Object calculate() { final Boolean unwrapped = (Boolean) msgComposerUnwrappedValue.getValue(); if (unwrapped != null) { final MessageComposerType msgComposer = SOAPFactory.eINSTANCE.createMessageComposerType(); msgComposer.setUnwrapped(unwrapped.booleanValue()); return msgComposer; } return null; } protected void doSetValue(Object value) { if (value instanceof MessageComposerType) { final MessageComposerType msgComposer = (MessageComposerType) value; msgComposerUnwrappedValue.setValue(new Boolean(msgComposer.isUnwrapped())); } else { msgComposerUnwrappedValue.setValue(null); } getValue(); } }; // now bind the message composer into the binding binding = context.bindValue(computedMessageComposer, ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__MESSAGE_COMPOSER)); final IObservableValue contextMapperSOAPHeaders = new WritableValue(realm, null, SoapHeadersType.class); binding = context.bindValue(ViewersObservables.observeSingleSelection(_soapHeadersTypeCombo), contextMapperSOAPHeaders, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); ComputedValue computedContextMapper = new ComputedValue() { @Override protected Object calculate() { final SoapHeadersType soapHeaders = (SoapHeadersType) contextMapperSOAPHeaders.getValue(); if (soapHeaders != null) { final ContextMapperType ctxMapper = SOAPFactory.eINSTANCE.createContextMapperType(); ctxMapper.setSoapHeadersType(soapHeaders); return ctxMapper; } return null; } protected void doSetValue(Object value) { if (value instanceof ContextMapperType) { final ContextMapperType ctxMapper = (ContextMapperType) value; contextMapperSOAPHeaders.setValue(ctxMapper.getSoapHeadersType()); } else { contextMapperSOAPHeaders.setValue(null); } getValue(); } }; // now bind the context mapper into the binding binding = context.bindValue(computedContextMapper, ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__CONTEXT_MAPPER)); bindMtomControls(context, domain, realm); }
From source file:org.switchyard.tools.ui.editor.components.soap.SOAPBindingServiceComposite.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, SOAPBindingType.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("SOAP binding name should not be empty", Status.WARNING)), null);// ww w . j av a 2s . 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("SOAP 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(_mWSDLURIText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__WSDL), new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new StringEmptyValidator(Messages.error_noUri)), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_portNameText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__WSDL_PORT), new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); bindMessageComposerAndContextMapperControls(context, domain, realm); final IObservableValue endpointConfigConfigFile = new WritableValue(realm, null, String.class); final IObservableValue endpointConfigConfigName = new WritableValue(realm, null, String.class); binding = context.bindValue(SWTObservables.observeText(_configFileText, SWT.Modify), endpointConfigConfigFile, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_configNameText, SWT.Modify), endpointConfigConfigName, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); ComputedValue computedEndpointConfig = new ComputedValue() { @Override protected Object calculate() { final String configFile = (String) endpointConfigConfigFile.getValue(); final String configName = (String) endpointConfigConfigName.getValue(); if (configFile != null || configName != null) { final EndpointConfigType endpointConfig = SOAPFactory.eINSTANCE.createEndpointConfigType(); endpointConfig.setConfigFile(configFile); endpointConfig.setConfigName(configName); return endpointConfig; } return null; } protected void doSetValue(Object value) { if (value instanceof EndpointConfigType) { final EndpointConfigType endpointConfig = (EndpointConfigType) value; endpointConfigConfigFile.setValue(endpointConfig.getConfigFile()); endpointConfigConfigName.setValue(endpointConfig.getConfigName()); } else { endpointConfigConfigFile.setValue(null); endpointConfigConfigName.setValue(null); } getValue(); } }; // now bind the endpoint config into the binding binding = context.bindValue(computedEndpointConfig, ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__ENDPOINT_CONFIG)); bindMtomControls(context, domain, realm); if (getTargetObject() != null && getTargetObject() instanceof Service) { final IObservableValue wsdlSocketValue = SWTObservables.observeText(_mWSDLSocketText, new int[] { SWT.Modify }); final UpdateValueStrategy wsdlSocketUpdateValueStrategy = new EMFUpdateValueStrategyNullForEmptyString( null, UpdateValueStrategy.POLICY_CONVERT); wsdlSocketUpdateValueStrategy.setConverter(new WSDLPortConverter()); wsdlSocketUpdateValueStrategy.setAfterConvertValidator(new ServerPortValidator( "Server Port value must be in the form '1234', ':1234', or 'host:1234' or follow the pattern for escaped properties (i.e. ':${propName}' or '${propName1}:${propName2}').")); binding = context.bindValue(SWTObservables.observeText(_contextPathText, new int[] { SWT.Modify }), ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__CONTEXT_PATH), new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(wsdlSocketValue, ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__SOCKET_ADDR), wsdlSocketUpdateValueStrategy, null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); } }