changeset 520:9e2b151770bd

Bugfix in the range/location panel - avoid NullPointerExceptions in getData(). flys-client/trunk@1999 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 25 May 2011 07:05:22 +0000 (2011-05-25)
parents 77234b1d009c
children fc60822e9c89
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java
diffstat 2 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue May 24 16:22:34 2011 +0000
+++ b/flys-client/ChangeLog	Wed May 25 07:05:22 2011 +0000
@@ -1,3 +1,11 @@
+2011-05-25  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java:
+	  Bugfix: We return the inserted values only in getData(). We do not
+	  return Data objects with no value. This prevents NullPointerExceptions
+	  that occur if no location has been inserted - e.g. the case if we
+	  selected a range.
+
 2011-05-24  Ingo Weinzierl <ingo@intevation.de>
 
 	  ISSUE-91
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java	Tue May 24 16:22:34 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java	Wed May 25 07:05:22 2011 +0000
@@ -1,5 +1,6 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 
@@ -561,12 +562,35 @@
             }
         }
 
-        return new Data[] {
-            getDataMode(),
-            getDataLocations(),
-            getDataFrom(),
-            getDataTo(),
-            getDataStep() };
+        Data dMode      = getDataMode();
+        Data dLocations = getDataLocations();
+        Data dFrom      = getDataFrom();
+        Data dTo        = getDataTo();
+        Data dStep      = getDataStep();
+
+        List<Data> data = new ArrayList<Data>();
+
+        if (dMode != null) {
+            data.add(dMode);
+        }
+
+        if (dLocations != null) {
+            data.add(dLocations);
+        }
+
+        if (dFrom != null) {
+            data.add(dFrom);
+        }
+
+        if (dTo != null) {
+            data.add(dTo);
+        }
+
+        if (dStep != null) {
+            data.add(dStep);
+        }
+
+        return (Data[]) data.toArray(new Data[data.size()]);
     }
 
 
@@ -586,6 +610,10 @@
         double[] locations = getLocationValues();
         boolean  first     = true;
 
+        if (locations == null) {
+            return null;
+        }
+
         StringBuilder sb = new StringBuilder();
 
         for (double l: locations) {

http://dive4elements.wald.intevation.org