Skip to content
Snippets Groups Projects
Commit 1ca89772 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

added data binding support for int and double

parent 5c425b0f
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,14 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.extension.base;
import org.conqat.ide.commons.ui.databinding.validate.NumberPositiveValidator;
import org.conqat.ide.commons.ui.databinding.validate.TextToDoubleValidator;
import org.conqat.ide.commons.ui.databinding.validate.TextToIntegerValidator;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.conversion.NumberToStringConverter;
import org.eclipse.core.databinding.conversion.StringToNumberConverter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.gef.EditPart;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.layout.GridDataFactory;
......@@ -42,7 +49,7 @@ import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 6DF3091D1AF3953B2611F9A7C36F7793
* @ConQAT.Rating YELLOW Hash: 676ADDC72D693C4D8D63340613269441
*/
public abstract class PropertySectionBase extends AbstractPropertySection {
......@@ -139,4 +146,34 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
dbc.dispose();
dbc = new DataBindingContext();
}
/** Binds a positive double value. */
protected void bindPositiveDouble(Control text,
IObservableValue observedValue) {
bindDoubleValue(text, observedValue, NumberPositiveValidator.INSTANCE);
}
/** Binds a double value. */
protected void bindDoubleValue(Control text,
IObservableValue observedValue, IValidator numberValidator) {
DataBindingUtils.performComplexTextBinding(dbc, text, observedValue,
NumberToStringConverter.fromDouble(false),
StringToNumberConverter.toDouble(false),
TextToDoubleValidator.INSTANCE, numberValidator);
}
/** Binds a positive integer value. */
protected void bindPositiveInteger(Control text,
IObservableValue observedValue) {
bindIntegerValue(text, observedValue, NumberPositiveValidator.INSTANCE);
}
/** Binds a integer value. */
protected void bindIntegerValue(Control text,
IObservableValue observedValue, IValidator numberValidator) {
DataBindingUtils.performComplexTextBinding(dbc, text, observedValue,
NumberToStringConverter.fromInteger(false),
StringToNumberConverter.toInteger(false),
TextToIntegerValidator.INSTANCE, numberValidator);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment