- quick-fix to avoid NumberFormatException (#3743)
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 5 Nov 2013 13:19:39 +0000 (13:19 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 5 Nov 2013 13:19:39 +0000 (13:19 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/MinMaxTextSection.java

index 94b1a8f98277a91a7fb8850d7e7dcbfddbdb6615..1012b95bc8229df9be8c35036441f03d20858d9d 100644 (file)
@@ -1,9 +1,9 @@
 // $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.
  */
@@ -18,7 +18,7 @@ import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
  * <p>
  * MinMaxTextSection class.
  * </p>
- * 
+ *
  * @author c.mathew
  * @created 23 Jul 2013
  * @version 1.0
@@ -29,7 +29,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
        private final NumberWithLabelElement text_minVal;
        private final NumberWithLabelElement text_maxVal;
        private int cursorPosition;
-       
+
        // unit types handled by this section
        public enum UnitType {
                ELEVATION,
@@ -43,7 +43,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
         * <p>
         * Constructor for DateDetailSection.
         * </p>
-        * 
+        *
         * @param formFactory
         *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
         *            object.
@@ -61,10 +61,10 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
 
                text_minVal = formFactory.createNumberTextWithLabelElement(this,
                                "Min : ", getMinimum(), style);
-               
+
                text_maxVal = formFactory.createNumberTextWithLabelElement(this,
                                "Max : ", getMaximum(), style);
-       
+
                text_freeText = formFactory.createTextWithLabelElement(this,
                                "Freetext : ", getFreetext(), style);
 
@@ -75,7 +75,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
         * <p>
         * Setter for the field <code>timePeriod</code>.
         * </p>
-        * 
+        *
         * @param timePeriod
         *            a {@link eu.etaxonomy.cdm.model.common.TimePeriod} object.
         */
@@ -109,7 +109,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
                                if(getEntity().getDistanceToGroundText() != null) {
                                        text_freeText.setText(getEntity().getDistanceToGroundText());
                                }
-                               break;                  
+                               break;
                        case DIST_TO_WATER:
                                if(getEntity().getDistanceToWaterSurface() != null) {
                                        text_minVal.setNumber(getEntity().getDistanceToWaterSurface());
@@ -120,7 +120,7 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
                                if(getEntity().getDistanceToWaterSurfaceText() != null) {
                                        text_freeText.setText(getEntity().getDistanceToWaterSurfaceText());
                                }
-                               break;          
+                               break;
                        default:
                                break;
                        }
@@ -155,21 +155,21 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
        }
 
        private void handleEvent(Object eventSource) {
-               if (eventSource == text_minVal) {                       
+               if (eventSource == text_minVal) {
                        updateMinimum();
                } else if (eventSource == text_maxVal) {
                        updateMaximum();
                } else if (eventSource == text_freeText) {
-                       updateFreetext();               
-               } 
+                       updateFreetext();
+               }
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, null));
        }
 
 
-       
+
        /*
         * (non-Javadoc)
-        * 
+        *
         * @see eu.etaxonomy.taxeditor.forms.AbstractFormSection#dispose()
         */
        /** {@inheritDoc} */
@@ -178,65 +178,65 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
                formFactory.removePropertyChangeListener(this);
                super.dispose();
        }
-       
+
        private void updateMinimum() {
                switch(unitType) {
                case ELEVATION:
-                       getEntity().setAbsoluteElevation(text_minVal.getInteger());
+                       getEntity().setAbsoluteElevation(text_minVal.getDouble().intValue());
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGround(text_minVal.getDouble());
-                       break;                  
+                       break;
                case DIST_TO_WATER:
                        getEntity().setDistanceToWaterSurface(text_minVal.getDouble());
-                       break;                          
+                       break;
                }
        }
-       
+
        private Number getMinimum() {
                if(getEntity() == null) {
                        return null;
                }
                switch(unitType) {
                case ELEVATION:
-                       return getEntity().getAbsoluteElevation();                      
+                       return getEntity().getAbsoluteElevation();
                case DIST_TO_GROUND:
-                       return getEntity().getDistanceToGround();                       
+                       return getEntity().getDistanceToGround();
                case DIST_TO_WATER:
-                       return getEntity().getDistanceToWaterSurface();                                 
+                       return getEntity().getDistanceToWaterSurface();
                }
                return null;
        }
-       
+
        private void updateMaximum() {
                switch(unitType) {
                case ELEVATION:
-                       getEntity().setAbsoluteElevationMax(text_maxVal.getInteger());
+                       getEntity().setAbsoluteElevationMax(text_maxVal.getDouble().intValue());
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGroundMax(text_maxVal.getDouble());
-                       break;                  
+                       break;
                case DIST_TO_WATER:
                        getEntity().setDistanceToWaterSurfaceMax(text_maxVal.getDouble());
-                       break;                          
+                       break;
                }
        }
-       
+
        private Number getMaximum() {
                if(getEntity() == null) {
                        return null;
                }
                switch(unitType) {
                case ELEVATION:
-                       return getEntity().getAbsoluteElevationMaximum();                       
+                       return getEntity().getAbsoluteElevationMaximum();
                case DIST_TO_GROUND:
-                       return getEntity().getDistanceToGroundMax();                    
+                       return getEntity().getDistanceToGroundMax();
                case DIST_TO_WATER:
-                       return getEntity().getDistanceToWaterSurfaceMax();                                      
+                       return getEntity().getDistanceToWaterSurfaceMax();
                }
                return null;
        }
-       
+
        private void updateFreetext() {
                switch(unitType) {
                case ELEVATION:
@@ -244,24 +244,24 @@ public class MinMaxTextSection extends AbstractFormSection<DerivedUnitFacade> {
                        break;
                case DIST_TO_GROUND:
                        getEntity().setDistanceToGroundText(text_freeText.getText());
-                       break;                  
+                       break;
                case DIST_TO_WATER:
                        getEntity().setDistanceToWaterSurfaceText(text_freeText.getText());
-                       break;                          
+                       break;
                }
-       }       
-       
+       }
+
        private String getFreetext() {
                if(getEntity() == null) {
                        return null;
                }
                switch(unitType) {
                case ELEVATION:
-                       return getEntity().getAbsoluteElevationText();                  
+                       return getEntity().getAbsoluteElevationText();
                case DIST_TO_GROUND:
-                       return getEntity().getDistanceToGroundText();                   
+                       return getEntity().getDistanceToGroundText();
                case DIST_TO_WATER:
-                       return getEntity().getDistanceToWaterSurfaceText();                                     
+                       return getEntity().getDistanceToWaterSurfaceText();
                }
                return null;
        }