comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodplainChoice.java @ 3468:f37e7e8907cb

merged flys-artifacts/2.8.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:39 +0200
parents 2867ae59e216
children
comparison
equal deleted inserted replaced
3387:5ffad8bde8ad 3468:f37e7e8907cb
1 package de.intevation.flys.artifacts.states;
2
3 import org.w3c.dom.Element;
4
5 import org.apache.log4j.Logger;
6
7 import de.intevation.artifacts.Artifact;
8 import de.intevation.artifacts.CallContext;
9 import de.intevation.artifacts.CallMeta;
10
11 import de.intevation.artifacts.common.utils.XMLUtils;
12
13 import de.intevation.artifactdatabase.ProtocolUtils;
14
15 import de.intevation.flys.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