comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodplainChoice.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodplainChoice.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.artifacts.states;
2
3 import org.w3c.dom.Element;
4
5 import org.apache.log4j.Logger;
6
7 import org.dive4elements.artifacts.Artifact;
8 import org.dive4elements.artifacts.CallContext;
9 import org.dive4elements.artifacts.CallMeta;
10
11 import org.dive4elements.artifacts.common.utils.XMLUtils;
12
13 import org.dive4elements.artifactdatabase.ProtocolUtils;
14
15 import org.dive4elements.river.artifacts.resources.Resources;
16
17
18 /**
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
20 */
21 public class FloodplainChoice extends DefaultState {
22
23 public static final String OPTION = "floodplain.option";
24 public static final String ACTIVE = "floodplain.active";
25 public static final String INACTIVE = "floodplain.inactive";
26
27 private static final Logger logger =
28 Logger.getLogger(FloodplainChoice.class);
29
30
31 @Override
32 protected String getUIProvider() {
33 return "boolean_panel";
34 }
35
36
37 @Override
38 protected Element[] createItems(
39 XMLUtils.ElementCreator cr,
40 Artifact artifact,
41 String name,
42 CallContext context)
43 {
44 CallMeta meta = context.getMeta();
45
46 Element option = createItem(
47 cr,
48 new String[] { Resources.getMsg(meta, OPTION, OPTION), "true" });
49
50 return new Element[] { option };
51 }
52
53
54 @Override
55 protected String getLabelFor(
56 CallContext cc,
57 String name,
58 String value,
59 String type
60 ) {
61 logger.debug("GET LABEL FOR '" + name + "' / '" + value + "'");
62 if (value != null && value.equals("true")) {
63 return Resources.getMsg(cc.getMeta(), ACTIVE, ACTIVE);
64 }
65 else {
66 return Resources.getMsg(cc.getMeta(), INACTIVE, INACTIVE);
67 }
68 }
69
70
71 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
72 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
73 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
74 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
75
76 String[] arr = (String[]) obj;
77
78 label.setTextContent(arr[0]);
79 value.setTextContent(arr[1]);
80
81 item.appendChild(label);
82 item.appendChild(value);
83
84 return item;
85 }
86 }
87 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org