[Dive4elements-commits] [PATCH 10 of 11] Fixed validation in parameter matrix panel. Single selections are allowed now

Wald Commits scm-commit at wald.intevation.org
Mon Dec 3 17:27:30 CET 2012


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1354551949 -3600
# Node ID d5821c6f0ab030cd996187d944dcd06ec4c7cfbe
# Parent  5b551e3a58d53b60ccb4b1422908bd61d44842cd
Fixed validation in parameter matrix panel. Single selections are allowed now.
Avoid adding duplicates of user selection in parameter matrix.

diff -r 5b551e3a58d5 -r d5821c6f0ab0 flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java	Mon Dec 03 17:10:08 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java	Mon Dec 03 17:25:49 2012 +0100
@@ -263,16 +263,23 @@
         }
 
         ListGridRecord[] records = listGrid.getRecords();
-        for (ListGridRecord record: records) {
+        Map<String, List<String>> result = new HashMap<String, List<String>>();
+        for (ListGridRecord record : records) {
             for (int i = 0, n = columnNames.size(); i < n; i++) {
                 String columnName = columnNames.get(i);
-                List<String> chosenItems = selected.get(columnName);
                 if (Boolean.valueOf(record.getAttribute(columnName)) == true) {
-                    chosenItems.add(record.getAttribute(columnName + "-value"));
+                    if (result.containsKey(columnName)) {
+                        result.get(columnName).add(record.getAttribute(columnName + "-value"));
+                    }
+                    else {
+                        List<String> items = new ArrayList<String>();
+                        items.add(record.getAttribute(columnName + "-value"));
+                        result.put(columnName, items);
+                    }
                 }
             }
         }
-        return selected;
+        return result;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 5b551e3a58d5 -r d5821c6f0ab0 flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Mon Dec 03 17:10:08 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Mon Dec 03 17:25:49 2012 +0100
@@ -176,11 +176,20 @@
         GWT.log ("validation. validation. validation. ");
         List<String> errors = new ArrayList<String>();
         // Early stop on one (only) error.
+        boolean ok = false;
         for (Map.Entry<String, List<String>> entry : matrix.getSelection().entrySet()) {
+            /* single entries are allowed!!
                 if (entry.getValue() == null || entry.getValue().size() == 0) {
                     errors.add(MESSAGES.error_values_needed());
                     return errors;
                 }
+                */
+            if (entry.getValue() != null && entry.getValue().size() > 0) {
+                ok = true;
+            }
+        }
+        if (!ok) {
+            errors.add(MESSAGES.error_values_needed());
         }
         return errors;
     }


More information about the Dive4elements-commits mailing list