changeset 3994:cc0b31dc2789

fix issue898 (crash when no param selected for parametermatrix).
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 01 Oct 2012 09:39:26 +0200
parents 7d056b7a50d8
children 22981503ff81
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/ParameterMatrixPanel.java
diffstat 6 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Oct 01 08:54:44 2012 +0200
+++ b/flys-client/ChangeLog	Mon Oct 01 09:39:26 2012 +0200
@@ -1,3 +1,16 @@
+2012-10-01	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Fix issue898 (crash when no param selected).
+
+	* flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java
+	  (validate): implemented.
+
+	* 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:
+	  i18n for error message.
+
 2012-09-30	Christian Lins	<christian.lins@intevation.de>
 
 	* flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Oct 01 08:54:44 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Oct 01 09:39:26 2012 +0200
@@ -684,6 +684,8 @@
 
     String error_update_collection_attribute();
 
+    String error_values_needed();
+
     // MAP RELATED STRINGS
 
     String digitize();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Oct 01 08:54:44 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Oct 01 09:39:26 2012 +0200
@@ -346,6 +346,7 @@
 error_same_location = Reference location equals selected location.
 error_contains_same_location = Target locations contains reference location.
 error_update_collection_attribute = Error while updating the collection attribut
+error_values_needed = You must provide values.
 error_no_module_found = No modules found
 
 ## map related strings
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Oct 01 08:54:44 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Oct 01 09:39:26 2012 +0200
@@ -345,6 +345,7 @@
 error_same_location = Der gewählte Ort ist der Bezugsort.
 error_contains_same_location = Zielorte beinhalten den Bezugsort.
 error_update_collection_attribute = Fehler beim Aktualisieren des Collection-Attributs.
+error_values_needed = Es muss mindestens ein Wert selektiert sein.
 error_no_module_found = Keine nutzbaren Module gefunden.
 
 ## map related strings
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Oct 01 08:54:44 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Oct 01 09:39:26 2012 +0200
@@ -346,6 +346,7 @@
 error_same_location = Reference location equals selected location.
 error_contains_same_location = Target locations contains reference location.
 error_update_collection_attribute = Error while updating the collection attribut
+error_values_needed = You must provide values.
 error_no_module_found = No modules found
 
 ## map related strings
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Mon Oct 01 08:54:44 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrixPanel.java	Mon Oct 01 09:39:26 2012 +0200
@@ -1,9 +1,12 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.google.gwt.core.client.GWT;
+
 import com.google.gwt.user.client.ui.HTML;
 
 import com.smartgwt.client.widgets.Canvas;
@@ -24,6 +27,9 @@
  */
 public class ParameterMatrixPanel extends AbstractUIProvider {
 
+    /** The message class that provides i18n strings. */
+    protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
+
     private ParameterMatrix matrix;
 
     @Override
@@ -160,5 +166,21 @@
 
         return label;
     }
+
+
+    /** Selection shall not be empty. */
+    @Override
+    public List<String> validate() {
+        GWT.log ("validation. validation. validation. ");
+        List<String> errors = new ArrayList<String>();
+        // Early stop on one (only) error.
+        for (Map.Entry<String, List<String>> entry : matrix.getSelection().entrySet()) {
+                if (entry.getValue() == null || entry.getValue().size() == 0) {
+                    errors.add(MESSAGES.error_values_needed());
+                    return errors;
+                }
+        }
+        return errors;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org