changeset 127:21d791e21aca

Introduced a state to select the calculation mode. flys-artifacts/trunk@1467 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 14 Mar 2011 15:47:10 +0000
parents b18aebd1342f
children 206312c2aa76
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_en.properties
diffstat 7 files changed, 87 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Mar 14 15:43:12 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Mar 14 15:47:10 2011 +0000
@@ -1,3 +1,20 @@
+2011-03-14  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/conf/artifacts/winfo.xml: Modified the winfo states.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: Adapted
+	  the artifact regarding the changes of the last commit. The states
+	  describe() method creates the dynamic UI node - the artifact needs to
+	  apply this node.
+
+	* src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java:
+	  New. The state for choosing the calculation mode.
+
+	* src/main/resources/messages.properties,
+	  src/main/resources/messages_en.properties,
+	  src/main/resources/messages_de.properties: Added i18n strings for the
+	  calculation mode state.
+
 2011-03-14  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java:
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Mon Mar 14 15:43:12 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Mon Mar 14 15:47:10 2011 +0000
@@ -2,17 +2,17 @@
 <artifact name="winfo">
     <states>
 
-        <state id="winfo_river" description="winfo_river" state="de.intevation.flys.artifacts.states.RiverSelect">
+        <state id="state.winfo.river" description="state.winfo.river" state="de.intevation.flys.artifacts.states.RiverSelect">
             <data name="river" type="String" />
         </state>
 
         <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
-            <from state="winfo_river"/>
-            <to state="winfo_gauge"/>
+            <from state="state.winfo.river"/>
+            <to state="state.winfo.calculation_mode"/>
         </transition>
 
-        <state id="winfo_gauge" description="winfo_gauge" state="de.intevation.flys.artifacts.states.GaugeSelect">
-            <data name="gauge"  type="String" />
+        <state id="state.winfo.calculation_mode" description="state.winfo.calculation_mode" state="de.intevation.flys.artifacts.states.CalculationSelect">
+            <data name="calculation_mode"  type="String" />
         </state>
 
     </states>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Mon Mar 14 15:43:12 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Mon Mar 14 15:47:10 2011 +0000
@@ -93,13 +93,20 @@
         ProtocolUtils.appendState(creator, root, current);
         ProtocolUtils.appendReachableStates(creator, root, reachable);
 
-        current.describe(description, root, context, identifier());
+        Element ui = ProtocolUtils.createArtNode(
+            creator, "ui", null, null);
 
-        Node ui = (Node) XMLUtils.xpath(
+        Element staticUI  = ProtocolUtils.createArtNode(
+            creator, "static", null, null);
+
+        Element dynamic = current.describe(
             description,
-            XPATH_STATIC_UI,
-            XPathConstants.NODE,
-            ArtifactNamespaceContext.INSTANCE);
+            root,
+            context,
+            identifier());
+
+        ui.appendChild(dynamic);
+        root.appendChild(ui);
 
         appendStaticUI(creator, ui);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/CalculationSelect.java	Mon Mar 14 15:47:10 2011 +0000
@@ -0,0 +1,50 @@
+package de.intevation.flys.artifacts.states;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Element;
+
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifacts.common.utils.XMLUtils;
+
+import de.intevation.artifactdatabase.ProtocolUtils;
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class CalculationSelect extends DefaultState {
+
+    /** The logger that is used in this class.*/
+    private static Logger logger = Logger.getLogger(CalculationSelect.class);
+
+
+    protected Element[] createItems(
+        XMLUtils.ElementCreator cr,
+        String      name,
+        CallContext context)
+    {
+        Element one = createItem(cr, new String[] {"Abflusskurve", "1"});
+        Element two = createItem(cr, new String[] {"Wasserspiegellage", "2"});
+
+        return new Element[] { one, two };
+    }
+
+
+    protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
+        Element item  = ProtocolUtils.createArtNode(cr, "item", null, null);
+        Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+        Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+
+        String[] arr = (String[]) obj;
+
+        label.setTextContent(arr[0]);
+        value.setTextContent(arr[1]);
+
+        item.appendChild(label);
+        item.appendChild(value);
+
+        return item;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/resources/messages.properties	Mon Mar 14 15:43:12 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages.properties	Mon Mar 14 15:47:10 2011 +0000
@@ -1,2 +1,2 @@
 state.winfo.river = River
-state.winfo.gauge = Pegelauswahl
+state.winfo.calculation_mode = Calculation Mode
--- a/flys-artifacts/src/main/resources/messages_de.properties	Mon Mar 14 15:43:12 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_de.properties	Mon Mar 14 15:47:10 2011 +0000
@@ -1,2 +1,2 @@
 state.winfo.river = Fluss
-state.winfo.gauge = Pegelauswahl
+state.winfo.calculation_mode = Berechnungsart
--- a/flys-artifacts/src/main/resources/messages_en.properties	Mon Mar 14 15:43:12 2011 +0000
+++ b/flys-artifacts/src/main/resources/messages_en.properties	Mon Mar 14 15:47:10 2011 +0000
@@ -1,2 +1,2 @@
 state.winfo.river = River
-state.winfo.gauge = Pegelauswahl
+state.winfo.calculation_mode = Calculation Mode

http://dive4elements.wald.intevation.org