Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/states/HistoricalDischargeState.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeState.java@05eeedc5b156 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.states; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import org.w3c.dom.Element; | |
6 | |
7 import org.dive4elements.artifacts.Artifact; | |
8 import org.dive4elements.artifacts.ArtifactNamespaceContext; | |
9 import org.dive4elements.artifacts.CallContext; | |
10 import org.dive4elements.artifacts.CallMeta; | |
11 | |
12 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | |
13 | |
14 import org.dive4elements.river.artifacts.resources.Resources; | |
15 | |
16 | |
17 /** | |
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
19 */ | |
20 public class HistoricalDischargeState extends DefaultState { | |
21 | |
22 private static final Logger logger = | |
23 Logger.getLogger(HistoricalDischargeState.class); | |
24 | |
25 public static final String I18N_MODE_W = "historical.mode.w"; | |
26 public static final String I18N_MODE_Q = "historical.mode.q"; | |
27 | |
28 public static final String DATA_MODE = "historical_mode"; | |
29 public static final String DATA_VALUES = "historical_values"; | |
30 public static final int DATA_MODE_W = 0; | |
31 public static final int DATA_MODE_Q = 1; | |
32 | |
33 | |
34 @Override | |
35 protected String getUIProvider() { | |
36 return "wq_simple_array"; | |
37 } | |
38 | |
39 @Override | |
40 protected void appendItems( | |
41 Artifact artifact, | |
42 ElementCreator creator, | |
43 String name, | |
44 CallContext context, | |
45 Element select | |
46 ) { | |
47 if (name != null && name.equals(DATA_VALUES)) { | |
48 select.setAttributeNS( | |
49 ArtifactNamespaceContext.NAMESPACE_URI, | |
50 "art:type", | |
51 "doublearray"); | |
52 } | |
53 else if (name != null && name.equals(DATA_MODE)) { | |
54 select.setAttributeNS( | |
55 ArtifactNamespaceContext.NAMESPACE_URI, | |
56 "art:type", | |
57 "intoptions"); | |
58 } | |
59 | |
60 super.appendItems(artifact, creator, name, context, select); | |
61 } | |
62 | |
63 | |
64 @Override | |
65 protected Element[] createItems( | |
66 ElementCreator creator, | |
67 Artifact artifact, | |
68 String name, | |
69 CallContext context | |
70 ) { | |
71 logger.debug("createItems()"); | |
72 | |
73 if (name != null && name.equals(DATA_MODE)) { | |
74 return createModeItem(creator, artifact, name, context); | |
75 } | |
76 else if (name != null && name.equals(DATA_VALUES)) { | |
77 return createValuesItem(creator, artifact, name, context); | |
78 } | |
79 | |
80 logger.warn("Tried to create item for invalid data: " + name); | |
81 | |
82 return new Element[0]; | |
83 } | |
84 | |
85 | |
86 /** Get label for display in client, depending on chosen W or Q input. */ | |
87 @Override | |
88 protected String getLabelFor( | |
89 CallContext cc, | |
90 String name, | |
91 String value, | |
92 String type | |
93 ) { | |
94 CallMeta meta = cc.getMeta(); | |
95 | |
96 if (name.equals(DATA_MODE)) { | |
97 if (value.equals(String.valueOf(DATA_MODE_W))) { | |
98 return Resources.getMsg(meta, I18N_MODE_W, I18N_MODE_W); | |
99 } | |
100 else { | |
101 return Resources.getMsg(meta, I18N_MODE_Q, I18N_MODE_Q); | |
102 } | |
103 } | |
104 else { | |
105 return value; | |
106 } | |
107 } | |
108 | |
109 | |
110 protected Element[] createModeItem( | |
111 ElementCreator creator, | |
112 Artifact artifact, | |
113 String name, | |
114 CallContext context | |
115 ) { | |
116 logger.debug("createModeItem()"); | |
117 | |
118 CallMeta meta = context.getMeta(); | |
119 | |
120 Element modeW = createItem( | |
121 creator, | |
122 new String[] { | |
123 Resources.getMsg(meta, I18N_MODE_W, I18N_MODE_W), | |
124 String.valueOf(DATA_MODE_W) } ); | |
125 | |
126 Element modeQ = createItem( | |
127 creator, | |
128 new String[] { | |
129 Resources.getMsg(meta, I18N_MODE_Q, I18N_MODE_Q), | |
130 String.valueOf(DATA_MODE_Q) } ); | |
131 | |
132 return new Element[] { modeW, modeQ }; | |
133 } | |
134 | |
135 | |
136 protected Element[] createValuesItem( | |
137 ElementCreator creator, | |
138 Artifact artifact, | |
139 String name, | |
140 CallContext context | |
141 ) { | |
142 logger.debug("createValuesItem()"); | |
143 | |
144 Element valuesW = createItem( | |
145 creator, new String[] { "ws", "" } ); | |
146 | |
147 Element valuesQ = createItem( | |
148 creator, new String[] { "qs", "" } ); | |
149 | |
150 return new Element[] { valuesW, valuesQ }; | |
151 } | |
152 } | |
153 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |