}
/**
- * <p>getInteger</p>
- *
- * @return a {@link java.lang.Integer} object.
+ * Get the value of this field as an {@link Integer}.
+ * @return the Integer value or null if {@link NumberFormatException} occurs.
*/
public Integer getInteger() {
String text = super.getText().trim();
- return text.equals("") ? 0 : new Integer(text);
+ try {
+ return text.equals("") ? 0 : new Integer(text);
+ } catch (NumberFormatException e) {
+ exception = e;
+ }
+ return null;
}
/**
- * <p>getFloat</p>
- *
- * @return a {@link java.lang.Float} object.
+ * Get the value of this field as a {@link Float}.
+ * @return the Float value or null if {@link NumberFormatException} occurs.
*/
public Float getFloat(){
- String text = super.getText();
- return new Float(text);
+ String text = super.getText();
+ try {
+ return new Float(text);
+ } catch (NumberFormatException e) {
+ exception = e;
+ }
+ return null;
}
/**
- * <p>getDouble</p>
- *
- * @return a {@link java.lang.Float} object.
+ * Get the value of this field as an {@link Double}.
+ * @return the Double value or null if {@link NumberFormatException} occurs.
*/
public Double getDouble(){
- String text = super.getText();
- return new Double(text);
+ String text = super.getText();
+ try {
+ return new Double(text);
+ } catch (NumberFormatException e) {
+ exception = e;
+ }
+ return null;
}
-
+
private String getStringRepresentation(Object number){
if(number != null){
return number.toString();
try{
- Float number = Float.parseFloat(value);
+ 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.");
+ exception = new NumberFormatException("You entered a number that is not within the allowed bounds.");
+ throw exception;
}
}catch(NumberFormatException e){
text.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
- firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
+ firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
exception = e;
return;
}