# HG changeset patch # User Ingo Weinzierl # Date 1306307122 0 # Node ID 9e2b151770bd98fca259845d2662447e7ae77e86 # Parent 77234b1d009c386cbaeb069f0e6d8e751be51a08 Bugfix in the range/location panel - avoid NullPointerExceptions in getData(). flys-client/trunk@1999 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 77234b1d009c -r 9e2b151770bd flys-client/ChangeLog --- 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 + + * 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 ISSUE-91 diff -r 77234b1d009c -r 9e2b151770bd flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java --- 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 = new ArrayList(); + + 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) {