changeset 2525:da1d897ed66d

Implemented ParameterMatrixPanel.getData(). flys-client/trunk@4412 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 15 May 2012 14:24:09 +0000 (2012-05-15)
parents 39cf246b28c4
children a911e2968cb1
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java
diffstat 2 files changed, 56 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue May 15 14:23:00 2012 +0000
+++ b/flys-client/ChangeLog	Tue May 15 14:24:09 2012 +0000
@@ -1,3 +1,9 @@
+2012-05-15  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java:
+	  Implemented getData() which now returns the selected values from
+	  ParameterMatrix as colon separated string.
+
 2012-05-14	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/ModuleSelection.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Tue May 15 14:23:00 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Tue May 15 14:24:09 2012 +0000
@@ -1,5 +1,9 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import com.google.gwt.core.client.GWT;
 
 import com.smartgwt.client.types.FieldType;
@@ -10,6 +14,8 @@
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
 import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.DefaultData;
+import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.IntegerOptionsData;
 
 /**
@@ -17,12 +23,52 @@
  */
 public class ParameterMatrixPanel extends AbstractUIProvider {
 
+    private ParameterMatrix matrix;
+
     @Override
     protected Data[] getData() {
-        GWT.log("TODO: IMPLEMENT RadioPanel.getData()");
-        return new Data[0];
+        Map<String, List<String>> selection = matrix.getSelection();
+        Set<Map.Entry<String, List<String>>> entries = selection.entrySet();
+
+        Data[] list = new Data[selection.size()];
+
+        int i = 0;
+
+        for (Map.Entry<String, List<String>> entry: entries) {
+            String value = buildValueString(entry.getValue());
+
+            DataItem item = new DefaultDataItem(
+                entry.getKey(),
+                null,
+                value);
+
+            list[i++] = new DefaultData(
+                entry.getKey(), null, null, new DataItem[] { item });
+        }
+
+        return list;
     }
 
+
+    protected String buildValueString(List<String> values) {
+        StringBuilder sb = new StringBuilder();
+
+        boolean first = true;
+
+        for (String value: values) {
+            if (!first) {
+                sb.append(";");
+            }
+
+            sb.append(value);
+
+            first = false;
+        }
+
+        return sb.toString();
+    }
+
+
     @Override
     public Canvas createOld(DataList dataList) {
         GWT.log("TODO: IMPLEMENT RadioPanel.createOld()");
@@ -34,7 +80,7 @@
         VLayout v = new VLayout();
         v.addMember(createTitle(dataList));
 
-        ParameterMatrix matrix = new ParameterMatrix();
+        matrix = new ParameterMatrix();
 
         for (Data data: dataList.getAll()) {
             if (data instanceof IntegerOptionsData) {
@@ -43,6 +89,7 @@
         }
 
         v.addMember(matrix.create());
+        v.addMember(getNextButton());
 
         return v;
     }

http://dive4elements.wald.intevation.org