annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java @ 139:05207cc4a084

Fixed a german umlaut. flys-artifacts/trunk@1521 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 21 Mar 2011 06:11:01 +0000
parents 8be4a837f20a
children 992afc0299cd
rev   line source
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
3 import java.util.List;
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
4
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
7 import org.w3c.dom.Element;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Node;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.CallContext;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
12 import de.intevation.artifacts.common.utils.XMLUtils;
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
13
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
14 import de.intevation.artifactdatabase.ProtocolUtils;
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
15 import de.intevation.artifactdatabase.data.StateData;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
132
8be4a837f20a Added support for the flys backend and an example how to use it.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 126
diff changeset
17 import de.intevation.flys.model.River;
8be4a837f20a Added support for the flys backend and an example how to use it.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 126
diff changeset
18
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
19 import de.intevation.flys.artifacts.model.RiverFactory;
132
8be4a837f20a Added support for the flys backend and an example how to use it.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 126
diff changeset
20
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
21 import de.intevation.flys.artifacts.resources.Resources;
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
22
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 /**
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 */
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
27 public class RiverSelect extends DefaultState {
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 /** The logger used in this class. */
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private static Logger logger = Logger.getLogger(RiverSelect.class);
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 /**
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 * The default constructor that initializes an empty State object.
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 */
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public RiverSelect() {
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 /**
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 * Initialize the state based on the state node in the configuration.
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 *
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 * @param config The state configuration node.
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 */
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 public void setup(Node config) {
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 super.setup(config);
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
49 protected Element createData(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
50 XMLUtils.ElementCreator cr,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
51 StateData data,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
52 CallContext context)
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 {
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
54 Element select = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
55 cr, "select",
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
56 new String[] { "uiprovider" },
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
57 new String[] { "select_with_map" });
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
58 cr.addAttr(select, "name", data.getName());
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
59
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
60 Element label = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
61 cr, "label", null, null);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
62
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
63 Element choices = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
64 cr, "choices", null, null);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
65
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
66 label.setTextContent(Resources.getMsg(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
67 context.getMeta(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
68 getID(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
69 getID()));
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
70
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
71 return select;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
72 }
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
73
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
74
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
75 protected Element[] createItems(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
76 XMLUtils.ElementCreator cr,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
77 String name,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
78 CallContext context)
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
79 {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
80 List<River> rivers = RiverFactory.getRivers();
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
81 Element[] items = new Element[rivers.size()];
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
82
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
83 int idx = 0;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
84 for (River river: rivers) {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
85 items[idx++] = createRiverItem(cr, river);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
86 }
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
87
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
88 return items;
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
89 }
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
90
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
91
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
92 /**
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
93 * This method creates a node that represents a river item. This node
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
94 * contains the label and the value that describe the river.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
95 *
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
96 * @param cr The ElementCreator.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
97 * @param river The river.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
98 *
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
99 * @return the element that contains the information about the river.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
100 */
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
101 protected Element createRiverItem(XMLUtils.ElementCreator cr, River river) {
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
102 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
103 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
104 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
105
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
106 label.setTextContent(river.getName());
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
107 value.setTextContent(river.getName());
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
108
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
109 item.appendChild(label);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
110 item.appendChild(value);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
111
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
112 return item;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org