Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/EnterMultipleLocationsState.java @ 3728:d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
flys-artifacts/trunk@5401 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 08 Sep 2012 13:36:06 +0000 |
parents | 1cfe788325d5 |
children | 8e66293c5369 |
rev | line source |
---|---|
2306
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
3721
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
3 import org.apache.log4j.Logger; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
4 import org.w3c.dom.Element; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
5 |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
6 import de.intevation.artifacts.Artifact; |
2312
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
8 import de.intevation.artifacts.common.utils.StringUtils; |
3721
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
9 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
10 import de.intevation.flys.artifacts.WINFOArtifact; |
2312
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
11 |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
12 |
2306
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 /** |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 * Get me doubles (km). |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 */ |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 public class EnterMultipleLocationsState extends EnterLocationState { |
3721
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
17 /** The logger for this class. */ |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
18 private static Logger logger = Logger.getLogger(EnterMultipleLocationsState.class); |
2306
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 @Override |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 protected String getUIProvider() { |
3721
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
22 logger.debug("multi location panel"); |
2306
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 return "multi_location_panel"; |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 } |
2312
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
25 |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2314
diff
changeset
|
26 |
2312
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
27 /** Deal with multiple double values. */ |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
28 @Override |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
29 protected String getLabelFor( |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
30 CallContext cc, |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
31 String name, |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
32 String value, |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
33 String type |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
34 ) { |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
35 String label = ""; |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
36 String[] vals = value.split(" "); |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
37 for (int i = 0; i < vals.length; i++) { |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
38 vals[i] = super.getLabelFor(cc, name, vals[i], type); |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
39 } |
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
40 |
2314
f4ca234ba214
Fix call to StringUtils.join .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2312
diff
changeset
|
41 return StringUtils.join(" ", vals); |
2312
f911ddd93f58
Format multiple double values with a locale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2306
diff
changeset
|
42 } |
3721
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
43 |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
44 /** |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
45 * This method creates a list of items. These items represent the amount of |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
46 * input data that is possible for this state. |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
47 * |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
48 * @param cr The ElementCreator. |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
49 * @param name The name of the amount of data. |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
50 * |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
51 * @return a list of items. |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
52 */ |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
53 @Override |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
54 protected Element[] createItems( |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
55 ElementCreator cr, |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
56 Artifact artifact, |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
57 String name, |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
58 CallContext context |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
59 ) { |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
60 if (name.equals("reference_endpoint")) { |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
61 Element[] elements = new Element[1]; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
62 WINFOArtifact winfo = (WINFOArtifact) artifact; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
63 Double km = winfo.getReferenceStartKm(); |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
64 elements[0] = createItem( |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
65 cr, |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
66 new String[] {"start_km", km.toString()}); |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
67 return elements; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
68 } |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
69 return null; |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
70 } |
1cfe788325d5
Issue 791.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
71 |
2306
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 } |
cc6b8af44728
Prepare new data input for reference curves 'Ziel' locations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |