changeset 76:2473440671ce

Integrate UI-Representation for Describe into the FISArtifact. gnv-artifacts/trunk@87 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 15 Sep 2009 10:11:08 +0000
parents 9345835e2bc1
children 0e38f512f7e4
files gnv-artifacts/Changelog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java
diffstat 4 files changed, 61 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/Changelog	Mon Sep 14 13:38:20 2009 +0000
+++ b/gnv-artifacts/Changelog	Tue Sep 15 10:11:08 2009 +0000
@@ -1,3 +1,12 @@
+2009-09-15  Tim Englich  <tim.englich@intevation.de>
+
+    * src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java (createUserInterface) Edited:
+      Integrate UI-Representation for Describe into the FISArtifact. 
+    * src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java (createXFormElement) Refactoring,
+      src/main/java/de/intevation/gnv/transition/TransitionBase.java (describe) Refactoring: 
+      Extract the Element-Creation of XForms Nodes into a Common Class to make them available for
+      other Classes which have to create XForm-Fragments    
+      
 2009-09-14  Tim Englich  <tim.englich@intevation.de>
 
     * src/main/java/de/intevation/gnv/transition/Transition.java Edited, 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java	Mon Sep 14 13:38:20 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java	Tue Sep 15 10:11:08 2009 +0000
@@ -327,8 +327,36 @@
     
     protected void createUserInterface(Element parent, Document document){
         Element uiNode = xmlUtilities.createArtifactElement(document,"ui");
-        
-        // TODO hier selectbox mit den produktnamen
+        ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
+        if (this.products != null && !this.products.isEmpty()){
+            String selectboxName = "product";
+            Iterator<Product> it = this.products.values().iterator();
+            Element selectNode = xmlUtilities.createXFormElement(document,"select");
+            selectNode.setAttribute("ref", selectboxName);
+            uiNode.appendChild(selectNode);
+            
+            Element lableNode = xmlUtilities.createXFormElement(document, "label");
+            lableNode.setTextContent(selectboxName);
+            selectNode.appendChild(lableNode);
+            Element choiceNode = xmlUtilities.createXFormElement(document, "choices");
+            selectNode.appendChild(choiceNode);
+            while (it.hasNext()){
+                Product p = it.next();
+                Element itemNode = xmlUtilities.createXFormElement(document, "item");
+                
+                
+                Element choiceLableNode = xmlUtilities.createXFormElement(document, "label");
+                choiceLableNode.setTextContent(p.getName());
+                itemNode.appendChild(choiceLableNode);
+                
+                Element choicValueNode = xmlUtilities.createXFormElement(document, "value");
+                choicValueNode.setTextContent(p.getName());
+                itemNode.appendChild(choicValueNode);
+                
+                choiceNode.appendChild(itemNode);
+                
+            }
+        }
         
         parent.appendChild(uiNode);
     }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java	Mon Sep 14 13:38:20 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java	Tue Sep 15 10:11:08 2009 +0000
@@ -28,6 +28,7 @@
 import de.intevation.gnv.transition.describedata.KeyValueDescibeData;
 import de.intevation.gnv.transition.describedata.MinMaxDescribeData;
 import de.intevation.gnv.transition.exception.TransitionException;
+import de.intevation.gnv.utils.ArtifactXMLUtilities;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -39,9 +40,6 @@
      */
     private static Logger log = Logger.getLogger(GNVArtifactBase.class);
     
-    public static final String XFORM_URL = "http://www.w3.org/2002/xforms";
-    public static final String XFORM_PREFIX = "xform";
-    
     private String id = null;
     
     private String description = null;
