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

- bindDoubleValue() and bindPositiveDoubleValue() use the default of a maximum...

- bindDoubleValue() and bindPositiveDoubleValue() use the default of a maximum number of three fractional digits to be shown in a String representation of the value
- Hence, add variants of that function where a custom maximum number of fractional digits to be shown in a String representation of the value can be specified
parent bd77cbbe
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,8 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.service.ILibraryService;
import com.ibm.icu.text.NumberFormat;
/**
* Base class for property sections, dealing with setting the input and
* providing some utility methods.
......@@ -61,7 +63,7 @@ import org.fortiss.tooling.kernel.service.ILibraryService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 29023A6DC4CB0A681B7986E833D23B78
* @ConQAT.Rating YELLOW Hash: 8CE6478413817CEBD4797CF4258C1E3D
*/
public abstract class PropertySectionBase extends AbstractPropertySection {
......@@ -284,18 +286,46 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
dbc = new EMFDataBindingContext();
}
/** Binds a positive double value. */
/**
* Binds a positive double value with the default number of a maximum of three fraction digits
* to be used in the String representation.
*/
protected void bindPositiveDoubleValue(Control text, IObservableValue observedValue) {
bindDoubleValue(text, observedValue, NumberPositiveValidator.INSTANCE);
}
/** Binds a double value. */
/**
* Binds a positive double value with a user defined maximum number of fraction digits to be
* used in the String representation.
*/
protected void bindPositiveDoubleValue(Control text, IObservableValue observedValue,
int maxFractionDigits) {
bindDoubleValue(text, observedValue, NumberPositiveValidator.INSTANCE, maxFractionDigits);
}
/**
* Binds a double value with the default number of a maximum of three fraction digits
* to be used in the String representation.
*/
protected void bindDoubleValue(Control text, IObservableValue observedValue,
IValidator numberValidator) {
performComplexTextBinding(dbc, text, observedValue, fromDouble(false), toDouble(false),
TextToDoubleValidator.INSTANCE, numberValidator);
}
/**
* Binds a double value with a user defined maximum number of fraction digits to be
* used in the String representation.
*/
protected void bindDoubleValue(Control text, IObservableValue observedValue,
IValidator numberValidator, int maxFractionDigits) {
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(maxFractionDigits);
performComplexTextBinding(dbc, text, observedValue, fromDouble(nf, false),
toDouble(nf, false), TextToDoubleValidator.INSTANCE, numberValidator);
}
/** Binds a positive integer value. */
protected void bindPositiveIntegerValue(Control text, IObservableValue observedValue) {
bindIntegerValue(text, observedValue, NumberPositiveValidator.INSTANCE);
......
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