List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeText
@Deprecated public static ISWTObservableValue observeText(Control control, int event)
control
. From source file:com.platzerworld.e4.biergarten.views.details.DetailsView.java
License:Open Source License
private Text createText(final Composite parent, final String labelText, final String property) { final Label label = new Label(parent, SWT.NONE); label.setText(labelText);//from w w w .j a va 2 s. co m GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); label.setLayoutData(gridData); final Text text = new Text(parent, SWT.NONE); GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL); gridData2.horizontalIndent = 0; gridData2.horizontalSpan = 1; text.setLayoutData(gridData2); if (property != null) { dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), PojoObservables.observeDetailValue(contactValue, property, String.class)); } return text; }
From source file:com.rcpcompany.uibindings.tests.views.TestView.java
License:Open Source License
protected void bindUI() { final DataBindingContext c = new DataBindingContext(); final UpdateValueStrategy modelToTarget = new EMFUpdateValueStrategy(); final UpdateValueStrategy targetToModel = new EMFUpdateValueStrategy(); c.bindValue(SWTObservables.observeText(myText, SWT.Modify), EMFObservables.observeValue(myObject, TestModelPackage.Literals.TEST_OBJECT__TEXT), targetToModel, modelToTarget);/*from www . j a v a 2 s. co m*/ }
From source file:com.runwaysdk.manager.view.EntityView.java
License:Open Source License
private final void bind(Object control, String attribute) { IComponentObject modelObject = this.getEntity(); if (control instanceof Text) { // The DataBindingContext object will manage the databindings IObservableValue uiElement = SWTObservables.observeText((Text) control, SWT.Modify); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); bindingContext.bindValue(uiElement, modelElement, null, null); } else if (control instanceof IDateTime) { // The DataBindingContext object will manage the databindings IObservableValue uiElement = new IDateObservableValue(realm, (IDateTime) control); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); // The bindValue method call binds the text element with the model bindingContext.bindValue(uiElement, modelElement, null, null); } else if (control instanceof ValidateTextWidget) { ValidateTextWidget widget = (ValidateTextWidget) control; // The DataBindingContext object will manage the databindings IObservableValue uiElement = SWTObservables.observeText(widget.getText(), SWT.Modify); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(widget.getValidator()); bindingContext.bindValue(uiElement, modelElement, strategy, null); } else if (control instanceof ReferenceWidget) { // The DataBindingContext object will manage the databindings IObservableValue uiElement = new ReferenceObservableValue(realm, (ReferenceWidget) control); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); // The bindValue method call binds the text element with the model MessageUpdateStrategy strategy = new MessageUpdateStrategy((IMessageWidget) control); bindingContext.bindValue(uiElement, modelElement, strategy, null); } else if (control instanceof StructView) { // The DataBindingContext object will manage the databindings IObservableValue uiElement = new StructObservableValue(realm, (StructView) control); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); // The bindValue method call binds the text element with the model bindingContext.bindValue(uiElement, modelElement, null, null); } else if (control instanceof ComboViewer) { IObservableValue uiElement = ViewersObservables.observeSingleSelection((ComboViewer) control); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); bindingContext.bindValue(uiElement, modelElement, null, null); } else if (control instanceof RadioGroup) { // The DataBindingContext object will manage the databindings IObservableValue uiElement = new RadioGroupObservableValue(realm, (RadioGroup) control); IObservableValue modelElement = RunwayObservables.observeValue(realm, modelObject, attribute); // The bindValue method call binds the text element with the model bindingContext.bindValue(uiElement, modelElement, null, null); }//from www . j av a 2s. c o m }
From source file:com.runwaysdk.manager.view.ExportDialog.java
License:Open Source License
private void bind() { Realm realm = SWTObservables.getRealm(getShell().getDisplay()); DataBindingContext bindingContext = new DataBindingContext(realm); // Bind the type value bindingContext.bindValue(new RadioGroupObservableValue(realm, group), BeansObservables.observeValue(bean, "type"), null, null); // Bind the lower value bindingContext.bindValue(SWTObservables.observeText(startText, SWT.Modify), BeansObservables.observeValue(bean, "lower"), null, null); // Bind the location value bindingContext.bindValue(SWTObservables.observeText(fileText, SWT.Modify), BeansObservables.observeValue(bean, "location"), null, null); }
From source file:com.runwaysdk.manager.view.ImportDialog.java
License:Open Source License
private void bind() { Realm realm = SWTObservables.getRealm(getShell().getDisplay()); DataBindingContext bindingContext = new DataBindingContext(realm); // Bind the location value bindingContext.bindValue(SWTObservables.observeText(fileText, SWT.Modify), BeansObservables.observeValue(bean, "location"), null, null); }
From source file:com.schmeedy.pdt.joomla.manifest.ui.editor.OverviewPage.java
protected DataBindingContext initDataBindings() { final DataBindingContext bindingContext = new DataBindingContext(); ////from www.j a va2s.co m final IObservableValue nameTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(nameText, SWT.Modify)); final IObservableValue currentInputNameObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__NAME); bindingContext.bindValue(nameTextObserveTextObserveWidget, currentInputNameObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue versionTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(versionText, SWT.Modify)); final IObservableValue currentInputVersionObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__VERSION); bindingContext.bindValue(versionTextObserveTextObserveWidget, currentInputVersionObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue descriptionTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(descriptionText, SWT.Modify)); final IObservableValue currentInputDescriptionObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__DESCRIPTION); bindingContext.bindValue(descriptionTextObserveTextObserveWidget, currentInputDescriptionObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue authorNameTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(authorNameText, SWT.Modify)); final IObservableValue currentInputAuthorObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__AUTHOR); bindingContext.bindValue(authorNameTextObserveTextObserveWidget, currentInputAuthorObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue authorEmailTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(authorEmailText, SWT.Modify)); final IObservableValue currentInputAuthorEmailObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__AUTHOR_EMAIL); bindingContext.bindValue(authorEmailTextObserveTextObserveWidget, currentInputAuthorEmailObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue authorUrlTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(authorUrlText, SWT.Modify)); final IObservableValue currentInputAuthorUrlObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__AUTHOR_URL); bindingContext.bindValue(authorUrlTextObserveTextObserveWidget, currentInputAuthorUrlObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue copyrightTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(copyrightText, SWT.Modify)); final IObservableValue currentInputCopyrightObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__COPYRIGHT); bindingContext.bindValue(copyrightTextObserveTextObserveWidget, currentInputCopyrightObserveValue, null, new EMFUpdateValueStrategy()); // final IObservableValue licenseTextObserveTextObserveWidget = SWTObservables.observeDelayedValue(300, SWTObservables.observeText(licenseText, SWT.Modify)); final IObservableValue currentInputLicenseObserveValue = EMFEditObservables.observeValue(editingDomain, currentInput, Literals.JOOMLA_EXTENSION_MANIFEST__LICENSE); bindingContext.bindValue(licenseTextObserveTextObserveWidget, currentInputLicenseObserveValue, null, new EMFUpdateValueStrategy()); // return bindingContext; }
From source file:com.siemens.ct.mp3m.ui.editors.id3.databinding.Id3TagPage.java
License:Open Source License
private void addKeyValuePair(String key, IMP3Info id3TagInfo, String value, final DataBindingContext bindingContext, boolean editable) { StringFieldEditor stringEditor = new StringFieldEditor(key, key + ":", section); //$NON-NLS-1$ toolkit.adapt(stringEditor.getTextControl(section), true, true); stringEditor.setEnabled(editable, section); Label label = stringEditor.getLabelControl(section); label.setEnabled(true);//from ww w . j a v a2 s . c om toolkit.adapt(label, false, false); ControlDecoration controlDecoration = createTextDecoration(stringEditor.getTextControl(section)); // do the data binding bindingContext.bindValue(SWTObservables.observeText(stringEditor.getTextControl(section), SWT.Modify), PojoObservables.observeValue(id3TagInfo, value), new UpdateValueStrategy().setAfterConvertValidator(new RequiredValidator(controlDecoration, this)), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); stringEditor.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (AggregateValidationStatus .getStatusMerged(bindingContext.getValidationStatusProviders()) == Status.OK_STATUS) { if (event.getProperty().equals("field_editor_value")) { isDirty = true; } getEditor().editorDirtyStateChanged(); } } }); fieldEditors.add(stringEditor); }
From source file:com.softberries.klerk.gui.dialogs.AddressDialog.java
License:Open Source License
protected DataBindingContext initDataBindings() { IValidator notEmptyValidator = new FieldNotEmptyValidator("This field cannot be empty!"); DataBindingContext bindingContext = new DataBindingContext(); UpdateValueStrategy ttm = new UpdateValueStrategy(); ttm.setBeforeSetValidator(notEmptyValidator); ///*from ww w. j ava2 s . c om*/ IObservableValue countryTxtObserveTextObserveWidget = SWTObservables.observeText(countryTxt, SWT.Modify); IObservableValue currentAddressCountryObserveValue = PojoObservables.observeValue(currentAddress, "country"); Binding binding = bindingContext.bindValue(countryTxtObserveTextObserveWidget, currentAddressCountryObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); // IObservableValue cityTxtObserveTextObserveWidget = SWTObservables.observeText(cityTxt, SWT.Modify); IObservableValue currentAddressCityObserveValue = PojoObservables.observeValue(currentAddress, "city"); binding = bindingContext.bindValue(cityTxtObserveTextObserveWidget, currentAddressCityObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); // IObservableValue streetTxtObserveTextObserveWidget = SWTObservables.observeText(streetTxt, SWT.Modify); IObservableValue currentAddressStreetObserveValue = PojoObservables.observeValue(currentAddress, "street"); binding = bindingContext.bindValue(streetTxtObserveTextObserveWidget, currentAddressStreetObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); // IObservableValue houseNrTxtObserveTextObserveWidget = SWTObservables.observeText(houseNrTxt, SWT.Modify); IObservableValue currentAddressHouseNumberObserveValue = PojoObservables.observeValue(currentAddress, "houseNumber"); binding = bindingContext.bindValue(houseNrTxtObserveTextObserveWidget, currentAddressHouseNumberObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); // IObservableValue flatNrTxtObserveTextObserveWidget = SWTObservables.observeText(flatNrTxt, SWT.Modify); IObservableValue currentAddressFlatNumberObserveValue = PojoObservables.observeValue(currentAddress, "flatNumber"); bindingContext.bindValue(flatNrTxtObserveTextObserveWidget, currentAddressFlatNumberObserveValue, null, null); // IObservableValue postCodeTxtObserveTextObserveWidget = SWTObservables.observeText(postCodeTxt, SWT.Modify); IObservableValue currentAddressPostCodeObserveValue = PojoObservables.observeValue(currentAddress, "postCode"); binding = bindingContext.bindValue(postCodeTxtObserveTextObserveWidget, currentAddressPostCodeObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); // IObservableValue notesTxtObserveTextObserveWidget = SWTObservables.observeText(notesTxt, SWT.Modify); IObservableValue currentAddressNotesObserveValue = PojoObservables.observeValue(currentAddress, "notes"); bindingContext.bindValue(notesTxtObserveTextObserveWidget, currentAddressNotesObserveValue, null, null); // return bindingContext; }
From source file:com.softberries.klerk.gui.editors.SingleDocumentEditor.java
License:Open Source License
protected void bindValidator(Text field, Object obj, String property, IValidator validator) { DataBindingContext bindingContext = new DataBindingContext(); UpdateValueStrategy ttm = new UpdateValueStrategy(); ttm.setBeforeSetValidator(validator); ///*w w w . ja v a 2s . c o m*/ IObservableValue countryTxtObserveTextObserveWidget = SWTObservables.observeText(field, SWT.Modify); IObservableValue currentAddressCountryObserveValue = PojoObservables.observeValue(obj, property); Binding binding = bindingContext.bindValue(countryTxtObserveTextObserveWidget, currentAddressCountryObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); }
From source file:com.softberries.klerk.gui.editors.SingleObjectEditor.java
License:Open Source License
protected void bindValidator(Text field, Object obj, String property, IValidator validator) { DataBindingContext bindingContext = new DataBindingContext(); UpdateValueStrategy ttm = new UpdateValueStrategy(); ttm.setBeforeSetValidator(validator); ////from ww w . ja v a2 s . com IObservableValue countryTxtObserveTextObserveWidget = SWTObservables.observeText(field, SWT.Modify); IObservableValue currentAddressCountryObserveValue = PojoObservables.observeValue(obj, property); Binding binding = bindingContext.bindValue(countryTxtObserveTextObserveWidget, currentAddressCountryObserveValue, ttm, null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); }