annotate flys-client/src/main/java/de/intevation/flys/client/client/utils/IntegerValidator.java @ 4269:0c766c475805

Add Panel and Tree UI classes for dispayling the measurement station info The new ui classes are using the new extracted base class InfoPanel and InfoTree which are in common with the gauge info.
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 26 Oct 2012 12:22:06 +0200
parents c21d14e48040
children
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: 1504
diff changeset
5 import com.google.gwt.core.client.GWT;
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
6
1504
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 import com.smartgwt.client.widgets.form.fields.FormItem;
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
1507
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
9 import de.intevation.flys.client.client.FLYSConstants;
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
10
1504
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 /**
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 * @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
13 */
1507
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
14 public class IntegerValidator implements Validator {
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
15
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
16 /** The interface that provides i18n messages. */
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
17 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
1504
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18
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 */
1507
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
22 public boolean validate(FormItem item, Map errors) {
1504
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 boolean valid = true;
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
1507
c21d14e48040 Improved validation and property handling.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1504
diff changeset
25 String v = item.getValue().toString();
1504
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 try {
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 if (v == null) {
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 throw new NumberFormatException("empty");
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
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 int value = Integer.parseInt(v);
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 errors.remove(item.getFieldName());
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 }
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 catch (NumberFormatException nfe) {
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 errors.put(item.getFieldName(), MSG.wrongFormat());
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 item.focusInItem();
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 valid = false;
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 }
02a9104c0451 Implemented the validators more object oriented.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 return valid;
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 }

http://dive4elements.wald.intevation.org