// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.eclipse.swt.widgets.Display;
import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
/**
private Float start;
private Float end;
-
+
private NumberFormatException exception;
/**
super(toolkit, parentElement, labelString, null, null, style);
setNumber(initialNumber);
}
-
-
+
+
/**
* <p>setNumber</p>
*
public void setNumber(Number number) {
super.setText(getStringRepresentation(number));
}
-
+
/**
* <p>getInteger</p>
*
String text = super.getText().trim();
return text.equals("") ? 0 : new Integer(text);
}
-
+
/**
* <p>getFloat</p>
*
String text = super.getText();
return new Float(text);
}
-
+
/**
* <p>getDouble</p>
*
private String getStringRepresentation(Object number){
if(number != null){
return number.toString();
- }
+ }
return null;
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
return;
}
-
+
try{
-
+
Float number = Float.parseFloat(value);
-
+
if((start != null && number < start) || (end != null && number > end)){
throw new NumberFormatException("You entered a number that is not within the allowed bounds.");
}
-
+
}catch(NumberFormatException e){
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
+ exception = e;
return;
}
-
+
exception = null;
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
-
+
super.modifyText(event);
}
-
+
/**
* <p>setLimits</p>
*
public void setLimits(int numberOfDigits, Integer start, Integer end){
setLimits(numberOfDigits, start.floatValue(), end.floatValue());
}
-
+
/**
* <p>setLimits</p>
*
this.start = start;
this.end = end;
}
-
+
/**
* <p>Getter for the field <code>exception</code>.</p>
*