comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodplainChoice.java @ 9277:2323d005f9a5

compile error fix
author gernotbelger
date Fri, 20 Jul 2018 10:39:02 +0200
parents 13650d8a2373
children
comparison
equal deleted inserted replaced
9276:3141f0e7314e 9277:2323d005f9a5
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.artifacts.states; 9 package org.dive4elements.river.artifacts.states;
10 10
11 import org.w3c.dom.Element;
12
13 import org.apache.log4j.Logger; 11 import org.apache.log4j.Logger;
14
15 import org.dive4elements.artifacts.Artifact; 12 import org.dive4elements.artifacts.Artifact;
16 import org.dive4elements.artifacts.CallContext; 13 import org.dive4elements.artifacts.CallContext;
17 import org.dive4elements.artifacts.CallMeta; 14 import org.dive4elements.artifacts.CallMeta;
18
19 import org.dive4elements.artifacts.common.utils.XMLUtils; 15 import org.dive4elements.artifacts.common.utils.XMLUtils;
20
21 import org.dive4elements.artifactdatabase.ProtocolUtils;
22
23 import org.dive4elements.river.artifacts.resources.Resources; 16 import org.dive4elements.river.artifacts.resources.Resources;
24 17 import org.w3c.dom.Element;
25 18
26 /** 19 /**
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
28 */ 21 */
29 // FIXME: inherit from BooleanChoiceState instead to remove duplicate code; BUT: this will probably break artifact serialization 22 // FIXME: inherit from BooleanChoiceState instead to remove duplicate code; BUT: this will probably break artifact
23 // serialization
30 public class FloodplainChoice extends DefaultState { 24 public class FloodplainChoice extends DefaultState {
31 25
32 public static final String OPTION = "floodplain.option"; 26 public static final String OPTION = "floodplain.option";
33 public static final String ACTIVE = "floodplain.active"; 27 public static final String ACTIVE = "floodplain.active";
34 public static final String INACTIVE = "floodplain.inactive"; 28 public static final String INACTIVE = "floodplain.inactive";
35 29
36 private static final Logger log = 30 private static final Logger log = Logger.getLogger(FloodplainChoice.class);
37 Logger.getLogger(FloodplainChoice.class);
38
39 31
40 @Override 32 @Override
41 protected String getUIProvider() { 33 protected String getUIProvider() {
42 return "boolean_panel"; 34 return "boolean_panel";
43 } 35 }
44 36
37 @Override
38 protected Element[] createItems(final XMLUtils.ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
39 final CallMeta meta = context.getMeta();
45 40
46 @Override 41 final Element option = createItem(cr, new String[] { Resources.getMsg(meta, OPTION, OPTION), "true" });
47 protected Element[] createItems(
48 XMLUtils.ElementCreator cr,
49 Artifact artifact,
50 String name,
51 CallContext context)
52 {
53 CallMeta meta = context.getMeta();
54
55 Element option = createItem(
56 cr,
57 new String[] { Resources.getMsg(meta, OPTION, OPTION), "true" });
58 42
59 return new Element[] { option }; 43 return new Element[] { option };
60 } 44 }
61 45
62
63 @Override 46 @Override
64 protected String getLabelFor( 47 protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) {
65 CallContext cc,
66 String name,
67 String value,
68 String type
69 ) {
70 log.debug("GET LABEL FOR '" + name + "' / '" + value + "'"); 48 log.debug("GET LABEL FOR '" + name + "' / '" + value + "'");
71 if (value != null && value.equals("true")) { 49 if (value != null && value.equals("true")) {
72 return Resources.getMsg(cc.getMeta(), ACTIVE, ACTIVE); 50 return Resources.getMsg(cc.getMeta(), ACTIVE, ACTIVE);
73 } 51 } else {
74 else {
75 return Resources.getMsg(cc.getMeta(), INACTIVE, INACTIVE); 52 return Resources.getMsg(cc.getMeta(), INACTIVE, INACTIVE);
76 } 53 }
77 } 54 }
78 55
79 56 // ist mit super identisch!
80 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { 57 // protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
81 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); 58 // Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
82 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); 59 // Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
83 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); 60 // Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
84 61 //
85 String[] arr = (String[]) obj; 62 // String[] arr = (String[]) obj;
86 63 //
87 label.setTextContent(arr[0]); 64 // label.setTextContent(arr[0]);
88 value.setTextContent(arr[1]); 65 // value.setTextContent(arr[1]);
89 66 //
90 item.appendChild(label); 67 // item.appendChild(label);
91 item.appendChild(value); 68 // item.appendChild(value);
92 69 //
93 return item; 70 // return item;
94 } 71 // }
95 } 72 }
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org