changeset 8627:e0c8850d8629

Add default value handling in MultiPeriodPanel
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 26 Mar 2015 11:53:41 +0100
parents 3b85c8cee94b
children a5439a609625
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/MultiPeriodPanel.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/MultiPeriodPanel.java	Thu Mar 26 11:52:05 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/MultiPeriodPanel.java	Thu Mar 26 11:53:41 2015 +0100
@@ -127,6 +127,23 @@
         input.addMember(grid);
         root.addMember(input);
 
+        /* Check for a default element */
+        Data periods = getData(data.getAll(), "periods");
+        DataItem[] items = periods.getItems();
+        if (items == null) {
+            return root;
+        }
+
+        for (DataItem item: items) {
+            if (!item.getLabel().equals("default")) {
+                continue;
+            }
+            String[] vals = item.getStringValue().split(",");
+            long f = Long.valueOf(vals[0]).longValue();
+            long t = Long.valueOf(vals[1]).longValue();
+            inputPanel.setFromDate(new Date(f));
+            inputPanel.setToDate(new Date(t));
+        }
         return root;
     }
 

http://dive4elements.wald.intevation.org