changeset 3539:091397efaca5

Issue 791: Do not allow the same values in reference and target location. flys-client/trunk@5352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 04 Sep 2012 09:19:33 +0000
parents 9f8f941351b1
children 98fac4872ae6
files flys-client/ChangeLog 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/MultipleLocationPanel.java
diffstat 6 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Sep 04 07:14:29 2012 +0000
+++ b/flys-client/ChangeLog	Tue Sep 04 09:19:33 2012 +0000
@@ -1,3 +1,16 @@
+2012-09-04  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Issue 791.
+
+	* src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java:
+	  Do not allow the same values in reference and target location.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
+	  Added i18n strings.
+
 2012-09-04	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Partial fix for issue820.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Tue Sep 04 07:14:29 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Tue Sep 04 09:19:33 2012 +0000
@@ -635,6 +635,10 @@
 
     String top_edge();
 
+    String error_same_location();
+
+    String error_contains_same_location();
+
     // MAP RELATED STRINGS
 
     String digitize();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Tue Sep 04 07:14:29 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Tue Sep 04 09:19:33 2012 +0000
@@ -322,6 +322,8 @@
 error_bad_dgm_river = You have selected a DEM for a wrong river.
 error_dialog_not_valid = One or more values are not valid.
 error_invalid_date = The entered date is not valid.
+error_same_location = Reference location equals selected location.
+error_contains_same_location = Target locations contains reference location.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Tue Sep 04 07:14:29 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Tue Sep 04 09:19:33 2012 +0000
@@ -322,6 +322,8 @@
 error_bad_dgm_river = Das gew\u00e4hlte DGM passt nicht zum gew\u00e4hlten Fluss.
 error_dialog_not_valid = Eine oder mehrere Daten sind nicht korrekt.
 error_invalid_date = Das eingegebene Datum ist nicht korrekt.
+error_same_location = Der gewählte Ort ist der Bezugsort.
+error_contains_same_location = Zielorte beinhalten den Bezugsort.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Tue Sep 04 07:14:29 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Tue Sep 04 09:19:33 2012 +0000
@@ -323,6 +323,8 @@
 error_bad_dgm_river = You have selected a DEM for a wrong river.
 error_dialog_not_valid = One or more values are not valid.
 error_invalid_date = The entered date is not valid.
+error_same_location = Reference location equals selected location.
+error_contains_same_location = Target locations contains reference location.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java	Tue Sep 04 07:14:29 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java	Tue Sep 04 09:19:33 2012 +0000
@@ -171,7 +171,7 @@
         locationPanel = new DoubleArrayPanel(
             MSG.unitLocation(),
             getLocationValues(),
-            new BlurHandler(){public void onBlur(BlurEvent be) {}});
+            new BlurHandler(){public void onBlur(BlurEvent be) {validate();}});
 
         picker.getLocationTable().setAutoFetchData(true);
 
@@ -197,6 +197,9 @@
         List<String> errors = new ArrayList<String>();
         NumberFormat nf     = NumberFormat.getDecimalFormat();
 
+        DataList[] ref = artifact.getArtifactDescription().getOldData();
+        String mode = ref[1].get(0).getStringValue();
+
         saveLocationValues(locationPanel);
 
         if (!locationPanel.validateForm()) {
@@ -208,7 +211,14 @@
         double[] good   = new double[lValues.length];
         int      idx    = 0;
 
+        double reference =
+            Double.valueOf(ref[2].get(0).getStringValue()).doubleValue();
         for (double value: lValues) {
+            if (mode.equals("calc.reference.curve") &&
+                value == reference) {
+                errors.add(MSG.error_contains_same_location());
+                return errors;
+            }
             if (value < min || value > max) {
                 String tmp = MSG.error_validate_range();
                 tmp = tmp.replace("$1", nf.format(value));
@@ -315,6 +325,17 @@
         catch(NumberFormatException nfe) {
             // Is there anything else to do here?
         }
+
+        // compare reference location and target location.
+        DataList[] ref = artifact.getArtifactDescription().getOldData();
+        String mode = ref[1].get(0).getStringValue();
+        if (mode.equals("calc.reference.curve") &&
+            ref[2].get(0).getStringValue().equals(record.getAttribute("from")))
+        {
+            SC.warn(MSG.error_same_location());
+            return;
+        }
+
         setLocationValues(selected);
     }
 

http://dive4elements.wald.intevation.org