diff flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java @ 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 e703555f8da1
children 03de5c424f95
line wrap: on
line diff
--- 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