changeset 1566:c408074c6409

Initialize the min and max fields in RangePanel. flys-client/trunk@3822 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 30 Jan 2012 10:12:05 +0000
parents 87f5ed6960e8
children 7e738bc8ed75
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerRangeData.java flys-client/src/main/java/de/intevation/flys/client/shared/model/RangeData.java
diffstat 5 files changed, 94 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Jan 30 08:57:43 2012 +0000
+++ b/flys-client/ChangeLog	Mon Jan 30 10:12:05 2012 +0000
@@ -1,3 +1,19 @@
+2012-01-30  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/shared/model/RangeData.java:
+	  Added getDefaultLower() and getDefaultUpper() methods.
+
+	* src/main/java/de/intevation/flys/client/shared/model/IntegerRangeData.java:
+	  Added a new constructor that takes default values for min and max and
+	  implemented the getDefaultLower() and getDefaultUpper() methods.
+
+	* src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java:
+	  Read default values for min and max data items from DESCRIBE document.
+
+	* src/main/java/de/intevation/flys/client/client/ui/RangePanel.java:
+	  Initialize the min and max field with default values provided by
+	  RangeData's getDefaultLower() and getDefaultUpper() methods.
+
 2012-01-30  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java	Mon Jan 30 08:57:43 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangePanel.java	Mon Jan 30 10:12:05 2012 +0000
@@ -46,6 +46,8 @@
         root.addMember(createForm(data));
         root.addMember(getNextButton());
 
+        initDefaults(data);
+
         return root;
     }
 
@@ -94,6 +96,16 @@
     }
 
 
+    protected void initDefaults(DataList dataList) {
+        RangeData data = findRangeData(dataList);
+
+        if (data != null) {
+            setLower(String.valueOf(data.getDefaultLower()));
+            setUpper(String.valueOf(data.getDefaultUpper()));
+        }
+    }
+
+
     protected RangeData findRangeData(DataList dataList) {
         RangeData data = null;
 
@@ -126,11 +138,21 @@
     }
 
 
+    public void setLower(String lower) {
+        lowerForm.setValue(FIELD_LOWER, lower);
+    }
+
+
     public String getUpper() {
         return upperForm.getValueAsString(FIELD_UPPER);
     }
 
 
+    public void setUpper(String upper) {
+        upperForm.setValue(FIELD_UPPER, upper);
+    }
+
+
     protected Canvas createLabel(DataList dataList) {
         RangeData rangeData = findRangeData(dataList);
 
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Mon Jan 30 08:57:43 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Mon Jan 30 10:12:05 2012 +0000
@@ -144,13 +144,27 @@
                 list.add(new DefaultData(name, label, null, dataItems, def));
             }
             else if (type.equals("intrange")) {
-                String min   = ClientProtocolUtils.getMinNode(d);
-                String max   = ClientProtocolUtils.getMaxNode(d);
+                String min = ClientProtocolUtils.getMinNode(d);
+                String max = ClientProtocolUtils.getMaxNode(d);
+
+                String defMin = ClientProtocolUtils.getDefMin(d);
+                String defMax = ClientProtocolUtils.getDefMax(d);
 
                 try {
                     int lower = Integer.parseInt(min);
                     int upper = Integer.parseInt(max);
-                    list.add(new IntegerRangeData(name, label, lower, upper));
+
+                    if (defMin != null && defMax != null) {
+                        list.add(new IntegerRangeData(
+                                name, label,
+                                lower, upper,
+                                Integer.parseInt(defMin),
+                                Integer.parseInt(defMax)));
+                    }
+                    else {
+                        list.add(
+                            new IntegerRangeData(name, label, lower, upper));
+                    }
                 }
                 catch (NumberFormatException nfe) {
                     logger.warn("NumberFormatException: ", nfe);
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerRangeData.java	Mon Jan 30 08:57:43 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/IntegerRangeData.java	Mon Jan 30 10:12:05 2012 +0000
@@ -12,16 +12,41 @@
     protected int lower;
     protected int upper;
 
+    protected Integer defLower;
+    protected Integer defUpper;
+
 
     public IntegerRangeData() {
     }
 
 
     public IntegerRangeData(String label, String desc, int lower, int upper) {
+        this(label, desc, lower, upper, null, null);
+    }
+
+
+    /**
+     * @param label
+     * @param desc
+     * @param lower
+     * @param upper
+     * @param defLower
+     * @param defUpper
+     */
+    public IntegerRangeData(
+        String  label,
+        String  desc,
+        int     lower,
+        int     upper,
+        Integer defLower,
+        Integer defUpper
+    ) {
         this.label       = label;
         this.description = desc;
         this.lower       = lower;
         this.upper       = upper;
+        this.defLower    = defLower;
+        this.defUpper    = defUpper;
     }
 
 
@@ -89,5 +114,15 @@
     public Object getUpper() {
         return upper;
     }
+
+
+    public Object getDefaultLower() {
+        return defLower;
+    }
+
+
+    public Object getDefaultUpper() {
+        return defUpper;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/RangeData.java	Mon Jan 30 08:57:43 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/RangeData.java	Mon Jan 30 10:12:05 2012 +0000
@@ -9,5 +9,9 @@
     Object getLower();
 
     Object getUpper();
+
+    Object getDefaultLower();
+
+    Object getDefaultUpper();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org