comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 137:7f839b81cdde

Added a new state for the W/Q input in the WINFO parameterization. flys-artifacts/trunk@1514 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 18 Mar 2011 09:38:11 +0000
parents
children 89bd0417418f
comparison
equal deleted inserted replaced
136:2e510c998adb 137:7f839b81cdde
1 package de.intevation.flys.artifacts.states;
2
3 import org.apache.log4j.Logger;
4
5 import org.w3c.dom.Element;
6
7 import de.intevation.artifacts.CallContext;
8
9 import de.intevation.artifacts.common.utils.XMLUtils;
10
11 import de.intevation.artifactdatabase.ProtocolUtils;
12 import de.intevation.artifactdatabase.data.StateData;
13
14 import de.intevation.flys.artifacts.resources.Resources;
15
16 /**
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
18 */
19 public class WQSelect extends DefaultState {
20
21 /** The logger used in this class.*/
22 private static Logger logger = Logger.getLogger(WQSelect.class);
23
24
25 /** The default step width for Qs.*/
26 public static final String DEFAULT_STEP_Q = "50";
27
28 /** The default step width for Qs.*/
29 public static final String DEFAULT_STEP_W = "30";
30
31 /**
32 * The default constructor that initializes an empty State object.
33 */
34 public WQSelect() {
35 }
36
37 protected Element createData(
38 XMLUtils.ElementCreator cr,
39 StateData data,
40 CallContext context)
41 {
42 Element select = ProtocolUtils.createArtNode(
43 cr, "select", null, null);
44
45 cr.addAttr(select, "name", data.getName(), true);
46
47 Element label = ProtocolUtils.createArtNode(
48 cr, "label", null, null);
49
50 Element choices = ProtocolUtils.createArtNode(
51 cr, "choices", null, null);
52
53 label.setTextContent(Resources.getMsg(
54 context.getMeta(),
55 data.getName(),
56 data.getName()));
57
58 select.appendChild(label);
59
60 return select;
61 }
62
63
64 protected Element[] createItems(
65 XMLUtils.ElementCreator cr,
66 String name,
67 CallContext context)
68 {
69 // TODO Insert correct min/max values!
70
71 if (name.equals("wq_from")) {
72 Element minW = createItem(cr, new String[] {"minW", "250"});
73 Element minQ = createItem(cr, new String[] {"minQ", "5.5"});
74 return new Element[] { minW, minQ };
75 }
76 else if (name.equals("wq_to")) {
77 Element maxW = createItem(cr, new String[] {"maxW", "850"});
78 Element maxQ = createItem(cr, new String[] {"maxQ", "1530"});
79 return new Element[] { maxW, maxQ };
80 }
81 else {
82 Element stepW = createItem(cr, new String[] {"stepW", DEFAULT_STEP_W});
83 Element stepQ = createItem(cr, new String[] {"stepQ", DEFAULT_STEP_Q});
84 return new Element[] { stepW, stepQ };
85 }
86 }
87
88
89 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
90 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
91 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
92 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
93
94 String[] arr = (String[]) obj;
95
96 label.setTextContent(arr[0]);
97 value.setTextContent(arr[1]);
98
99 item.appendChild(label);
100 item.appendChild(value);
101
102 return item;
103 }
104
105
106 protected String getUIProvider() {
107 return "wq_panel";
108 }
109 }
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org