diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java @ 7748:316a9eeb0836

Hopefully a cleaner fix for flys/issue1549 using the FloatRangeValidator from SmartGWT to verify that the 'to' field stays positive.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 21 Feb 2014 15:28:08 +0100
parents 91a57b66c7ed
children afa0ffc3a708
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java	Tue Feb 11 16:18:57 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java	Fri Feb 21 15:28:08 2014 +0100
@@ -8,7 +8,7 @@
 
 package org.dive4elements.river.client.client.ui;
 
-import java.util.List;
+import com.smartgwt.client.widgets.form.validator.FloatRangeValidator;
 
 public class WaterlevelGroundPanel extends DistancePanel {
 
@@ -21,6 +21,11 @@
 
     public WaterlevelGroundPanel() {
         super("left");
+
+        FloatRangeValidator frv = new FloatRangeValidator();
+        frv.setMin(0f);
+        frv.setMax(Float.MAX_VALUE);
+        distancePanel.getToItem().setValidators(frv);
     }
 
 
@@ -125,16 +130,5 @@
         // We don't need a helper panel here. But we have to override this
         // method to avoid the table creation in the parent class.
     }
-
-    @Override
-    protected void validateTo(List<String> errors) {
-        double to = distancePanel.getTo();
-
-        if (to < 0d) {
-            distancePanel.setTo(max);
-            errors.add(MSG.negative_values_not_allowed_for_to());
-        }
-        super.validateTo(errors);
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org