@@ -237,11 +235,12 @@
     public void describe(Document document, Node rootNode) {
         
         if(this.descibeData != null){
+            ArtifactXMLUtilities xmlutilities = new ArtifactXMLUtilities();
             Iterator<Object> it = this.descibeData.iterator();
             while (it.hasNext()){
                 Object o = it.next();
                 if (o instanceof Collection<?>){
-                    Element selectNode = this.createXFormElement(document,"select");
+                    Element selectNode = xmlutilities.createXFormElement(document,"select");
                     // TODO: HACK:
                     // BESSERE LÖSUNG FINDEN
                     Object[] names = this.inputValueNames.toArray();
@@ -249,22 +248,22 @@
                     
                     selectNode.setAttribute("ref", name);
                     
-                    Element lableNode = this.createXFormElement(document, "label");
+                    Element lableNode = xmlutilities.createXFormElement(document, "label");
                     lableNode.setTextContent(name);
-                    Element choiceNode = this.createXFormElement(document, "choices");
+                    Element choiceNode = xmlutilities.createXFormElement(document, "choices");
                     
                     Collection<KeyValueDescibeData> values = (Collection)o;
                     Iterator<KeyValueDescibeData> resultIt = values.iterator();
                     while (resultIt.hasNext()){
                         KeyValueDescibeData result = resultIt.next();
-                        Element itemNode = this.createXFormElement(document, "item");
+                        Element itemNode = xmlutilities.createXFormElement(document, "item");
                         
                         
-                        Element choiceLableNode = this.createXFormElement(document, "label");
+                        Element choiceLableNode = xmlutilities.createXFormElement(document, "label");
                         choiceLableNode.setTextContent(result.getValue());
                         itemNode.appendChild(choiceLableNode);
                         
-                        Element choicValueNode = this.createXFormElement(document, "value");
+                        Element choicValueNode = xmlutilities.createXFormElement(document, "value");
                         choicValueNode.setTextContent(""+result.getKey());
                         itemNode.appendChild(choicValueNode);
                         
@@ -287,23 +286,23 @@
                         max = DateUtils.getPatternedDateAmer(d);
                     }
                     
-                    Element inputMinNode = this.createXFormElement(document, "input");
+                    Element inputMinNode = xmlutilities.createXFormElement(document, "input");
                     inputMinNode.setAttribute("ref", "minvalue");
-                    Element inputMinLableNode = this.createXFormElement(document, "label");
+                    Element inputMinLableNode = xmlutilities.createXFormElement(document, "label");
                     inputMinLableNode.setTextContent("minvalue");
                     inputMinNode.appendChild(inputMinLableNode);
                     
-                    Element inputMinValueNode = this.createXFormElement(document, "value");
+                    Element inputMinValueNode = xmlutilities.createXFormElement(document, "value");
                     inputMinValueNode.setTextContent(min.toString());
                     inputMinNode.appendChild(inputMinValueNode);
                     
-                    Element inputMaxNode = this.createXFormElement(document, "input");
+                    Element inputMaxNode = xmlutilities.createXFormElement(document, "input");
                     inputMaxNode.setAttribute("ref", "maxvalue");
-                    Element inputMaxLableNode = this.createXFormElement(document, "label");
+                    Element inputMaxLableNode = xmlutilities.createXFormElement(document, "label");
                     inputMaxLableNode.setTextContent("maxvalue");
                     inputMaxNode.appendChild(inputMaxLableNode);
                     
-                    Element inputMaxValueNode = this.createXFormElement(document, "value");
+                    Element inputMaxValueNode = xmlutilities.createXFormElement(document, "value");
                     inputMaxValueNode.setTextContent(max.toString());
                     inputMaxNode.appendChild(inputMaxValueNode);
                     
@@ -317,12 +316,6 @@
        
     }
 
-    private Element createXFormElement(Document document, String name) {
-        Element node = document.createElementNS(XFORM_URL, name);
-        node.setPrefix(XFORM_PREFIX);
-        return node;
-    }
-
     /**
      * @see de.intevation.gnv.transition.Transition#getDescibeData()
      */
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java	Mon Sep 14 13:38:20 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java	Tue Sep 15 10:11:08 2009 +0000
@@ -39,6 +39,9 @@
      */
     private static Logger log = Logger.getLogger(TimeSeriesOutputTransition.class);
   
+    public static final String XFORM_URL = "http://www.w3.org/2002/xforms";
+    public static final String XFORM_PREFIX = "xform";
+    
     /**
      * Constructor
      */
@@ -96,7 +99,11 @@
         return this.readDocument(inputStream);
     }
     
-    
+    public Element createXFormElement(Document document, String name) {
+        Element node = document.createElementNS(XFORM_URL, name);
+        node.setPrefix(XFORM_PREFIX);
+        return node;
+    }
     
 
 }

http://dive4elements.wald.intevation.org