[PATCH 2 of 2] issue1063: Always create data for all parameters, even if not specified

Wald Commits scm-commit at wald.intevation.org
Mon Nov 18 15:39:04 CET 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1384785532 -3600
# Node ID dacc1123075fbfe324fdb9c9c7c399e9bbcb01dc
# Parent  b4b8764ee90de19f06fbb99d959e367d2394fbb3
issue1063: Always create data for all parameters, even if not specified.
This will delete old data elements.

diff -r b4b8764ee90d -r dacc1123075f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java	Mon Nov 18 15:37:33 2013 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java	Mon Nov 18 15:38:52 2013 +0100
@@ -47,7 +47,7 @@
         Map<String, List<String>> selection = matrix.getSelection();
         Set<Map.Entry<String, List<String>>> entries = selection.entrySet();
 
-        Data[] list = new Data[selection.size()];
+        Data[] list = new Data[matrix.getColumnNames().size()];
 
         int i = 0;
 
@@ -63,6 +63,23 @@
                 entry.getKey(), null, null, new DataItem[] { item });
         }
 
+        // To delete old values already given, construct empty ones
+        // for all not-specified options.
+        for (String colName : matrix.getColumnNames()) {
+            boolean found = false;
+            for (Data data : list) {
+                if (data != null && data.getLabel().equals(colName)) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                // Add an empty data for this.
+                list[i++] = new DefaultData(
+                    colName, null, null, new DataItem[] { });
+            }
+        }
+
         return list;
     }
 


More information about the Dive4elements-commits mailing list