changeset 2475:d77b1e489df7

Issue 492. Validate axis scale in chart properties dialog. flys-client/trunk@4214 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 11 Apr 2012 11:44:45 +0000
parents 6f7e188fac1a
children e8c4f8f2220e
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Apr 11 08:21:53 2012 +0000
+++ b/flys-client/ChangeLog	Wed Apr 11 11:44:45 2012 +0000
@@ -1,3 +1,11 @@
+2012-04-11  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Issue 492.
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java:
+	  Added axis validation. Same values in fields 'from' and 'to' in axis
+	  scale are not allowed.
+
 2012-04-11  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java	Wed Apr 11 08:21:53 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java	Wed Apr 11 11:44:45 2012 +0000
@@ -201,6 +201,7 @@
             DoubleProperty upper =
                 (DoubleProperty)pg.getPropertyByName("upper");
             final FormItem range1 = createDoubleProperty(upper);
+            range1.setName("rangeupper");
             range1.setWidth(70);
             range1.setValue(
                 ((DoubleProperty)
@@ -209,6 +210,7 @@
             DoubleProperty lower =
                 (DoubleProperty)pg.getPropertyByName("lower");
             final FormItem range2 = createDoubleProperty(lower);
+            range2.setName("rangelower");
             range2.setWidth(70);
             range2.setValue(
                 ((DoubleProperty)
@@ -453,6 +455,14 @@
         boolean valid = true;
         if(c instanceof DynamicForm) {
             DynamicForm f = (DynamicForm) c;
+            FormItem up = f.getItem("rangeupper");
+            FormItem lo = f.getItem("rangelower");
+
+            if(up != null && lo != null &&
+               !up.isDisabled() && !lo.isDisabled())
+            {
+                validateRange(f);
+            }
             return !f.hasErrors();
         }
         else if(c.getChildren().length > 0) {
@@ -465,5 +475,22 @@
         }
         return valid;
     }
+
+    protected boolean validateRange(DynamicForm form) {
+        Map errors = form.getErrors();
+        FormItem up = form.getItem("rangeupper");
+        FormItem lo = form.getItem("rangelower");
+
+        String v1 = up.getValue().toString();
+        String v2 = lo.getValue().toString();
+
+        if(v1.equals(v2)) {
+            errors.put(up.getFieldName(), MSG.wrongFormat());
+            errors.put(lo.getFieldName(), MSG.wrongFormat());
+            form.setErrors(errors, true);
+            return false;
+        }
+        return true;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org