changeset 2528:33e2a1e23ae8

Implemented ParameterMatrixPanel.createOld() and added a real 'description' to Data instances in DataFactory. flys-client/trunk@4421 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 16 May 2012 10:45:57 +0000 (2012-05-16)
parents c8413741339f
children b07c36e47970
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java flys-client/src/main/java/de/intevation/flys/client/server/DataFactory.java
diffstat 3 files changed, 84 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed May 16 08:16:13 2012 +0000
+++ b/flys-client/ChangeLog	Wed May 16 10:45:57 2012 +0000
@@ -1,3 +1,14 @@
+2012-05-16  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/DataFactory.java: Extract
+	  the 'label' attribute of a <data> element and set this label as
+	  description of new Data instances. If no 'label' attribute is
+	  provided, the 'name' attribute (which is required) is used as
+	  description.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java:
+	  Implemented the createOld() method to display the user specified values.
+
 2012-05-16  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Wed May 16 08:16:13 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Wed May 16 10:45:57 2012 +0000
@@ -9,6 +9,7 @@
 import com.smartgwt.client.types.FieldType;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.shared.model.Data;
@@ -71,8 +72,48 @@
 
     @Override
     public Canvas createOld(DataList dataList) {
-        GWT.log("TODO: IMPLEMENT RadioPanel.createOld()");
-        return new Label("TODO: DISPLAY INSERTED VALUES");
+        HLayout layout  = new HLayout();
+        VLayout vLayout = new VLayout();
+
+        layout.setWidth(300);
+        vLayout.setWidth(280);
+
+        for (int i = 0, n = dataList.size(); i < n; i++) {
+            HLayout row  = new HLayout();
+            VLayout cols = new VLayout();
+
+            row.setWidth(300);
+            cols.setWidth(100);
+
+            Data       data  = dataList.get(i);
+            DataItem[] items = data.getItems();
+
+            Label parameter = new Label(data.getDescription());
+            parameter.setWidth(200);
+
+            for (int j = 0, m = dataList.size(); j < m; j++) {
+                DataItem item  = items[j];
+                Label    value = new Label(item.getLabel());
+
+                value.setValign(com.smartgwt.client.types.VerticalAlignment.TOP);
+                value.setWidth(130);
+                value.setHeight(20);
+
+                cols.addMember(value);
+            }
+
+            row.addMember(parameter);
+            row.addMember(cols);
+
+            vLayout.addMember(row);
+        }
+
+        Canvas back = getBackButton(dataList.getState());
+
+        layout.addMember(vLayout);
+        layout.addMember(back);
+
+        return layout;
     }
 
     @Override
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DataFactory.java	Wed May 16 08:16:13 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/DataFactory.java	Wed May 16 10:45:57 2012 +0000
@@ -42,41 +42,44 @@
      * @return a Data instance.
      */
     public static Data createDataFromElement(Element element) {
-        String name = element.getAttributeNS(NS_URI, "name");
-        String type = element.getAttributeNS(NS_URI, "type");
+        String name  = element.getAttributeNS(NS_URI, "name");
+        String type  = element.getAttributeNS(NS_URI, "type");
+        String label = element.getAttributeNS(NS_URI, "label");
+
+        label = label != null && label.length() > 0 ? label : name;
 
         try {
             logger.debug("Create Data instance for: " + name + " | " + type);
 
             if (type == null || type.length() == 0) {
-                return createDefaultData(element, name);
+                return createDefaultData(element, name, label);
             }
 
             type = type.toLowerCase();
 
             if (type.equals(StringData.TYPE)) {
-                return createStringData(element, name);
+                return createStringData(element, name, label);
             }
             else if (type.equals(IntegerData.TYPE)) {
-                return createIntegerData(element, name);
+                return createIntegerData(element, name, label);
             }
             else if (type.equals(IntegerOptionsData.TYPE)) {
-                return createIntegerOptionsData(element, name);
+                return createIntegerOptionsData(element, name, label);
             }
             else if (type.equals(IntegerRangeData.TYPE)) {
-                return createIntegerRangeData(element, name);
+                return createIntegerRangeData(element, name, label);
             }
             else if (type.equals(IntegerArrayData.TYPE)) {
-                return createIntegerArrayData(element, name);
+                return createIntegerArrayData(element, name, label);
             }
             else if (type.equals(DoubleArrayData.TYPE)) {
-                return createDoubleArrayData(element, name);
+                return createDoubleArrayData(element, name, label);
             }
             else if (type.equals(LongRangeData.TYPE)) {
-                return createLongRangeData(element, name);
+                return createLongRangeData(element, name, label);
             }
             else {
-                return createDefaultData(element, name);
+                return createDefaultData(element, name, label);
             }
         }
         catch (Exception e) {
@@ -96,9 +99,9 @@
      *
      * @return an instance of DefaultData.
      */
-    protected static Data createDefaultData(Element ele, String name) {
+    protected static Data createDefaultData(Element ele, String name, String label) {
         logger.debug("Create new DefaultData");
-        return new DefaultData(name, name, "default", extractDataItems(ele));
+        return new DefaultData(name, label, "default", extractDataItems(ele));
     }
 
 
@@ -111,8 +114,8 @@
      *
      * @return an instance of StringData.
      */
-    protected static Data createStringData(Element ele, String name) {
-        return new StringData(name, name, extractDataItems(ele));
+    protected static Data createStringData(Element ele, String name, String label) {
+        return new StringData(name, label, extractDataItems(ele));
     }
 
 
@@ -125,8 +128,8 @@
      *
      * @return an instance of IntegerData.
      */
-    protected static Data createIntegerData(Element ele, String name) {
-        return new IntegerData(name, name, extractDataItems(ele));
+    protected static Data createIntegerData(Element ele, String name, String label) {
+        return new IntegerData(name, label, extractDataItems(ele));
     }
 
 
@@ -139,8 +142,8 @@
      *
      * @return an instance of IntegerOptionsData.
      */
-    protected static Data createIntegerOptionsData(Element ele, String name) {
-        return new IntegerOptionsData(name, name, extractDataItems(ele));
+    protected static Data createIntegerOptionsData(Element ele, String name, String label) {
+        return new IntegerOptionsData(name, label, extractDataItems(ele));
     }
 
 
@@ -153,7 +156,7 @@
      *
      * @return an instance of IntegerRangeData.
      */
-    protected static Data createIntegerRangeData(Element ele, String name) {
+    protected static Data createIntegerRangeData(Element ele, String name, String label) {
         DataItem[] items    = extractDataItems(ele);
         String     rawValue = items[0].getStringValue();
 
@@ -161,7 +164,7 @@
 
         return new IntegerRangeData(
             name,
-            name,
+            label,
             Integer.valueOf(minmax[0]),
             Integer.valueOf(minmax[1]));
     }
@@ -176,7 +179,7 @@
      *
      * @return an instance of IntegerArrayData.
      */
-    protected static Data createIntegerArrayData(Element ele, String name) {
+    protected static Data createIntegerArrayData(Element ele, String name, String label) {
         DataItem[] items    = extractDataItems(ele);
         String     rawValue = items[0].getStringValue();
 
@@ -192,7 +195,7 @@
             }
         }
 
-        return new IntegerArrayData(name, items[0].getLabel(), integers);
+        return new IntegerArrayData(name, label, integers);
     }
 
 
@@ -205,7 +208,7 @@
      *
      * @return an instance of DoubleArrayData.
      */
-    protected static Data createDoubleArrayData(Element ele, String name) {
+    protected static Data createDoubleArrayData(Element ele, String name, String label) {
         DataItem[] items    = extractDataItems(ele);
         String     rawValue = items[0].getStringValue();
 
@@ -221,7 +224,7 @@
             }
         }
 
-        return new DoubleArrayData(name, items[0].getLabel(), doubles);
+        return new DoubleArrayData(name, label, doubles);
     }
 
 
@@ -270,7 +273,7 @@
      *
      * @return an instance of IntegerRangeData.
      */
-    protected static Data createLongRangeData(Element ele, String name) {
+    protected static Data createLongRangeData(Element ele, String name, String label) {
         DataItem[] items    = extractDataItems(ele);
         String     rawValue = items[0].getStringValue();
 
@@ -278,7 +281,7 @@
 
         return new LongRangeData(
             name,
-            name,
+            label,
             Long.valueOf(minmax[0]),
             Long.valueOf(minmax[1]));
     }

http://dive4elements.wald.intevation.org