sParamName = name;
inputField = new Text(composite, SWT.BORDER);
float value = COConfigurationManager.getFloatParameter(name);
inputField.setText(String.valueOf(value));
inputField.addListener(SWT.Verify, new Listener() {
public void handleEvent(Event e) {
String text = e.text;
char[] chars = new char[text.length()];
text.getChars(0, chars.length, chars, 0);
for (int i = 0; i < chars.length; i++) {
if ( !((chars[i] >= '0' && chars[i] <= '9') || chars[i] == '.') ) {
e.doit = false;
return;
}
}
}
});
inputField.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
try {
float val = Float.parseFloat(inputField.getText());
if (val < fMinValue) {
if (!(allowZero && val == 0)) {
val = fMinValue;
}
}
if (val > fMaxValue) {
if (fMaxValue > -1) {
val = fMaxValue;
}
}
COConfigurationManager.setParameter(name, val);
}
catch (Exception e) {}
}
});
inputField.addListener(SWT.FocusOut, new Listener() {
public void handleEvent(Event event) {
try {
float val = Float.parseFloat(inputField.getText());
if (val < fMinValue) {
if (!(allowZero && val == 0)) {