Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
7747:cfa7e2164f87 | 7748:316a9eeb0836 |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.client.ui; | 9 package org.dive4elements.river.client.client.ui; |
10 | 10 |
11 import java.util.List; | 11 import com.smartgwt.client.widgets.form.validator.FloatRangeValidator; |
12 | 12 |
13 public class WaterlevelGroundPanel extends DistancePanel { | 13 public class WaterlevelGroundPanel extends DistancePanel { |
14 | 14 |
15 private static final long serialVersionUID = 6598703468619862469L; | 15 private static final long serialVersionUID = 6598703468619862469L; |
16 | 16 |
19 public static final String FIELD_STEP = "diff_diff"; | 19 public static final String FIELD_STEP = "diff_diff"; |
20 | 20 |
21 | 21 |
22 public WaterlevelGroundPanel() { | 22 public WaterlevelGroundPanel() { |
23 super("left"); | 23 super("left"); |
24 | |
25 FloatRangeValidator frv = new FloatRangeValidator(); | |
26 frv.setMin(0f); | |
27 frv.setMax(Float.MAX_VALUE); | |
28 distancePanel.getToItem().setValidators(frv); | |
24 } | 29 } |
25 | 30 |
26 | 31 |
27 @Override | 32 @Override |
28 protected String getLowerField() { | 33 protected String getLowerField() { |
123 @Override | 128 @Override |
124 protected void initHelperPanel() { | 129 protected void initHelperPanel() { |
125 // We don't need a helper panel here. But we have to override this | 130 // We don't need a helper panel here. But we have to override this |
126 // method to avoid the table creation in the parent class. | 131 // method to avoid the table creation in the parent class. |
127 } | 132 } |
128 | |
129 @Override | |
130 protected void validateTo(List<String> errors) { | |
131 double to = distancePanel.getTo(); | |
132 | |
133 if (to < 0d) { | |
134 distancePanel.setTo(max); | |
135 errors.add(MSG.negative_values_not_allowed_for_to()); | |
136 } | |
137 super.validateTo(errors); | |
138 } | |
139 } | 133 } |
140 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 134 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |