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:de.uniluebeck.itm.spyglass.plugin.mappainter.MapPainterPrefComposite.java
License:Open Source License
private void updateScaleLinkBlock() { final boolean locked = config.getLockGridElementSquare(); if (locked) { blockHeight.setText(blockWidth.getText()); if (lockBinding2 == null) { // bind the two fields together lockBinding2 = dbc.bindValue(SWTObservables.observeText(blockWidth, SWT.Modify), SWTObservables.observeText(this.blockHeight, SWT.Modify), null, null); }// w w w .j ava 2 s . co m button2.setImage(SWTResourceManager .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_closed_hor.png")); } else { if (lockBinding2 != null) { // Kill the binding (it will be automatically removed from the dbc) lockBinding2.dispose(); lockBinding2 = null; } button2.setImage(SWTResourceManager .getImage("de/uniluebeck/itm/spyglass/gui/configuration/chain_small_open_hor.png")); } }
From source file:de.uniluebeck.itm.spyglass.plugin.nodesensorrange.NodeSensorRangeOptionsComposite.java
License:Open Source License
public void setDatabinding(final DataBindingContext dbc, final NodeSensorRangeXMLConfig.Config config, final NodeSensorRangePreferencePage page) { this.page = page; defaultConfigClone = config.clone(); defaultConfigClone.addPropertyChangeListener(dirtyListener); IObservableValue obsModel;// w ww.j a v a 2 s . co m ISWTObservableValue obsWidget; UpdateValueStrategy usTargetToModel; UpdateValueStrategy usModelToTarget; final Realm realm = dbc.getValidationRealm(); { obsWidget = SWTObservables.observeText(defaultLineWidth, SWT.Modify); obsModel = BeansObservables.observeValue(realm, defaultConfigClone, NodeSensorRangeXMLConfig.PROPERTYNAME_LINE_WIDTH); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel.setAfterConvertValidator(new IntegerRangeValidator("Line Width", 1, Integer.MAX_VALUE)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeSelection(defaultRangeType); obsModel = BeansObservables.observeValue(realm, defaultConfigClone, NodeSensorRangeXMLConfig.PROPERTYNAME_RANGE_TYPE); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setConverter(new NodeSensorRangeTypeConverter(String.class, Enum.class)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeBackground(defaultRangeForegroundColor); obsModel = BeansObservables.observeValue(realm, defaultConfigClone, NodeSensorRangeXMLConfig.PROPERTYNAME_COLOR_R_G_B); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel.setConverter(new ColorToRGBConverter()); usModelToTarget = new UpdateValueStrategy(); usModelToTarget.setConverter(new RGBToColorConverter()); dbc.bindValue(obsWidget, obsModel, usTargetToModel, usModelToTarget); } { obsWidget = SWTObservables.observeBackground(defaultRangeBackgroundColor); obsModel = BeansObservables.observeValue(realm, defaultConfigClone, NodeSensorRangeXMLConfig.PROPERTYNAME_BACKGROUND_R_G_B); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel.setConverter(new ColorToRGBConverter()); usModelToTarget = new UpdateValueStrategy(); usModelToTarget.setConverter(new RGBToColorConverter()); dbc.bindValue(obsWidget, obsModel, usTargetToModel, usModelToTarget); } { obsWidget = SWTObservables.observeText(defaultBackgroundAlphaTransparency, SWT.Modify); obsModel = BeansObservables.observeValue(realm, defaultConfigClone, NodeSensorRangeXMLConfig.PROPERTYNAME_BACKGROUND_ALPHA); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel .setAfterConvertValidator(new IntegerRangeValidator("Background Alpha Transparency", 0, 255)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } perNodeConfigurationComposite.setDataBinding(dbc, page); }
From source file:de.uniluebeck.itm.spyglass.plugin.objectpainter.ObjectPainterOptionsComposite.java
License:Open Source License
public void setDatabinding(final DataBindingContext dbc, final ObjectPainterXMLConfig config, final Spyglass spyglass, final ObjectPainterPreferencePage page) { this.page = page; IObservableValue obsModel;/*ww w. j ava2s. c o m*/ ISWTObservableValue obsWidget; UpdateValueStrategy usTargetToModel; { obsWidget = SWTObservables.observeText(imageFileText, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_IMAGE_FILE_NAME); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterGetValidator(new FileReadableValidator()); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeText(imageSizeWidthText, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_IMAGE_SIZE_X); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new IntegerRangeValidator("Width", 0, Integer.MAX_VALUE)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeText(imageSizeHeightText, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_IMAGE_SIZE_Y); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new IntegerRangeValidator("Height", 0, Integer.MAX_VALUE)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeSelection(this.drawLineCheckbox); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_DRAW_LINE); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeSelection(keepProportionsButton); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_KEEP_PROPORTIONS); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { final MetricsXMLConfig mConf = spyglass.getConfigStore().getSpyglassConfig().getGeneralSettings() .getMetrics(); dbc.bindValue(SWTObservables.observeText(this.label3), BeansObservables.observeValue(dbc.getValidationRealm(), mConf, "unit"), null, null); } { final MetricsXMLConfig mConf = spyglass.getConfigStore().getSpyglassConfig().getGeneralSettings() .getMetrics(); dbc.bindValue(SWTObservables.observeText(this.label3a), BeansObservables.observeValue(dbc.getValidationRealm(), mConf, "unit"), null, null); } // TODO: { final IObservableValue observableColor = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_LINE_COLOR); dbc.bindValue(SWTObservables.observeBackground(colorExample), observableColor, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setConverter(new ColorToArrayConverter()), new UpdateValueStrategy().setConverter(new ArrayToColorConverter(this.getDisplay()))); } { final IObservableValue observable = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_PACKET_TYPE_3D); dbc.bindValue(SWTObservables.observeSelection(combo1), observable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setConverter(new Converter("", true) { @Override public Object convert(final Object fromObject) { return fromObject.equals("TrajectoryPacket3D"); } }), new UpdateValueStrategy().setConverter(new Converter(true, "") { @Override public Object convert(final Object fromObject) { return ((Boolean) fromObject) ? "TrajectoryPacket3D" : "TrajectoryPacket2D"; } })); } { obsWidget = SWTObservables.observeText(inteval, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, ObjectPainterXMLConfig.PROPERTYNAME_UPDATE_INTERVAL); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new IntegerRangeValidator("Display update interval", 50, 10000)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } }
From source file:de.uniluebeck.itm.spyglass.plugin.positionpacketnodepositioner.PositionPacketNodePositionerPreferencePage.java
License:Open Source License
private void addDatabinding() { final IObservableValue modelObservable = BeansObservables.observeValue(getRealm(), this.config, "timeout"); dbc.bindValue(SWTObservables.observeText(fieldName, SWT.Modify), modelObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator( new IntegerRangeValidator("Timeout", 0, Integer.MAX_VALUE)), null);// w w w .ja v a 2 s .c o m }
From source file:de.uniluebeck.itm.spyglass.plugin.simpleglobalinformation.SimpleGlobalInformationOptionsComposite.java
License:Open Source License
/** * Sets the parameters necessary for data binding * /*ww w . jav a 2s. c o m*/ * @param dbc * the data binding context * @param config * the configuration */ public void setDatabinding(final DataBindingContext dbc, final SimpleGlobalInformationXMLConfig config) { stringFormatter.setDataBinding(dbc); // show the total number of available nodes final IObservableValue observableshowNN = BeansObservables.observeValue(dbc.getValidationRealm(), config, "showNumNodes"); dbc.bindValue(SWTObservables.observeSelection(this.showNumNodes), observableshowNN, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); // semantic types { final IObservableValue modelObservable2 = BeansObservables.observeValue(dbc.getValidationRealm(), config, "semanticTypes4Neighborhoods"); final UpdateValueStrategy strFromModel = new UpdateValueStrategy(); strFromModel.setConverter(new IntListToStringConverter()); final UpdateValueStrategy strToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); 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); } // show the average node degree final IObservableValue observableshowAVGND = BeansObservables.observeValue(dbc.getValidationRealm(), config, "showNodeDegree"); dbc.bindValue(SWTObservables.observeSelection(this.showAVGNodeDegree), observableshowAVGND, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); // if the average node degree is not to be shown, disable the semantic types field { dbc.bindValue(SWTObservables.observeSelection(this.showAVGNodeDegree), SWTObservables.observeEnabled(this.semanticTypes), null, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER)); semanticTypes.setEnabled(showAVGNodeDegree.getSelection()); } }
From source file:de.uniluebeck.itm.spyglass.plugin.simplenodepainter.OptionsComposite.java
License:Open Source License
/** * Sets the parameters necessary for data binding * // w w w. jav a 2 s . c o m * @param dbc * the data binding context * @param config * the configuration * @param page * the plug-in's preference page */ public void setDatabinding(final DataBindingContext dbc, final PluginXMLConfig config, final SimpleNodePainterPreferencePage page) { this.page = page; // line width final IObservableValue modelObservable = BeansObservables.observeValue(dbc.getValidationRealm(), config, SimpleNodePainterXMLConfig.PROPERTYNAME_LINE_WIDTH); dbc.bindValue(SWTObservables.observeText(this.lineWidth, SWT.Modify), modelObservable, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); // extended inf final IObservableValue observableExtInf = BeansObservables.observeValue(dbc.getValidationRealm(), config, SimpleNodePainterXMLConfig.PROPERTYNAME_EXTENDED_DEFAULT_VALUE); dbc.bindValue(SWTObservables.observeSelection(this.showExtInf), observableExtInf, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); // node indertifier representation final IObservableValue observableNodeRepr = BeansObservables.observeValue(dbc.getValidationRealm(), config, SimpleNodePainterXMLConfig.PROPERTYNAME_NODE_IDS_AS_HEX); dbc.bindValue(SWTObservables.observeSelection(this.nodeIDsAsHex), observableNodeRepr, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT), null); // line color final IObservableValue observableColor = BeansObservables.observeValue(dbc.getValidationRealm(), config, SimpleNodePainterXMLConfig.PROPERTYNAME_LINE_COLOR_R_G_B); dbc.bindValue(SWTObservables.observeBackground(colorExample), observableColor, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setConverter(new ColorToArrayConverter()), new UpdateValueStrategy().setConverter(new ArrayToColorConverter(this.getDisplay()))); stringFormatter.setDataBinding(dbc, config); }
From source file:de.uniluebeck.itm.spyglass.plugin.springembedderpositioner.SpringEmbedderPositionerOptionsComposite.java
License:Open Source License
public SpringEmbedderPositionerOptionsComposite(final Composite parent, final DataBindingContext dbc, final SpringEmbedderPositionerXMLConfig config) { super(parent, SWT.NONE); initGui();/* w w w.j av a 2 s . co m*/ this.dbc = dbc; this.config = config; IObservableValue obsModel; ISWTObservableValue obsWidget; { obsWidget = SWTObservables.observeText(timeout, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_TIMEOUT); dbc.bindValue( obsWidget, obsModel, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new IntegerRangeValidator("Timeout", 0, Integer.MAX_VALUE)), null); } { obsWidget = SWTObservables.observeText(optimumSpringLength, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, SpringEmbedderPositionerXMLConfig.PROPERTYNAME_OPTIMUM_SPRING_LENGTH); dbc.bindValue(obsWidget, obsModel, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setAfterConvertValidator( new IntegerRangeValidator("Optimum spring length", 0, Integer.MAX_VALUE)), null); } { obsWidget = SWTObservables.observeText(springStiffness, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, SpringEmbedderPositionerXMLConfig.PROPERTYNAME_SPRING_STIFFNESS); dbc.bindValue(obsWidget, obsModel, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new DoubleRangeValidator("Spring's stiffness", 0, 1)), null); } { obsWidget = SWTObservables.observeText(repulsionFactor, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, SpringEmbedderPositionerXMLConfig.PROPERTYNAME_REPULSION_FACTOR); dbc.bindValue(obsWidget, obsModel, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new IntegerRangeValidator("Repulsion factor", 0, Integer.MAX_VALUE)), null); } { obsWidget = SWTObservables.observeText(efficiencyFactor, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, SpringEmbedderPositionerXMLConfig.PROPERTYNAME_EFFICIENCY_FACTOR); dbc.bindValue( obsWidget, obsModel, new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT) .setAfterConvertValidator(new DoubleRangeValidator("Efficiency of forces", 0, 1)), null); } { obsWidget = SWTObservables.observeText(semType, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, SpringEmbedderPositionerXMLConfig.PROPERTYNAME_EDGE_SEMANTIC_TYPES); final UpdateValueStrategy strToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); strToModel.setConverter(new StringToIntListConverter()); strToModel.setAfterConvertValidator( new IntegerRangeValidator("Semantic type(s) for neighbourhood", -1, 255)); strToModel.setAfterGetValidator(new StringToIntListValidator("Semantic type(s) for neighbourhood")); final UpdateValueStrategy strFromModel = new UpdateValueStrategy(); strFromModel.setConverter(new IntListToStringConverter()); dbc.bindValue(obsWidget, obsModel, strToModel, strFromModel); } }
From source file:de.uniluebeck.itm.spyglass.plugin.vectorsequencepainter.VectorSequencePainterOptionsComposite.java
License:Open Source License
public void setDatabinding(final DataBindingContext dbc, final VectorSequencePainterXMLConfig config, final VectorSequencePainterPreferencePage page) { this.page = page; IObservableValue obsModel;/*from ww w .ja v a 2s .c o m*/ ISWTObservableValue obsWidget; UpdateValueStrategy usTargetToModel; UpdateValueStrategy usModelToTarget; { obsWidget = SWTObservables.observeText(lineWidth, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, VectorSequencePainterXMLConfig.PROPERTYNAME_LINE_WIDTH); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel.setAfterConvertValidator(new IntegerRangeValidator("Line Width", 1, Integer.MAX_VALUE)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeBackground(lineColor); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, VectorSequencePainterXMLConfig.PROPERTYNAME_LINE_COLOR_R_G_B); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel.setConverter(new ColorToArrayConverter()); usModelToTarget = new UpdateValueStrategy(); usModelToTarget.setConverter(new ArrayToColorConverter(this.getDisplay())); dbc.bindValue(obsWidget, obsModel, usTargetToModel, usModelToTarget); } { obsWidget = SWTObservables.observeText(ttl, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, PluginXMLConfig.PROPERTYNAME_TIMEOUT); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel .setAfterConvertValidator(new IntegerRangeValidator("Time To Live", 0, Integer.MAX_VALUE)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } { obsWidget = SWTObservables.observeText(dimension, SWT.Modify); obsModel = BeansObservables.observeValue(dbc.getValidationRealm(), config, VectorSequencePainterXMLConfig.PROPERTYNAME_DIMENSION); usTargetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT); usTargetToModel.setAfterConvertValidator(new IntegerRangeValidator("Dimension", 2, 3)); dbc.bindValue(obsWidget, obsModel, usTargetToModel, null); } }
From source file:de.walware.docmlet.tex.internal.ui.preferences.TexCodeStylePreferenceBlock.java
License:Open Source License
@Override protected void addBindings(final DataBindingSupport db) { fStdIndentSettings.addBindings(db, fModel); db.getContext().bindValue(SWTObservables.observeText(fIndentBlockDepthControl, SWT.Modify), BeansObservables.observeValue(db.getRealm(), fModel, TexCodeStyleSettings.INDENT_BLOCK_DEPTH_PROP), new UpdateValueStrategy().setAfterGetValidator( new IntegerValidator(1, 10, Messages.CodeStyle_Indent_IndentInBlocks_error_message)), null);//from www. ja v a 2s . c om db.getContext().bindValue(SWTObservables.observeText(fIndentEnvDepthControl, SWT.Modify), BeansObservables.observeValue(db.getRealm(), fModel, TexCodeStyleSettings.INDENT_ENV_DEPTH_PROP), new UpdateValueStrategy().setAfterGetValidator( new IntegerValidator(1, 10, Messages.CodeStyle_Indent_IndentInEnvs_error_message)), null); final WritableSet labels = new WritableSet(db.getRealm()); fIndentEnvLabelsControl.setInput(labels); db.getContext().bindSet(labels, BeansObservables.observeSet(db.getRealm(), fModel, TexCodeStyleSettings.INDENT_ENV_LABELS_PROP)); }
From source file:de.walware.rj.eclient.graphics.RGraphicsPreferencePage.java
License:Open Source License
protected void addBindings(final DataBindingContext dbc, final Realm realm) { fCustomHDpiVisibleValue = new WritableValue(realm, 96.0, Double.class); fCustomVDpiVisibleValue = new WritableValue(realm, 96.0, Double.class); dbc.bindValue(SWTObservables.observeText(fCustomHDpiControl, SWT.Modify), fCustomHDpiVisibleValue, new UpdateValueStrategy().setAfterGetValidator(new DecimalValidator(10.0, 10000.0, "The value for Horizontal (x) DPI is invalid (10-10000).")), null);/*w ww. j a v a 2s . c o m*/ dbc.bindValue(SWTObservables.observeText(fCustomVDpiControl, SWT.Modify), fCustomVDpiVisibleValue, new UpdateValueStrategy().setAfterGetValidator(new DecimalValidator(10.0, 10000.0, "The value for Vertical (x) DPI is invalid (10-10000).")), null); fCustomHDpiVisibleValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { if (fCustomEnabled) { fCustomHDpiUserValue = (Double) fCustomHDpiVisibleValue.getValue(); } } }); fCustomVDpiVisibleValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { if (fCustomEnabled) { fCustomVDpiUserValue = (Double) fCustomVDpiVisibleValue.getValue(); } } }); }