Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/utils/DoubleValidator.java @ 2548:ada02bbd3b7f
Merged revisions 4541,4544 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-client/trunk
........
r4541 | ingo | 2012-05-28 18:25:36 +0200 (Mo, 28 Mai 2012) | 1 line
Added i18n string for floodmap datacage.
........
r4544 | teichmann | 2012-05-28 20:49:35 +0200 (Mo, 28 Mai 2012) | 1 line
Added i18n strings used by Delta W/t export of the fixing analysis.
........
flys-client/tags/2.7@4548 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 29 May 2012 05:08:18 +0000 |
parents | 4f4d29404dba |
children | 0ef4753e5515 |
rev | line source |
---|---|
1504
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.utils; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.Map; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
5 import com.google.gwt.core.client.GWT; |
1504
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.i18n.client.NumberFormat; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import com.smartgwt.client.widgets.form.fields.FormItem; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
10 import de.intevation.flys.client.client.FLYSConstants; |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
11 |
1504
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 /** |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 */ |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
15 public class DoubleValidator implements Validator { |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
16 |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
17 /** The interface that provides i18n messages. */ |
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
18 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
1504
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 /** |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 * |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 */ |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
23 public boolean validate(FormItem item, Map errors) { |
1504
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 boolean valid = true; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 |
1536
4f4d29404dba
Filter the helper input tables using the range filter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1507
diff
changeset
|
26 if(item.getValue() == null) { |
4f4d29404dba
Filter the helper input tables using the range filter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1507
diff
changeset
|
27 return false; |
4f4d29404dba
Filter the helper input tables using the range filter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1507
diff
changeset
|
28 } |
1507
c21d14e48040
Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1506
diff
changeset
|
29 String v = item.getValue().toString(); |
1504
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 NumberFormat f = NumberFormat.getDecimalFormat(); |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 try { |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 if (v == null) { |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 throw new NumberFormatException("empty"); |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 } |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 double value = f.parse(v); |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 errors.remove(item.getFieldName()); |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 } |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 catch (NumberFormatException nfe) { |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 errors.put(item.getFieldName(), MSG.wrongFormat()); |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 item.focusInItem(); |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 valid = false; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 } |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 return valid; |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 } |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 } |
02a9104c0451
Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |