Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HWSDatacageState.java @ 5704:c13cbdd010ed
Used replacement ${help.url} in i18n- properties.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 12:42:02 +0200 |
parents | 11c853b0854a |
children |
rev | line source |
---|---|
5310
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 import org.w3c.dom.Element; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.Artifact; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.artifacts.FLYSArtifact; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 public class HWSDatacageState |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 extends DefaultState |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 private static final Logger logger = Logger.getLogger(HWSDatacageState.class); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 @Override |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 protected String getUIProvider() { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 return "hws_datacage_panel"; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 @Override |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 protected Element createStaticData( |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 FLYSArtifact flys, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 ElementCreator creator, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 CallContext cc, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 String name, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 String value, |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 String type |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 ) { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 Element dataElement = creator.create("data"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 creator.addAttr(dataElement, "name", name, true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 creator.addAttr(dataElement, "type", type, true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 Element itemElement = creator.create("item"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 creator.addAttr(itemElement, "value", value, true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 creator.addAttr(itemElement, "label", getLabel(cc, value), true); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 dataElement.appendChild(itemElement); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 return dataElement; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 public static String getLabel(CallContext cc, String value) { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 logger.debug("Create label for value: " + value); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 return value; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 @Override |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 public boolean validate(Artifact artifact) |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 throws IllegalArgumentException |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 FLYSArtifact flys = (FLYSArtifact) artifact; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 String hws = flys.getDataAsString("uesk.hws"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 logger.debug("hws: " + hws); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 return true; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 /** |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 * Returns the DGM specified in the parameters of <i>flys</i>. |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 * |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 * @param flys The FLYSArtifact that knows the ID of a DGM. |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 * |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 * @throws IllegalArgumentException If the FLYSArtifact doesn't know the ID |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 * of a DGM. |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 * |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 * @return the DGM specified by FLYSArtifact's parameters. |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 */ |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 public static String getHWS(FLYSArtifact flys) |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 throws IllegalArgumentException |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 String hws= flys.getDataAsString("uesk.hws"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 if (hws == null) { |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 return null; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 logger.debug("Found selected hws: '" + hws + "'"); |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 return hws; |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 } |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 |
11c853b0854a
Added new states for HWS, user shapefile and barriers.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 } |