diff flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java @ 2521:fe177e7f61d1

Added a new UIProvider that renders a matrix of checkboxes for user input. flys-client/trunk@4401 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 14 May 2012 14:45:02 +0000
parents 69a498896c9c
children 261347ea60b8
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Mon May 14 10:29:05 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Mon May 14 14:45:02 2012 +0000
@@ -180,6 +180,12 @@
             else if (type.equals("intarray")) {
                 list.add(new IntegerArrayData(name, label, null));
             }
+            else if (type.equals("intoptions") && uiProvider.equals("parameter-matrix")) {
+                NodeList   choices = ClientProtocolUtils.getItemNodes(d);
+                DataItem[] opts    = extractIntegerOptions(choices);
+
+                list.add(new IntegerOptionsData(name, label, opts));
+            }
             else if (type.equals("intoptions")) {
                 NodeList   choices = ClientProtocolUtils.getItemNodes(d);
                 DataItem[] opts    = extractCurrentDataItems(choices);
@@ -237,6 +243,23 @@
     }
 
 
+    protected static DataItem[] extractIntegerOptions(NodeList options) {
+        DataItem[] items = new DataItem[options.getLength()];
+
+        for (int i = 0, n = options.getLength(); i < n; i++) {
+            Element el = (Element) options.item(i);
+
+            String value = el.getTextContent();
+            String label = XMLUtils.xpathString(
+                el, "@art:label", ArtifactNamespaceContext.INSTANCE);
+
+            items[i] = new DefaultDataItem(label, label, value);
+        }
+
+        return items;
+    }
+
+
     /**
      * This method extract the {@link DataItem}s of the DESCRIBE document.
      *

http://dive4elements.wald.intevation.org