ASM #638 - Inconsistent Type for scale widget value accessed through the varDict.
Change-Id: If81102e5a3b70e224f88a351277e9c29e9f9cc91 Former-commit-id: 3c1ce33424799b39db14f909d8de2946e5aca1bc
This commit is contained in:
parent
cfe7f318d8
commit
94f06ccbc9
2 changed files with 30 additions and 3 deletions
|
@ -40,6 +40,8 @@ import org.eclipse.swt.widgets.Scale;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jun 4, 2008 1164 jelkins Initial creation
|
* 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.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -65,6 +67,8 @@ public class ScaleWidget extends Widget {
|
||||||
|
|
||||||
private DecimalFormat format;
|
private DecimalFormat format;
|
||||||
|
|
||||||
|
private boolean isFloat = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor specifying this scale's label.
|
* Class constructor specifying this scale's label.
|
||||||
*
|
*
|
||||||
|
@ -126,7 +130,12 @@ public class ScaleWidget extends Widget {
|
||||||
scale.setPageIncrement(1);
|
scale.setPageIncrement(1);
|
||||||
|
|
||||||
if (getValue() == null) {
|
if (getValue() == null) {
|
||||||
setValue(new Float(minValue));
|
if (isFloat()) {
|
||||||
|
setValue(new Float(minValue));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setValue(new Integer((int)minValue));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setInitialScaleValue(((Number) (getValue())).floatValue());
|
setInitialScaleValue(((Number) (getValue())).floatValue());
|
||||||
|
@ -140,7 +149,12 @@ public class ScaleWidget extends Widget {
|
||||||
float value = getScaleValue();
|
float value = getScaleValue();
|
||||||
|
|
||||||
label.setText(format.format(value));
|
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;
|
this.precision = precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFloat() {
|
||||||
|
return isFloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFloat(boolean isFloat) {
|
||||||
|
this.isFloat = isFloat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition.FieldType;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 30, 2012 randerso Initial creation
|
* May 30, 2012 randerso Initial creation
|
||||||
* May 12, 2014 16167 ryu Fix sizing and accessibility of content.
|
* May 12, 2014 16167 ryu Fix sizing and accessibility of content.
|
||||||
|
* Dec 11, 2014 638 mgamazaychikov Set isFloat in makeScale.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -403,9 +404,14 @@ public class DialogAreaComposite extends ScrolledComposite {
|
||||||
|
|
||||||
ScaleWidget scale = new ScaleWidget(labelText);
|
ScaleWidget scale = new ScaleWidget(labelText);
|
||||||
scale.setOptions(valueList);
|
scale.setOptions(valueList);
|
||||||
scale.setValue(initialValue);
|
|
||||||
scale.setResolution(res);
|
scale.setResolution(res);
|
||||||
scale.setPrecision(precision);
|
scale.setPrecision(precision);
|
||||||
|
if (initialValue instanceof Float ){
|
||||||
|
scale.setFloat(true);
|
||||||
|
} else {
|
||||||
|
scale.setFloat(false);
|
||||||
|
}
|
||||||
|
scale.setValue(initialValue);
|
||||||
|
|
||||||
scale.buildComposite(this.topFrame);
|
scale.buildComposite(this.topFrame);
|
||||||
return scale;
|
return scale;
|
||||||
|
|
Loading…
Add table
Reference in a new issue