changeset 1502:d1223d93dd68

Issue 358. Validate dialog on accept. flys-client/trunk@3629 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 09 Jan 2012 14:28:37 +0000
parents d12cb71965cf
children 3304608baf35
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/chart/ChartPropertiesEditor.java
diffstat 6 files changed, 60 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Jan 09 09:50:37 2012 +0000
+++ b/flys-client/ChangeLog	Mon Jan 09 14:28:37 2012 +0000
@@ -1,3 +1,16 @@
+2012-01-09  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Issue 358. Validate dialog on accept.
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java:
+	  Validate all forms before updating the chart.
+
+	* 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 string for error message.
+
 2012-01-09  Raimund Renkert <raimund.renkert@intevation.de>
 
 	Issue 358. Axis range fix.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Jan 09 09:50:37 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Jan 09 14:28:37 2012 +0000
@@ -498,6 +498,7 @@
 
     String error_bad_dgm_river();
 
+    String error_dialog_not_valid();
 
 
     String bottom_edge();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Jan 09 09:50:37 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Jan 09 14:28:37 2012 +0000
@@ -259,6 +259,7 @@
 error_invalid_dgm_selected = You have selected an invalid DEM.
 error_bad_dgm_range = You have selected a DEM with an invalid range.
 error_bad_dgm_river = You have selected a DEM for a wrong river.
+error_dialog_not_valid = One or more values are not valid.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Jan 09 09:50:37 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Jan 09 14:28:37 2012 +0000
@@ -259,6 +259,7 @@
 error_invalid_dgm_selected = Sie haben ein falsches DGM gew\u00e4hlt.
 error_bad_dgm_range = Das gew\u00e4hlte DGM passt nicht zur gew\u00e4hlten Berechnungsstrecke.
 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.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Jan 09 09:50:37 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Jan 09 14:28:37 2012 +0000
@@ -259,6 +259,7 @@
 error_invalid_dgm_selected = You have selected an invalid DEM.
 error_bad_dgm_range = You have selected a DEM with an invalid range.
 error_bad_dgm_river = You have selected a DEM for a wrong river.
+error_dialog_not_valid = One or more values are not valid.
 
 ## map related strings
 digitize = images/digitize.png
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java	Mon Jan 09 09:50:37 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java	Mon Jan 09 14:28:37 2012 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.client.ui.chart;
 
 import java.util.List;
+import java.util.Map;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -123,7 +124,13 @@
         cancel.addClickHandler(this);
         accept.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent e) {
-                updateCollection();
+                if(isDialogValid()) {
+                    updateCollection();
+                }
+                else {
+                    GWT.log("Dialog not valid");
+                    SC.warn(MSG.error_dialog_not_valid());
+                }
             }
         });
 
@@ -404,4 +411,39 @@
         this.tab.updateChartInfo();
         this.tab.updateChartPanel();
     }
+
+
+    protected boolean isDialogValid() {
+        boolean valid = true;
+        for (int i = 0; i < tabs.getNumTabs(); i++) {
+            Tab t = tabs.getTab(i);
+            Canvas container = t.getPane();
+            Canvas[] children = container.getChildren();
+            for (Canvas c: children) {
+                valid = validateCanvas(c);
+                if(!valid) {
+                    return valid;
+                }
+            }
+        }
+        return valid;
+    }
+
+
+    protected boolean validateCanvas(Canvas c) {
+        boolean valid = true;
+        if(c instanceof DynamicForm) {
+            DynamicForm f = (DynamicForm) c;
+            return !f.hasErrors();
+        }
+        else if(c.getChildren().length > 0) {
+            for (Canvas child: c.getChildren()) {
+                valid = validateCanvas(child);
+                if(!valid) {
+                    return valid;
+                }
+            }
+        }
+        return valid;
+    }
 }

http://dive4elements.wald.intevation.org