changeset 4133:c722c08cf502

Merged heads.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 15 Oct 2012 09:31:50 +0200
parents f6c73ee1b7f1 (diff) 360e22afb98b (current diff)
children 9c78264109ad
files flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java
diffstat 7 files changed, 89 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeTimerangeState.java	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeTimerangeState.java	Mon Oct 15 09:31:50 2012 +0200
@@ -23,12 +23,12 @@
             Logger.getLogger(GaugeTimerangeState.class);
 
 
-    protected int[] getLowerUpper(FLYSArtifact flys) {
+    protected long[] getLowerUpper(FLYSArtifact flys) {
         Gauge gauge = FLYSUtils.getReferenceGauge(flys);
 
         if (gauge == null) {
             logger.warn("No reference gauge specified!");
-            return new int[] { 0, 0 };
+            return new long[] { 0, 0 };
         }
 
         Session session = SessionHolder.HOLDER.get();
@@ -53,7 +53,7 @@
             Calendar up = (Calendar) res[1];
 
             if (lo != null && up != null) {
-                return new int[] { lo.get(Calendar.YEAR), up.get(Calendar.YEAR) };
+                return new long[] { lo.getTimeInMillis(), up.getTimeInMillis() };
             }
         }
 
@@ -65,7 +65,7 @@
 
     @Override
     protected Object getLower(FLYSArtifact flys) {
-        int[] lowerUpper = getLowerUpper(flys);
+        long[] lowerUpper = getLowerUpper(flys);
 
         return lowerUpper != null ? lowerUpper[0] : 0;
     }
@@ -73,7 +73,7 @@
 
     @Override
     protected Object getUpper(FLYSArtifact flys) {
-        int[] lowerUpper = getLowerUpper(flys);
+        long[] lowerUpper = getLowerUpper(flys);
 
         return lowerUpper != null ? lowerUpper[1] : 0;
     }
@@ -83,5 +83,10 @@
     protected String getUIProvider() {
         return "gaugetimerange";
     }
+
+    @Override
+    protected String getType() {
+        return "longrange";
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Oct 15 09:31:50 2012 +0200
@@ -568,6 +568,8 @@
 
     String error_validate_date_range();
 
+    String error_validate_date_range_invalid();
+
     String error_validate_lower_range();
 
     String error_validate_upper_range();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Oct 15 09:31:50 2012 +0200
@@ -287,6 +287,7 @@
 error_read_minmax_values = Error while reading min/max values for the location input.
 error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2.
 error_validate_date_range = Start date needs to be before end date.
+error_validate_date_range_invalid = The specified timerange is invalid.
 error_validate_lower_range = The lower value $1 needs to be bigger than $2.
 error_validate_upper_range = The upper value $1 needs to be smaller than $2.
 error_empty_state = Required inputs are missing.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Oct 15 09:31:50 2012 +0200
@@ -285,7 +285,8 @@
 unexpected_exception = Ein unerwarteter Fehler ist aufgetreten
 error_read_minmax_values = Fehler beim Lesen der min/max Werte. Es kann keine Validierung der eingegebenen Strecke durchgef\u00fchrt werden.
 error_validate_range = Der Wert $1 muss kleiner als $3 und gr\u00f6\u00dfer als $2 sein.
-error_validate_date_range = Anfangsdatum muss früher sein als Enddatum.
+error_validate_date_range = Anfangsdatum muss fr\u00fcher sein als Enddatum.
+error_validate_date_range_invalid = Der eingegebene Zeitbereich ist ung\u00fcltig.
 error_validate_lower_range = Der untere Wert $1 muss gr\u00f6\u00dfer sein als $2.
 error_validate_upper_range = Der obere Wert $1 muss kleiner sein als $2.
 error_empty_state = Es wurden nicht alle ben\u00d6tigten Daten eingegeben.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Oct 15 09:31:50 2012 +0200
@@ -287,6 +287,7 @@
 error_read_minmax_values = Error while reading min/max values for the location input.
 error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2.
 error_validate_date_range = Start date needs to be before end date.
+error_validate_date_range_invalid = The specified timerange is invalid.
 error_validate_lower_range = The lower value $1 needs to be bigger than $2.
 error_validate_upper_range = The upper value $1 needs to be smaller than $2.
 error_empty_state = Required inputs are missing.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java	Mon Oct 15 09:31:50 2012 +0200
@@ -47,6 +47,10 @@
 
     protected DateRangeItem dateRange;
 
+    protected Long maxUpper;
+    protected Long maxLower;
+
+
     public GaugeTimeRangePanel() {
         GWT.log("Creating YearInputPanel");
         yearTable = new ListGrid();
@@ -54,7 +58,24 @@
         yearTable.setShowHeaderContextMenu(false);
     }
 
-    @Override
+    protected void setMaxUpper(DataList dataList) {
+        LongRangeData range = (LongRangeData) dataList.get(0);
+        setMaxUpper((Long) range.getUpper());
+    }
+
+    protected void setMaxUpper(Long maxUpper) {
+        this.maxUpper = maxUpper;
+    }
+
+    protected void setMaxLower(DataList dataList) {
+        LongRangeData range = (LongRangeData) dataList.get(0);
+        setMaxLower((Long) range.getLower());
+    }
+
+    protected void setMaxLower(Long maxLower) {
+        this.maxLower = maxLower;
+    }
+
     public Canvas create(DataList data) {
         setDataName(data);
 
@@ -76,6 +97,10 @@
         yearTable.setDataSource(new DischargeInfoDataSource(url, gauge));
 
         helperContainer.addMember(yearTable);
+
+        setMaxUpper(data);
+        setMaxLower(data);
+
         return root;
     }
 
@@ -94,6 +119,7 @@
     public Canvas createOld(DataList dataList) {
         GWT.log("create old date.");
         Data       data  = dataList.get(0);
+        DataItem[] items = data.getItems();
 
         HLayout layout = new HLayout();
 
@@ -144,8 +170,7 @@
 
     @Override
     public Object getMaxLower() {
-        Date d = dateRange.getFromDate();
-        return new Long(d.getTime());
+        return maxLower;
     }
 
 
@@ -330,13 +355,30 @@
     @Override
     public List<String> validate() {
         List<String> errors = new ArrayList<String>();
-        if (dateRange.getFromDate() == null ||
-            dateRange.getToDate() == null ||
-            !dateRange.getFromDate().before(dateRange.getToDate()))
-        {
+
+        Date from = dateRange.getFromDate();
+        Date to   = dateRange.getToDate();
+
+        if (from == null || to == null) {
             String msg = MSG.error_validate_date_range();
             errors.add(msg);
         }
+
+        long maxLow = (Long) getMaxLower();
+        long maxUpper = (Long) getMaxUpper();
+        long inLow = from.getTime();
+        long inUpper = to.getTime();
+
+        if (inLow < maxLow) {
+            errors.add(MSG.error_validate_date_range_invalid());
+        }
+        else if (inUpper > maxUpper) {
+            errors.add(MSG.error_validate_date_range_invalid());
+        }
+        else if (inLow > inUpper) {
+            errors.add(MSG.error_validate_date_range_invalid());
+        }
+
         return errors;
     }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Mon Oct 15 00:04:35 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Mon Oct 15 09:31:50 2012 +0200
@@ -28,6 +28,7 @@
 import de.intevation.flys.client.shared.model.IntegerArrayData;
 import de.intevation.flys.client.shared.model.IntegerRangeData;
 import de.intevation.flys.client.shared.model.IntegerOptionsData;
+import de.intevation.flys.client.shared.model.LongRangeData;
 import de.intevation.flys.client.shared.model.OutputMode;
 import de.intevation.flys.client.shared.model.Recommendation;
 import de.intevation.flys.client.shared.model.WQDataItem;
@@ -177,6 +178,29 @@
                     logger.warn("NumberFormatException: ", nfe);
                 }
             }
+            else if (type.equals("longrange")) {
+                String min = ClientProtocolUtils.getMinNode(d);
+                String max = ClientProtocolUtils.getMaxNode(d);
+
+                String defMin = ClientProtocolUtils.getDefMin(d);
+                String defMax = ClientProtocolUtils.getDefMax(d);
+
+                try {
+                    long lower = Long.valueOf(min);
+                    long upper = Long.valueOf(max);
+
+                    if (defMin != null && defMax != null) {
+                        list.add(new LongRangeData(
+                                name, label,
+                                lower, upper,
+                                Long.valueOf(defMin),
+                                Long.valueOf(defMax)));
+                    }
+                }
+                catch (NumberFormatException nfe) {
+                    logger.warn("NumberFormatException: ", nfe);
+                }
+            }
             else if (type.equals("intarray")) {
                 list.add(new IntegerArrayData(name, label, null));
             }

http://dive4elements.wald.intevation.org