From 1ca897728871abad61c36a992b10eaeac8d90dab Mon Sep 17 00:00:00 2001
From: Florian Hoelzl <hoelzl@fortiss.org>
Date: Tue, 26 Jul 2011 12:59:38 +0000
Subject: [PATCH] added data binding support for int and double

---
 .../extension/base/PropertySectionBase.java   | 39 ++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java
index f12437e05..213f715bb 100644
--- a/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java
+++ b/org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/extension/base/PropertySectionBase.java
@@ -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);
+	}
 }
-- 
GitLab