Skip to content
Snippets Groups Projects
Commit 7e12b015 authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/kernel.git into

3470-timing_model

Conflicts:
	org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings
	org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/internal/properties/.ratings


Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parents 12a19d99 54cab21b
No related branches found
No related tags found
1 merge request!393470 timing model
Showing
with 286 additions and 110 deletions
......@@ -19,7 +19,6 @@ Export-Package: org.fortiss.tooling.base.ui,
org.fortiss.tooling.base.ui.annotation.view.generic.filter,
org.fortiss.tooling.base.ui.compose,
org.fortiss.tooling.base.ui.contentprovider,
org.fortiss.tooling.base.ui.databinding,
org.fortiss.tooling.base.ui.dialog,
org.fortiss.tooling.base.ui.dnd.gef,
org.fortiss.tooling.base.ui.dnd.jface,
......
AbstractDecoratedStyledTextCellDatabindingEditingSupport.java 7db18b7973f945f087c0188f485fe3a63007d6c8 GREEN
AbstractDecoratedTextCellDatabindingEditingSupport.java 35f02a80a8d66975eace1805247ff4e2f8129283 GREEN
AbstractStyledTextCellDatabindingEditingSupport.java 8207d7cc6e5d49f8bca0b46fe92a08df85ad9094 GREEN
AbstractTextCellDatabindingEditingSupport.java 348e8377f8da4f8a4073c96cee58178635641678 GREEN
FloatValidator.java 371c13a05481c3d03304e82997b523eeec8746aa GREEN
IntValidator.java 6362bd7648937720f85027878e3e84d2b5a534d5 GREEN
NumberPositiveZeroValidator.java c960cf31a35f352cf31fa96a409073c04e83ca02 GREEN
......@@ -7,5 +7,4 @@ DiagramEditorBase.java 09663ce095074d1a8eef086284eea0a7776e0431 GREEN
DiagramKeyHandler.java cfd15ac8f9fc933739cef5e7039960e19826d1ce GREEN
FormsEditorBase.java 4046d340913d951340084ae7240d79f8e75cb8d4 GREEN
GEFEditorBase.java e668f596f45f07215994cbbd3929a9438331718f GREEN
StyledTextCellEditor.java c709c5092bf54d42ddbac53c8751659020060aef GREEN
TreeViewerEditorBase.java 1c59689ff57c4f3cc180d85f13021fc03461ecb0 GREEN
......@@ -13,7 +13,9 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: fortiss GmbH
Export-Package: org.fortiss.tooling.kernel.ui,
org.fortiss.tooling.kernel.ui.databinding,
org.fortiss.tooling.kernel.ui.dnd,
org.fortiss.tooling.kernel.ui.editor,
org.fortiss.tooling.kernel.ui.extension,
org.fortiss.tooling.kernel.ui.extension.base,
org.fortiss.tooling.kernel.ui.extension.data,
......
AbstractDecoratedStyledTextCellDatabindingEditingSupport.java a0b06a9bd98ce28da3e5df86b2cb289b5a7a2eab GREEN
AbstractDecoratedTextCellDatabindingEditingSupport.java d82943c0d4000b164beb45b00c64665cdcab2352 GREEN
AbstractStyledTextCellDatabindingEditingSupport.java 6ddea6d5cb18847f202043d9bb2bd8a55ae27a12 GREEN
AbstractTextCellDatabindingEditingSupport.java 8728e78f399a63c11f020fa447c002f42d735771 GREEN
FloatValidator.java 3173a438f0dc773331be9c7d57478984e1fd52b6 GREEN
IntValidator.java 934eee306191839be6d319432a1a238ff38c3f66 GREEN
NumberPositiveValidator.java c45d4433c260e1e7bd4117954221dacb6d2df225 GREEN
NumberPositiveZeroValidator.java 8ba0dfdcc8b8ad2154f2fb3e6217ff585e59d6e5 GREEN
NumberValidator.java 1acdc8a42e9d081251c698a90014989733b50120 GREEN
NumberValueValidatorBase.java a8cda58d8bba6fdc05c6ac3249dbf1b53fcb0c2b GREEN
......@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.DECORATION_KEY;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performCellTextBinding;
......
......@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.DECORATION_KEY;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performCellTextBinding;
......
......@@ -13,14 +13,14 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.ui.editor.StyledTextCellEditor;
import org.fortiss.tooling.kernel.ui.editor.StyledTextCellEditor;
import org.fortiss.tooling.kernel.ui.extension.base.EditorBase;
/**
......
......@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
......@@ -28,7 +28,6 @@ import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.widgets.Composite;
import org.fortiss.tooling.base.ui.fieldassist.FieldAssist;
import org.fortiss.tooling.kernel.ui.util.DataBindingUtils;
/**
......@@ -73,23 +72,12 @@ public abstract class AbstractTextCellDatabindingEditingSupport extends EditingS
protected CellEditor createCellEditor(ColumnViewer viewer) {
CellEditor cellEditor = new TextCellEditor((Composite)viewer.getControl());
setupCellEditor(cellEditor);
setupFieldAssist(cellEditor);
return cellEditor;
}
/** Set up the new created {@link CellEditor} */
protected abstract void setupCellEditor(CellEditor cellEditor);
/**
* Sets up {@link FieldAssist} for the cellEditor.
*
* @param cellEditor
* The {@link CellEditor} to create a {@link FieldAssist} for.
*/
protected void setupFieldAssist(CellEditor cellEditor) {
// Empty
}
/** {@inheritDoc} */
@Override
public CellEditor getCellEditor(Object model) {
......
......@@ -13,35 +13,28 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import static org.eclipse.core.databinding.validation.ValidationStatus.cancel;
import static org.eclipse.core.runtime.Status.OK_STATUS;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
import java.text.NumberFormat;
/**
* Validator for String to Float conversion.
* Validator to check if a number is an floating point number.
*
* @author hoelzl
* @author hoelzl, barner
*/
public class FloatValidator implements IValidator {
public class FloatValidator extends NumberValidator {
/** Singleton instance. */
/** {@link FloatValidator} singleton instance. */
public static final FloatValidator FLOAT_VALIDATOR = new FloatValidator();
/** Constructor. */
private FloatValidator() {
super(NumberFormat.getNumberInstance());
}
/** {@inheritDoc} */
@Override
public IStatus validate(Object value) {
if(value instanceof String) {
try {
Float.valueOf((String)value);
return OK_STATUS;
} catch(NumberFormatException nfex) {
// ignore
}
}
return cancel("Illegal float value!");
protected String getFormatName() {
return "Floating point";
}
}
......@@ -13,35 +13,28 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import static org.eclipse.core.databinding.validation.ValidationStatus.cancel;
import static org.eclipse.core.runtime.Status.OK_STATUS;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
import java.text.NumberFormat;
/**
* Validator for String to Int conversion.
* Validator to check if a number is an integer.
*
* @author hoelzl
* @author hoelzl, barner
*/
public class IntValidator implements IValidator {
public class IntValidator extends NumberValidator {
/** Singleton instance. */
/** {@link IntValidator} singleton instance. */
public static final IntValidator INT_VALIDATOR = new IntValidator();
/** Constructor. */
private IntValidator() {
super(NumberFormat.getIntegerInstance());
}
/** {@inheritDoc} */
@Override
public IStatus validate(Object value) {
if(value instanceof String) {
try {
Integer.valueOf((String)value);
return OK_STATUS;
} catch(NumberFormatException nfex) {
// ignore
}
}
return cancel("Illegal int value!");
protected String getFormatName() {
return "Integer";
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.databinding;
import static org.eclipse.core.databinding.validation.ValidationStatus.cancel;
import static org.eclipse.core.databinding.validation.ValidationStatus.ok;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
/**
* {@link IValidator} for checking that a numeric value is positive.
*
* @author barner
*/
public class NumberPositiveValidator extends NumberValueValidatorBase {
/** Singleton instance. */
public static final NumberPositiveValidator NUMBER_POSITIVE_VALIDATOR =
new NumberPositiveValidator();
/** {@inheritDoc} */
@Override
protected IStatus doValidate(Number number) {
if(number.doubleValue() <= 0) {
return cancel("Value must be > 0");
}
return ok();
}
}
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
......@@ -13,32 +13,32 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.databinding;
package org.fortiss.tooling.kernel.ui.databinding;
import static org.eclipse.core.databinding.validation.ValidationStatus.cancel;
import static org.eclipse.core.databinding.validation.ValidationStatus.ok;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
/**
* {@link IValidator} for checking that a numeric value is positive or zero.
*
* @author hattendorf
* @author barner
*/
public class NumberPositiveZeroValidator implements IValidator {
public class NumberPositiveZeroValidator extends NumberValueValidatorBase {
/** Singleton instance. */
public static final NumberPositiveZeroValidator INSTANCE = new NumberPositiveZeroValidator();
public static final NumberPositiveZeroValidator NUMBER_POSITIVE_ZERO_VALIDATOR =
new NumberPositiveZeroValidator();
/** {@inheritDoc} */
@Override
public IStatus validate(Object value) {
if(!(value instanceof Number)) {
return ValidationStatus
.cancel("Internal: Expected a Number, but had a " + value.getClass());
}
if(((Number)value).doubleValue() < 0) {
return ValidationStatus.cancel("Value must be positive or zero!");
protected IStatus doValidate(Number number) {
if(number.doubleValue() < 0) {
return cancel("Value must be >= 0");
}
return ValidationStatus.ok();
return ok();
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.databinding;
import static org.eclipse.core.databinding.validation.ValidationStatus.cancel;
import static org.eclipse.core.databinding.validation.ValidationStatus.ok;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
/**
* Validates if a given input is a valid {@link Number}.
*
* @author barner
*/
public abstract class NumberValidator implements IValidator {
/** The number format used in the current locale. */
private final NumberFormat format;
/** Character used to separate blocks of large numbers. */
private Character groupingSeparator;
/** Constructor. */
protected NumberValidator(NumberFormat format) {
this.format = format;
if(format instanceof DecimalFormat) {
DecimalFormat df = (DecimalFormat)format;
groupingSeparator = df.getDecimalFormatSymbols().getGroupingSeparator();
}
}
/** Returns the format name. */
protected abstract String getFormatName();
/** {@inheritDoc} */
@Override
public IStatus validate(Object value) {
String input = value != null ? value.toString() : "";
String trimmedInput = input.trim();
if(trimmedInput.isEmpty()) {
return ok();
}
if((groupingSeparator != null) && (trimmedInput.indexOf(groupingSeparator) != -1)) {
return cancel("Grouping separator \'" + groupingSeparator + "\' not allowed");
}
ParsePosition p = new ParsePosition(0);
format.parse(trimmedInput, p);
int errorIndex = p.getErrorIndex();
if(errorIndex == -1) {
// In case the input has a valid prefix, the error index will not indicate a problem.
// Therefore, check if the entire input was parsed.
if(p.getIndex() < trimmedInput.length()) {
errorIndex = p.getIndex();
} else {
return ok();
}
}
int n = input.indexOf(trimmedInput) + errorIndex;
return cancel(getFormatName() + " format validation failed at position " + n);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.databinding;
import static org.eclipse.core.databinding.validation.ValidationStatus.cancel;
import static org.eclipse.core.databinding.validation.ValidationStatus.ok;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
/**
* Base class for {@link IValidator}s to check the value of {@link Number}s.
*
* @author barner
*/
public abstract class NumberValueValidatorBase implements IValidator {
/** {@inheritDoc} */
@Override
public final IStatus validate(Object value) {
if(value == null) {
return ok();
}
if(!(value instanceof Number)) {
String typeName = value.getClass().getSimpleName();
error(ToolingKernelActivator.getDefault(), "Value \"" + value.toString() +
"\" is not a number but of type " + typeName + ".");
return cancel("Value is not a number");
}
return doValidate((Number)value);
}
/** Checks the value of the provided {@link Number}. */
protected abstract IStatus doValidate(Number number);
}
StyledTextCellEditor.java e844c8236bb162bcbe980e47796f7e93c57a14d6 GREEN
......@@ -13,7 +13,7 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.editor;
package org.fortiss.tooling.kernel.ui.editor;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.widgets.Composite;
......
......@@ -10,7 +10,7 @@ ModelEditorBindingBase.java 4c5ac569c0b6e7678fc8191096b26dfd09fdcb98 GREEN
ModelElementHandlerBase.java 384727748f125c9d43f19d9c0eba4ba1be5a7a26 GREEN
MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN
NamedCommentedModelElementHandlerBase.java 681b98b50b362f01abb7a36f108f4f11b9e51829 GREEN
PropertySectionBase.java c061c62531621d96b1e1d1c27ad99889c92bacb7 YELLOW
PropertySectionBase.java 0a39bd8587eeeeb72693b57e80ae8951c3e45c22 YELLOW
TutorialStepUIAtomicBase.java cea2a158158b476de2108d2309afcf47f217b6d9 GREEN
TutorialStepUIAtomicWithWhitelistBase.java a9788ae514f62d27169c737ef59fb583234b5d43 GREEN
TutorialStepUICompositeBase.java 8225210eacb5b88de47d78280c5819f572f00ffa GREEN
......
......@@ -21,15 +21,15 @@ import static org.eclipse.core.databinding.conversion.NumberToStringConverter.fr
import static org.eclipse.core.databinding.conversion.StringToNumberConverter.toBigDecimal;
import static org.eclipse.core.databinding.conversion.StringToNumberConverter.toDouble;
import static org.eclipse.core.databinding.conversion.StringToNumberConverter.toInteger;
import static org.fortiss.tooling.kernel.ui.databinding.FloatValidator.FLOAT_VALIDATOR;
import static org.fortiss.tooling.kernel.ui.databinding.IntValidator.INT_VALIDATOR;
import static org.fortiss.tooling.kernel.ui.databinding.NumberPositiveValidator.NUMBER_POSITIVE_VALIDATOR;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.DECORATION_KEY;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.performComplexTextBinding;
import static org.fortiss.tooling.kernel.ui.util.WidgetsFactory.createTextWithUndo;
import java.math.BigDecimal;
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.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.emf.common.notify.Notification;
......@@ -193,21 +193,39 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
protected abstract void setSectionInput(Object input);
/**
* Creates a text widget, which has a {@link ControlDecoration} attached.
* Creates a {@link Text} control which has a {@link ControlDecoration} attached.
* The decoration is stored as widget data for convenience.
*/
protected Text createDecoratedText(String labelText, int style) {
protected Text createDecoratedText(String value, int style) {
Text text = createTextWithUndo(getWidgetFactory(), composite, value, style);
text.setData(DECORATION_KEY, new ControlDecoration(text, SWT.LEFT | SWT.TOP));
return text;
}
/**
* Creates a {@link Text} control which has a {@link ControlDecoration} attached.
* The decoration is stored as widget data for convenience.
*/
protected Text createDecoratedText(String value) {
return createDecoratedText(value, SWT.NONE);
}
/**
* Creates a form text field, which has a {@link ControlDecoration} attached.
* The decoration is stored as widget data for convenience.
*/
protected Text createDecoratedFormText(String labelText, int style) {
Text text = createFormText(labelText, style);
text.setData(DECORATION_KEY, new ControlDecoration(text, SWT.LEFT | SWT.TOP));
return text;
}
/**
* Creates a text widget, which has a {@link ControlDecoration} attached.
* Creates a form text field, which has a {@link ControlDecoration} attached.
* The decoration is stored as widget data for convenience.
*/
protected Text createDecoratedText(String labelText) {
return createDecoratedText(labelText, SWT.NONE);
protected Text createDecoratedFormText(String labelText) {
return createDecoratedFormText(labelText, SWT.NONE);
}
/** Creates form text field. */
......@@ -294,13 +312,8 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
return button;
}
/** Creates a form entry. */
/** Creates a form entry and returns the {@link Label}. */
protected Label createFormEntry(Control control, String labelName) {
return createFormEntryAndReturnLabel(control, labelName);
}
/** Creates a form entry and return the label */
protected Label createFormEntryAndReturnLabel(Control control, String labelName) {
labelName = labelName.trim();
if(labelName.endsWith(":")) {
labelName = labelName.replaceAll(":$", "");
......@@ -335,7 +348,7 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
* fraction digits to be used in the String representation.
*/
protected void bindPositiveBigDecimalValue(Control text, IObservableValue<?> observedValue) {
bindBigDecimalValue(text, observedValue, NumberPositiveValidator.INSTANCE);
bindBigDecimalValue(text, observedValue, NUMBER_POSITIVE_VALIDATOR);
}
/**
......@@ -344,8 +357,19 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
*/
protected void bindPositiveBigDecimalValue(Control text, IObservableValue<?> observedValue,
int maxFractionDigits) {
bindBigDecimalValue(text, observedValue, NumberPositiveValidator.INSTANCE,
maxFractionDigits);
bindBigDecimalValue(text, observedValue, NUMBER_POSITIVE_VALIDATOR, maxFractionDigits);
}
/**
* Binds a {@link BigDecimal} value with the default number of a maximum of three fraction
* digits to be used in the String representation.
*/
private void bindBigDecimalValue(Control text, IObservableValue<?> observedValue,
IValidator numberValidator, NumberFormat nf) {
nf.setGroupingUsed(false);
performComplexTextBinding(dbc, text, observedValue, fromBigDecimal(nf), toBigDecimal(nf),
FLOAT_VALIDATOR, numberValidator);
}
/**
......@@ -354,10 +378,9 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
*/
protected void bindBigDecimalValue(Control text, IObservableValue<?> observedValue,
IValidator numberValidator) {
// TextToDoubleValidator checks format of fractional numbers and is hence also suitable for
// BigDecimals
performComplexTextBinding(dbc, text, observedValue, fromBigDecimal(), toBigDecimal(),
TextToDoubleValidator.INSTANCE, numberValidator);
NumberFormat nf = NumberFormat.getNumberInstance();
bindBigDecimalValue(text, observedValue, numberValidator, nf);
}
/**
......@@ -369,10 +392,7 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(maxFractionDigits);
// TextToDoubleValidator checks format of fractional numbers and is hence also suitable for
// BigDecimals
performComplexTextBinding(dbc, text, observedValue, fromBigDecimal(nf), toBigDecimal(nf),
TextToDoubleValidator.INSTANCE, numberValidator);
bindBigDecimalValue(text, observedValue, numberValidator, nf);
}
/**
......@@ -380,7 +400,7 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
* to be used in the String representation.
*/
protected void bindPositiveDoubleValue(Control text, IObservableValue<?> observedValue) {
bindDoubleValue(text, observedValue, NumberPositiveValidator.INSTANCE);
bindDoubleValue(text, observedValue, NUMBER_POSITIVE_VALIDATOR);
}
/**
......@@ -389,7 +409,7 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
*/
protected void bindPositiveDoubleValue(Control text, IObservableValue<?> observedValue,
int maxFractionDigits) {
bindDoubleValue(text, observedValue, NumberPositiveValidator.INSTANCE, maxFractionDigits);
bindDoubleValue(text, observedValue, NUMBER_POSITIVE_VALIDATOR, maxFractionDigits);
}
/**
......@@ -399,7 +419,7 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
protected void bindDoubleValue(Control text, IObservableValue<?> observedValue,
IValidator numberValidator) {
performComplexTextBinding(dbc, text, observedValue, fromDouble(false), toDouble(false),
TextToDoubleValidator.INSTANCE, numberValidator);
FLOAT_VALIDATOR, numberValidator);
}
/**
......@@ -412,18 +432,18 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(maxFractionDigits);
performComplexTextBinding(dbc, text, observedValue, fromDouble(nf, false),
toDouble(nf, false), TextToDoubleValidator.INSTANCE, numberValidator);
toDouble(nf, false), FLOAT_VALIDATOR, numberValidator);
}
/** Binds a positive integer value. */
protected void bindPositiveIntegerValue(Control text, IObservableValue<?> observedValue) {
bindIntegerValue(text, observedValue, NumberPositiveValidator.INSTANCE);
bindIntegerValue(text, observedValue, NUMBER_POSITIVE_VALIDATOR);
}
/** Binds a integer value. */
protected void bindIntegerValue(Control text, IObservableValue<?> observedValue,
IValidator numberValidator) {
performComplexTextBinding(dbc, text, observedValue, fromInteger(false), toInteger(false),
TextToIntegerValidator.INSTANCE, numberValidator);
INT_VALIDATOR, 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