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.toedter.e4.demo.contacts.rap.views.DetailComposite.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 + " "); // the extra space is due to a bug in // font formatting when using css // styling//from w w w . j a va 2 s .c o m GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalIndent = 20; label.setLayoutData(gridData); final Text text = new Text(parent, SWT.NONE); GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL); gridData2.horizontalIndent = 0; if (!generalGroup) { gridData2.horizontalSpan = 2; } else { gridData2.horizontalSpan = 1; if (labelText.equals("Title:")) { // The label image is set with data binding imageLabel = new Label(parent, SWT.NONE); GridData gridData3 = new GridData(); gridData3.verticalSpan = 5; imageLabel.setLayoutData(gridData3); } } text.setLayoutData(gridData2); if (property != null) { if (property.equals("name")) { dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), new AggregateNameObservableValue(contactValue)); } else { dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), PojoObservables.observeDetailValue(contactValue, property, String.class)); } } text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (commitChanges) { setDirty(true); } } }); return text; }
From source file:com.toedter.e4.demo.contacts.swt.views.DetailComposite.java
License:Open Source License
private Text createText(final Composite parent, final String labelText, final String property) { final Label label = new Label(parent, SWT.RIGHT); label.setText(labelText + " "); // the extra space is due to a bug in // font formatting when using css // styling// ww w . ja v a 2 s .c om GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalIndent = 20; label.setLayoutData(gridData); final Text text = new Text(parent, SWT.NONE); GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL); gridData2.horizontalIndent = 0; if (!generalGroup) { gridData2.horizontalSpan = 2; } else { gridData2.horizontalSpan = 1; if (labelText.equals("Title:")) { // The label image is set with data binding imageLabel = new Label(parent, SWT.NONE); GridData gridData3 = new GridData(); gridData3.verticalSpan = 5; imageLabel.setLayoutData(gridData3); } } text.setLayoutData(gridData2); if (property != null) { if (property.equals("name")) { dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), new AggregateNameObservableValue(contactValue)); } else { dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), PojoObservables.observeDetailValue(contactValue, property, String.class)); } } text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (commitChanges) { setDirty(true); } } }); return text; }
From source file:com.xored.af.ui.forms.parts.TextFormPart.java
License:Open Source License
@Override protected IObservableValue observeControl() { return SWTObservables.observeDelayedValue(400, SWTObservables.observeText(text, SWT.Modify)); }
From source file:de.quamoco.qm.properties.DoublePropertySectionBase.java
License:Apache License
/** {@inheritDoc} */ @Override/*from ww w.j av a 2 s . c o m*/ public void refresh() { super.refresh(); IObservableValue modelObservable = EMFEditObservables.observeValue(getEditingDomain(), getElement(), getFeature()); ISWTObservableValue viewObservable = SWTObservables.observeText(text, SWT.FocusOut); getContext().bindValue(viewObservable, modelObservable, new StringToDoubleConverter(), new DoubleToStringConverter()); if (multiline) { refreshHeight(); } }
From source file:de.quamoco.qm.properties.QIESLSpecificationPropertySectionBase.java
License:Apache License
/** {@inheritDoc} */ @Override/*www. ja va 2 s .c o m*/ public void refresh() { super.refresh(); IObservableValue modelObservable = EMFEditObservables.observeValue(getEditingDomain(), getElement(), getFeature()); modelObservable.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { verifyQIESL(null); } }); ISWTObservableValue viewObservable = SWTObservables.observeText(text, SWT.FocusOut); viewObservable.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { verifyQIESL(text.getText()); } }); getContext().bindValue(viewObservable, modelObservable); updateMeasuresAndFactorsTable(); updateNormalizationMeasuresTable(); layout(); verifyQIESL(null); }
From source file:de.quamoco.qm.properties.SpellCheckedTextPropertySectionBase.java
License:Apache License
/** {@inheritDoc} */ @Override//from w w w.jav a 2s.c o m public void refresh() { super.refresh(); IObservableValue modelObservable = EMFEditObservables.observeValue(getEditingDomain(), getElement(), getFeature()); ISWTObservableValue viewObservable = SWTObservables.observeText(text, SWT.FocusOut); getContext().bindValue(viewObservable, modelObservable); if (multiline) { refreshHeight(); } }
From source file:de.uniluebeck.itm.spyglass.gui.configuration.BasicGroupComposite.java
License:Open Source License
/** * Sets the parameters necessary for data binding * //from w w w .j av a 2 s . co m * @param dbc * the data binding context * @param config * the configuration * @param owner * @param manager * the plug-in managing instance * @param isInstancePage * <code>true</code> indicates that this widget is used to set parameters for a * plug-in instance, <code>false</code> indicates that this widget is used to set * parameters for a plug-in type. * */ public void setDatabinding(final DataBindingContext dbc, final PluginXMLConfig config, final Plugin owner, final PluginManager manager, final boolean isInstancePage) { // plugin name { final IObservableValue modelObservable = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_NAME); final ISWTObservableValue fieldObservableText = SWTObservables.observeText(pluginName, SWT.Modify); if (isInstancePage) { dbc.bindValue(fieldObservableText, modelObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new PluginNameValidator(manager, owner)), null); } else { dbc.bindValue(fieldObservableText, modelObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); } } // semantic types { final IObservableValue modelObservable2 = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_SEMANTIC_TYPES); final UpdateValueStrategy strToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); final UpdateValueStrategy strFromModel = new UpdateValueStrategy(); strFromModel.setConverter(new IntListToStringConverter()); strToModel.setConverter(new StringToIntListConverter()); strToModel.setAfterConvertValidator(new IntegerRangeValidator("Semantic types", -1, 255)); strToModel.setAfterGetValidator(new StringToIntListValidator("Semantic types")); dbc.bindValue(SWTObservables.observeText(this.semanticTypes, SWT.Modify), modelObservable2, strToModel, strFromModel); } // all semTypes { final IObservableValue observableAllSemTypes = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_ALL_SEMANTIC_TYPES); final IObservableValue observableAllSemTypesCheckbox = SWTObservables.observeSelection(this.allTypes); dbc.bindValue(observableAllSemTypesCheckbox, observableAllSemTypes, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); } // is visible { final IObservableValue observableVisible = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_VISIBLE); dbc.bindValue(SWTObservables.observeSelection(this.isVisible), observableVisible, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); } // is active { final IObservableValue observableActive = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_ACTIVE); final IObservableValue observableActiveButton = SWTObservables.observeSelection(this.isActive); dbc.bindValue(observableActiveButton, observableActive, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); } // disable the visibility field if plug-in is inactive { // ... but only if it's visibility button is not to be disabled all the time if (!basicOptions.equals(BasicOptions.ALL_BUT_VISIBLE) && !basicOptions.equals(BasicOptions.ALL_BUT_VISIBLE_AND_SEMANTIC_TYPES)) { dbc.bindValue(SWTObservables.observeEnabled(this.isVisible), SWTObservables.observeSelection(this.isActive), null, null); } } }
From source file:de.uniluebeck.itm.spyglass.gui.configuration.GeneralPreferencesComposite.java
License:Open Source License
public void setDatabinding(final DataBindingContext dbc, final GeneralSettingsXMLConfig config) { this.config = config; this.dbc = dbc; // unit length final IObservableValue modelObservable2 = BeansObservables.observeValue(dbc.getValidationRealm(), config.getMetrics(), "unit"); dbc.bindValue(SWTObservables.observeText(this.unitLength, SWT.Modify), modelObservable2, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator( new StringRegExValidator("Unit of length", ".+", "Please enter a unit.")), new UpdateValueStrategy()); // showRuler//from w w w .j a va 2 s . c o m final IObservableValue observableVisible = BeansObservables.observeValue(dbc.getValidationRealm(), config, "showRuler"); dbc.bindValue(SWTObservables.observeSelection(this.showRuler), observableVisible, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); // unit of time final IObservableValue modelObservable2b = BeansObservables.observeValue(dbc.getValidationRealm(), config, "timeUnit"); dbc.bindValue(SWTObservables.observeText(this.unitTime, SWT.Modify), modelObservable2b, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator( new StringRegExValidator("Unit of time", ".+", "Please enter a unit.")), new UpdateValueStrategy()); // offset X dbc.bindValue(SWTObservables.observeText(this.offsetX, SWT.Modify), BeansObservables.observeValue(dbc.getValidationRealm(), config.getMetrics(), "abs2metricOffsetX"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), new UpdateValueStrategy()); // offset Y dbc.bindValue(SWTObservables.observeText(this.offsetY, SWT.Modify), BeansObservables.observeValue(dbc.getValidationRealm(), config.getMetrics(), "abs2metricOffsetY"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), new UpdateValueStrategy()); // scale X dbc.bindValue(SWTObservables.observeText(this.scaleX, SWT.Modify), BeansObservables.observeValue(dbc.getValidationRealm(), config.getMetrics(), "abs2metricFactorX"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), new UpdateValueStrategy()); // scale Y dbc.bindValue(SWTObservables.observeText(this.scaleY, SWT.Modify), BeansObservables.observeValue(dbc.getValidationRealm(), config.getMetrics(), "abs2metricFactorY"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), new UpdateValueStrategy()); // scale Time dbc.bindValue(SWTObservables.observeText(this.scaleTime, SWT.Modify), BeansObservables.observeValue(dbc.getValidationRealm(), config, "timeScale"), new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), new UpdateValueStrategy()); dbc.bindValue(SWTObservables.observeText(this.label11length), SWTObservables.observeText(this.unitLength, SWT.Modify), null, null); dbc.bindValue(SWTObservables.observeText(this.label9length), SWTObservables.observeText(this.unitLength, SWT.Modify), null, null); updateScaleLink(); }
From source file:de.uniluebeck.itm.spyglass.gui.configuration.GeneralPreferencesComposite.java
License:Open Source License
private void updateScaleLink() { final boolean locked = config.getMetrics().getLockAbs2metricFactor(); if (locked) { scaleY.setText(scaleX.getText()); if (lockBinding == null) { // bind the two fields together lockBinding = dbc.bindValue(SWTObservables.observeText(scaleX, SWT.Modify), SWTObservables.observeText(scaleY, SWT.Modify), null, null); }//ww w . j ava 2 s. c om linkButton.setImage(SWTResourceManager .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_closed.png")); } else { if (lockBinding != null) { // Kill the binding (it will be automatically removed from the dbc) lockBinding.dispose(); lockBinding = null; } linkButton.setImage(SWTResourceManager .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_open.png")); } }
From source file:de.uniluebeck.itm.spyglass.gui.databinding.DatabindingTextEditingSupport.java
License:Open Source License
@Override protected IObservableValue doCreateCellEditorObservable(final CellEditor cellEditor) { return SWTObservables.observeText(cellEditor.getControl(), SWT.Modify); }