List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection
@Deprecated public static ISWTObservableValue observeSelection(Control control)
control
. 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);/* w w w .jav 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);/*from w w 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("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.SOAPBindingReferenceComposite.java
License:Open Source License
private void bindMtomControls(final DataBindingContext context, final EditingDomain domain, final Realm realm) { final IObservableValue mtomEnabled = new WritableValue(realm, null, Boolean.class); final IObservableValue mtomDisabled = new WritableValue(realm, null, Boolean.class); final IObservableValue mtomXopExpand = new WritableValue(realm, null, Boolean.class); final IObservableValue mtomThreshold = new WritableValue(realm, null, BigInteger.class); org.eclipse.core.databinding.Binding binding = context.bindValue( SWTObservables.observeSelection(_enableMtomCheckbox), mtomEnabled, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeSelection(_disableMtomCheckbox), mtomDisabled, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeSelection(_enableXopExpandCheckbox), mtomXopExpand, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_mtomThresholdText, SWT.Modify), mtomThreshold, new EMFUpdateValueStrategyNullForEmptyString(null, UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); ComputedValue computedMtom = new ComputedValue() { @Override//from w ww.j a v a 2 s .c om protected Object calculate() { final Boolean enabled = (Boolean) mtomEnabled.getValue(); final Boolean disabled = (Boolean) mtomDisabled.getValue(); final Boolean xopExpand = (Boolean) mtomXopExpand.getValue(); final BigInteger threshold = (BigInteger) mtomThreshold.getValue(); if (enabled != null && enabled.booleanValue()) { final MtomType mtom = SOAPFactory.eINSTANCE.createMtomType(); mtom.setEnabled(disabled); mtom.setXopExpand(xopExpand); mtom.setThreshold(threshold); return mtom; } return null; } protected void doSetValue(Object value) { if (value instanceof MtomType) { final MtomType mtom = (MtomType) value; mtomEnabled.setValue(new Boolean(true)); mtomDisabled.setValue(mtom.getEnabled()); mtomXopExpand.setValue(mtom.getXopExpand()); mtomThreshold.setValue(mtom.getThreshold()); } else { mtomEnabled.setValue(new Boolean(false)); mtomDisabled.setValue(null); mtomXopExpand.setValue(null); mtomThreshold.setValue(null); } getValue(); } }; mtomEnabled.addChangeListener(new IChangeListener() { @Override public void handleChange(ChangeEvent event) { Boolean value = (Boolean) mtomEnabled.getValue(); _disableMtomCheckbox.setEnabled(value.booleanValue()); _enableXopExpandCheckbox.setEnabled(value.booleanValue()); _mtomThresholdText.setEnabled(value.booleanValue()); } }); // now bind the mtom into the binding binding = context.bindValue(computedMtom, ObservablesUtil.observeDetailValue(domain, _bindingValue, SOAPPackage.Literals.SOAP_BINDING_TYPE__MTOM)); }
From source file:org.switchyard.tools.ui.editor.components.soap.SOAPBindingServiceComposite.java
License:Open Source License
private void bindMessageComposerAndContextMapperControls(final DataBindingContext context, final EditingDomain domain, final Realm realm) { final IObservableValue msgComposerUnwrappedValue = new WritableValue(realm, null, Boolean.class); org.eclipse.core.databinding.Binding 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/*w w w . j ava 2 s . com*/ 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)); }
From source file:org.switchyard.tools.ui.editor.diagram.binding.OperationSelectorComposite.java
License:Open Source License
/** * Bind the controls./* w w w . j a v a 2 s. c o m*/ * * @param domain the editing domain, may be null * @param context the data binding context */ public void bindControls(EditingDomain domain, DataBindingContext context) { final Realm realm = SWTObservables.getRealm(getDisplay()); _bindingValue = new WritableValue(realm, null, Binding.class); /* * intermediate values, used to separate control changes from value * changes (i.e. the bindings for these are wrapped with * SWTValueUpdater). */ final IObservableValue selectorTypeValue = new WritableValue(realm, null, SelectorType.class); final IObservableValue staticValue = new WritableValue(realm, null, String.class); final IObservableValue regexValue = new WritableValue(realm, null, String.class); final IObservableValue xpathValue = new WritableValue(realm, null, String.class); final IObservableValue javaValue = new WritableValue(realm, null, String.class); // bind intermediate values to controls org.eclipse.core.databinding.Binding binding = context.bindValue( ViewersObservables.observeSingleSelection(_typeCombo), selectorTypeValue, new UpdateValueStrategy(), null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeSelection(_operationSelectionCombo), staticValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_regexText, SWT.Modify), regexValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new RegexValidator()), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_xpathText, SWT.Modify), xpathValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); binding = context.bindValue(SWTObservables.observeText(_javaText, SWT.Modify), javaValue, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); ControlDecorationSupport.create(SWTValueUpdater.attach(binding), SWT.TOP | SWT.LEFT); /* * computed value. creates an operation selector based on the current * state of the controls. */ _selectorValue = new ComputedValue(realm, OperationSelectorType.class) { @Override protected Object calculate() { // we need to interrogate all values, or we'll miss events final SelectorType selectedType = (SelectorType) selectorTypeValue.getValue(); final String operationText = (String) staticValue.getValue(); final String xpathText = (String) xpathValue.getValue(); final String regexText = (String) regexValue.getValue(); final String javaText = (String) javaValue.getValue(); if (selectedType == null) { return null; } switch (selectedType) { case STATIC_TYPE: return selectedType.createOperationSelector(operationText); case XPATH_TYPE: return selectedType.createOperationSelector(xpathText); case REGEX_TYPE: return selectedType.createOperationSelector(regexText); case JAVA_TYPE: return selectedType.createOperationSelector(javaText); } return null; } @Override protected void doSetValue(Object value) { if (value == null) { selectorTypeValue.setValue(SelectorType.STATIC_TYPE); staticValue.setValue(""); } else if (value instanceof OperationSelectorType) { final SelectorType selectorType = SelectorType.valueOf((OperationSelectorType) value); selectorTypeValue.setValue(selectorType); switch (selectorType) { case STATIC_TYPE: staticValue.setValue(((StaticOperationSelectorType) value).getOperationName()); break; case XPATH_TYPE: xpathValue.setValue(((XPathOperationSelectorType) value).getExpression()); break; case REGEX_TYPE: regexValue.setValue(((RegexOperationSelectorType) value).getExpression()); break; case JAVA_TYPE: javaValue.setValue(((JavaOperationSelectorType) value).getClass_()); break; } } else { throw new IllegalArgumentException( "Unknown selector type: " + value.getClass().getCanonicalName()); } // update our cached value getValue(); } }; // now bind the selector into the binding context.bindValue(_selectorValue, ObservablesUtil.observeDetailValue(domain, _bindingValue, ScaPackage.eINSTANCE.getBinding_OperationSelector())); // propagate changes to the old binding composites _selectorValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { fireChangedEvent(OperationSelectorComposite.this); } }); }
From source file:org.switchyard.tools.ui.editor.diagram.shared.AbstractSwitchyardComposite.java
License:Open Source License
protected void addObservableListeners(boolean reset) { if (_observersAdded && !reset) { return;//from w w w . j av a 2 s . co m } if (reset && _observables != null && _observables.size() > 0) { for (int i = 0; i < _observables.size(); i++) { _observables.get(i).dispose(); } _observables.clear(); } _observables = new ArrayList<IObservable>(); if (_textValueChangeListener == null) { _textValueChangeListener = new TextValueChangeListener(); } if (_comboValueChangeListener == null) { _comboValueChangeListener = new ComboValueChangeListener(); } if (_buttonValueChangeListener == null) { _buttonValueChangeListener = new ButtonValueChangeListener(); } int styleBit = 0; Composite parent = this.getPanel().getParent(); System.out.println(parent); while (parent != null && !(parent instanceof Shell)) { parent = parent.getParent(); } if (parent != null && parent instanceof Shell) { Shell shell = (Shell) parent; if (shell.getData() instanceof WizardDialog || shell.getData() instanceof PropertyDialog) { styleBit = SWT.Modify; } } Iterator<Control> iter = _observableControls.iterator(); while (iter.hasNext()) { Control ctrl = iter.next(); if (ctrl.isDisposed()) { continue; } if (ctrl instanceof Text) { Text newText = (Text) ctrl; ISWTObservableValue focusObserver = SWTObservables.observeText(newText, SWT.FocusOut | styleBit); _observables.add(focusObserver); // focusObserver.removeValueChangeListener(_textValueChangeListener); focusObserver.addValueChangeListener(_textValueChangeListener); } else if (ctrl instanceof Combo) { final Combo newCombo = (Combo) ctrl; if ((newCombo.getStyle() & SWT.READ_ONLY) == 0) { newCombo.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { if ((e.keyCode >= 97 && e.keyCode <= 122) || // characters (e.keyCode >= 48 && e.keyCode <= 57) || // digits (e.keyCode == 32) || // spacebar (e.keyCode == SWT.BS) || // backspace (e.keyCode == SWT.ARROW_UP) || // up arrow (e.keyCode == SWT.ARROW_DOWN)) { AbstractSwitchyardComposite.this._comboTextChanged = (Control) e.widget; } } }); newCombo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { AbstractSwitchyardComposite.this._comboTextChanged = (Control) arg0.widget; } }); if (styleBit != 0) { newCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (AbstractSwitchyardComposite.this._comboTextChanged == (Control) e.getSource()) { System.out.println( "AbstractSwitchyardComposite:New Combo Selection (text entry): " //$NON-NLS-1$ + ((Combo) e.getSource()).getText()); handleChange((Control) e.getSource()); AbstractSwitchyardComposite.this._comboTextChanged = null; } } }); } newCombo.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { } @Override public void focusLost(FocusEvent e) { if (AbstractSwitchyardComposite.this._comboTextChanged == (Control) e.getSource()) { System.out.println("AbstractSwitchyardComposite:New Combo Value (text entry): " //$NON-NLS-1$ + ((Combo) e.getSource()).getText()); handleChange((Control) e.getSource()); AbstractSwitchyardComposite.this._comboTextChanged = null; } } }); } ISWTObservableValue selectionObserver = SWTObservables.observeSelection(newCombo); _observables.add(selectionObserver); // selectionObserver.removeValueChangeListener(_comboValueChangeListener); selectionObserver.addValueChangeListener(_comboValueChangeListener); } else if (ctrl instanceof Button) { Button newButton = (Button) ctrl; ISWTObservableValue buttonObserver = SWTObservables.observeSelection(newButton); _observables.add(buttonObserver); // buttonObserver.removeValueChangeListener(_buttonValueChangeListener); buttonObserver.addValueChangeListener(_buttonValueChangeListener); } } _observersAdded = true; }
From source file:org.symbian.tools.wrttools.wizards.NewWrtAppTemplatePage.java
License:Open Source License
public final void createControl(Composite parent) { Composite root = new Composite(parent, SWT.NONE); WizardPageSupport.create(this, bindingContext); root.setLayout(new GridLayout(2, false)); createLabel(root, "Name of main HTML:"); createText(root, IProjectTemplate.CommonKeys.main_html, "HTML file name", bindingContext); createLabel(root, ""); createLabel(root, ""); createLabel(root, "Name of CSS file:"); createText(root, IProjectTemplate.CommonKeys.main_css, "CSS file name", bindingContext); createLabel(root, ""); createLabel(root, ""); createLabel(root, "Name of JavaScript file:"); createText(root, IProjectTemplate.CommonKeys.main_js, "JavaScript file name", bindingContext); createLabel(root, ""); Button homeScreen = new Button(root, SWT.CHECK); homeScreen.setText("Enable HomeScreen"); createLabel(root, ""); createLabel(root, ""); IObservableValue view = SWTObservables.observeSelection(homeScreen); IObservableValue model = context.getParameterObservable("homeScreen"); bindingContext.bindValue(view, model); addTemplateControls(root);//from w w w . ja v a2s.c o m setControl(root); }
From source file:org.talend.updates.runtime.ui.ChooseUpdateSitesWizardPage.java
License:Open Source License
protected void initDataBindings() { SelectObservableValue featureRepoLocationTypeObservable = new SelectObservableValue( UpdateSiteLocationType.class); {/* w ww . j a v a2 s . c o m*/ DataBindingContext defaultRemoteBC = new DataBindingContext(); // define default Repo bindings IObservableValue btnDefaultRemoteSitesObserveSelection = SWTObservables .observeSelection(btnDefaultRemoteSites); featureRepoLocationTypeObservable.addOption(UpdateSiteLocationType.DEFAULT_REPO, btnDefaultRemoteSitesObserveSelection); // fake binding to trigger an update of the defaultRemoteBC validation to reset the validation message defaultRemoteBC.bindValue(btnDefaultRemoteSitesObserveSelection, new WritableValue()); // bind the validation messages to the wizard page WizardPageSupport.create(this, defaultRemoteBC); } // define remote custom Repo url bindings // define validator for text fields { DataBindingContext remoteRepoBC = new DataBindingContext(); UpdateValueStrategy afterConvertRemoteRepoValidator = new UpdateValueStrategy() .setAfterConvertValidator(updateWizardModel.new RemoteRepoURIValidator()); // bind selection to model value IObservableValue btnCustomUpdateSiteObserveSelection = SWTObservables .observeSelection(btnCustomUpdateSite); featureRepoLocationTypeObservable.addOption(UpdateSiteLocationType.REMOTE_REPO, btnCustomUpdateSiteObserveSelection); // bind selection to enable text field IObservableValue textObserveEnabled = SWTObservables.observeEnabled(CustomSiteText); remoteRepoBC.bindValue(textObserveEnabled, btnCustomUpdateSiteObserveSelection, null, null); // bind text modification to model with validation IObservableValue customSiteTextObserveText = SWTObservables.observeText(CustomSiteText, SWT.Modify); remoteRepoBC.bindValue(customSiteTextObserveText, PojoObservables.observeValue(updateWizardModel, "featureRepositories.remoteRepoUriStr"), //$NON-NLS-1$ afterConvertRemoteRepoValidator, null); // bind the validation messages to the wizard page WizardPageSupport.create(this, remoteRepoBC); } { // define local folder Repo bindings DataBindingContext localRepoBC = new DataBindingContext(); UpdateValueStrategy afterConvertLocalFolderValidator = new UpdateValueStrategy() .setAfterConvertValidator(updateWizardModel.new LocalRepoFolderValidator()); // bind selection to model IObservableValue btnLocalFolderObserveSelection = SWTObservables.observeSelection(btnLocalFolder); featureRepoLocationTypeObservable.addOption(UpdateSiteLocationType.LOCAL_FOLDER, btnLocalFolderObserveSelection); // bind selection to text fiedl enabled IObservableValue localFolderTextObserveEnabled = SWTObservables.observeEnabled(localFolderText); localRepoBC.bindValue(localFolderTextObserveEnabled, btnLocalFolderObserveSelection, null, null); // bind selection to browse button enabled IObservableValue localFolderBrowseButtonObserveEnabled = SWTObservables .observeEnabled(localFolderBrowseButton); localRepoBC.bindValue(localFolderBrowseButtonObserveEnabled, btnLocalFolderObserveSelection, null, null); // bind text field to model IObservableValue localFolderTextObserveText = SWTObservables.observeText(localFolderText, SWT.Modify); localRepoBC.bindValue(localFolderTextObserveText, PojoObservables.observeValue(updateWizardModel, "featureRepositories.localRepoPathStr"), //$NON-NLS-1$ afterConvertLocalFolderValidator, null); // // bind the validation messages to the wizard page WizardPageSupport.create(this, localRepoBC); } DataBindingContext radioBC = new DataBindingContext(); radioBC.bindValue(featureRepoLocationTypeObservable, PojoObservables.observeValue(updateWizardModel, "featureRepositories.updateSiteLocationType")); //$NON-NLS-1$ }
From source file:pl.zgora.uz.imgpro.ui.properties.composite.AbstractImproPropertiesComposite.java
License:Open Source License
protected void bindBoolean(final EStructuralFeature a, final Button button, final EObject object) { button.setSelection((Boolean) object.eGet(a)); IObservableValue buttonObserver = SWTObservables.observeSelection(button); buttonObserver.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { if (!object.eGet(a).equals(button.getSelection())) { TransactionalEditingDomain editingDomain = editor.getEditingDomain(); editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { protected void doExecute() { object.eSet(a, button.getSelection()); }//from ww w .java2 s.c o m }); } } }); button.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { } public void focusLost(FocusEvent e) { // editor.showErrorMessage(null); } }); }
From source file:ramo.klevis.openrental.forms.FormAvaibleCar.java
protected DataBindingContext initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); ///*from w w w . ja va 2 s . c o m*/ fillClassAndLocation(); // IObservableValue comboViewerObserveSingleSelection = ViewersObservables.observeSingleSelection(comboViewer); IObservableValue beanAvaibleCarClazzObserveValue = PojoObservables.observeValue(beanAvaibleCar, "clazz"); bindingContext.bindValue(comboViewerObserveSingleSelection, beanAvaibleCarClazzObserveValue, null, null); // IObservableValue comboViewer_1ObserveSingleSelection = ViewersObservables .observeSingleSelection(comboViewer_1); IObservableValue beanAvaibleCarLocationObserveValue = PojoObservables.observeValue(beanAvaibleCar, "location"); bindingContext.bindValue(comboViewer_1ObserveSingleSelection, beanAvaibleCarLocationObserveValue, null, null); // IObservableValue fromDateTextObserveSelectionObserveWidget = SWTObservables.observeSelection(fromDateText); IObservableValue beanAvaibleCarFromDateObserveValue = PojoObservables.observeValue(beanAvaibleCar, "fromDate"); bindingContext.bindValue(fromDateTextObserveSelectionObserveWidget, beanAvaibleCarFromDateObserveValue, null, null); // IObservableValue toDateTextObserveSelectionObserveWidget = SWTObservables.observeSelection(toDateText); IObservableValue beanAvaibleCarToDateObserveValue = PojoObservables.observeValue(beanAvaibleCar, "toDate"); bindingContext.bindValue(toDateTextObserveSelectionObserveWidget, beanAvaibleCarToDateObserveValue, null, null); // ObservableListContentProvider listContentProvider_2 = new ObservableListContentProvider(); tableViewer.setContentProvider(listContentProvider_2); // IObservableMap[] observeMaps = PojoObservables.observeMaps(listContentProvider_2.getKnownElements(), Car.class, new String[] { "id", "license", "make", "model", "rate", "year", "classes.class_" }); tableViewer.setLabelProvider(new ObservableMapLabelProvider(observeMaps)); // WritableList writableList_2 = new WritableList(getListCarsAvaible(), Car.class); tableViewer.setInput(writableList_2); // return bindingContext; }