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 f12437e05071d544864e5a2d9ab6850575f24673..213f715bbf061e6ad3e6b408aeb2b1f9af7396c0 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); + } }