From 94f06ccbc9102e6dc99831c5471e62b78d06e093 Mon Sep 17 00:00:00 2001 From: Michael Gamazaychikov Date: Thu, 11 Dec 2014 19:36:16 -0500 Subject: [PATCH] ASM #638 - Inconsistent Type for scale widget value accessed through the varDict. Change-Id: If81102e5a3b70e224f88a351277e9c29e9f9cc91 Former-commit-id: 3c1ce33424799b39db14f909d8de2946e5aca1bc --- .../viz/python/swt/widgets/ScaleWidget.java | 25 +++++++++++++++++-- .../gfe/ui/runtimeui/DialogAreaComposite.java | 8 +++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/widgets/ScaleWidget.java b/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/widgets/ScaleWidget.java index de66217ee4..e5daa6978a 100644 --- a/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/widgets/ScaleWidget.java +++ b/cave/com.raytheon.uf.viz.python.swt/src/com/raytheon/uf/viz/python/swt/widgets/ScaleWidget.java @@ -40,6 +40,8 @@ import org.eclipse.swt.widgets.Scale; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jun 4, 2008 1164 jelkins Initial creation + * Dec 11, 2014 638 mgamazaychikov Add isFloat to explicitly specify the type of return value + * be either Float or Integer. * * * @@ -65,6 +67,8 @@ public class ScaleWidget extends Widget { private DecimalFormat format; + private boolean isFloat = false; + /** * Class constructor specifying this scale's label. * @@ -126,7 +130,12 @@ public class ScaleWidget extends Widget { scale.setPageIncrement(1); if (getValue() == null) { - setValue(new Float(minValue)); + if (isFloat()) { + setValue(new Float(minValue)); + } + else { + setValue(new Integer((int)minValue)); + } } setInitialScaleValue(((Number) (getValue())).floatValue()); @@ -140,7 +149,12 @@ public class ScaleWidget extends Widget { float value = getScaleValue(); label.setText(format.format(value)); - setValue(new Float(value)); + if (isFloat()) { + setValue(new Float(value)); + } + else { + setValue(new Integer((int)value)); + } } }); @@ -241,4 +255,11 @@ public class ScaleWidget extends Widget { this.precision = precision; } + public boolean isFloat() { + return isFloat; + } + + public void setFloat(boolean isFloat) { + this.isFloat = isFloat; + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/DialogAreaComposite.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/DialogAreaComposite.java index 516fcd7e3c..c740b27d8d 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/DialogAreaComposite.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ui/runtimeui/DialogAreaComposite.java @@ -61,6 +61,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition.FieldType; * ------------ ---------- ----------- -------------------------- * May 30, 2012 randerso Initial creation * May 12, 2014 16167 ryu Fix sizing and accessibility of content. + * Dec 11, 2014 638 mgamazaychikov Set isFloat in makeScale. * * * @@ -403,9 +404,14 @@ public class DialogAreaComposite extends ScrolledComposite { ScaleWidget scale = new ScaleWidget(labelText); scale.setOptions(valueList); - scale.setValue(initialValue); scale.setResolution(res); scale.setPrecision(precision); + if (initialValue instanceof Float ){ + scale.setFloat(true); + } else { + scale.setFloat(false); + } + scale.setValue(initialValue); scale.buildComposite(this.topFrame); return scale;