changeset 4182:ad2489b595d7

Fix for issue #967
author Christian Lins <christian.lins@intevation.de>
date Tue, 16 Oct 2012 12:44:15 +0200
parents 0182916dcb01
children 1755a1bfe5ce
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedHeightsDatacagePanel.java
diffstat 3 files changed, 34 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-client/ChangeLog	Tue Oct 16 12:44:15 2012 +0200
@@ -1,3 +1,11 @@
+2012-10-16	Christian Lins	<christian.lins@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java:
+	  Fix possible IndexOutOfBoundsException (#967)
+
+	* src/main/java/de/intevation/flys/client/client/ui/minfo/BedHeightsDatacagePanel.java:
+	  Cosmetics.	
+
 2012-10-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java	Tue Oct 16 12:44:15 2012 +0200
@@ -3,20 +3,19 @@
 import com.google.gwt.core.client.GWT;
 
 import com.smartgwt.client.widgets.Button;
-
-import com.smartgwt.client.widgets.layout.VLayout;
-import com.smartgwt.client.widgets.layout.HLayout;
-
-import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.events.ClickEvent;
-
+import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.grid.ListGrid;
-
-import de.intevation.flys.client.shared.model.Artifact;
-import de.intevation.flys.client.shared.model.User;
-import de.intevation.flys.client.shared.model.ToLoad;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.Recommendation;
+import de.intevation.flys.client.shared.model.ToLoad;
+import de.intevation.flys.client.shared.model.User;
+
+import java.util.List;
 
 
 /**
@@ -95,14 +94,18 @@
         ToLoad toLoad1 = firstDatacageWidget.getSelection();
         ToLoad toLoad2 = secondDatacageWidget.getSelection();
 
-        // TODO further sanitize (toRecommendations.length)
         if (toLoad1 == null || toLoad2 == null) {
             return;
         }
 
-        grid.addData(new RecommendationPairRecord(
-            toLoad1.toRecommendations().get(0),
-            toLoad2.toRecommendations().get(0)));
+        List<Recommendation> toLoad1Rec = toLoad1.toRecommendations();
+        List<Recommendation> toLoad2Rec = toLoad2.toRecommendations();
+
+        if (toLoad1Rec.size() <= 0 || toLoad2Rec.size() <= 0) {
+            return;
+        }
+
+        grid.addData(new RecommendationPairRecord(toLoad1Rec.get(0), toLoad2Rec.get(0)));
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedHeightsDatacagePanel.java	Tue Oct 16 12:25:48 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/BedHeightsDatacagePanel.java	Tue Oct 16 12:44:15 2012 +0200
@@ -1,44 +1,31 @@
 package de.intevation.flys.client.client.ui.minfo;
 
 import com.google.gwt.core.client.GWT;
-
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
 import com.smartgwt.client.data.Record;
-
 import com.smartgwt.client.widgets.Canvas;
-
 import com.smartgwt.client.widgets.events.ClickEvent;
-
 import com.smartgwt.client.widgets.grid.ListGridRecord;
-
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.FLYSConstants;
-
 import de.intevation.flys.client.client.event.StepForwardEvent;
-
-import de.intevation.flys.client.client.services.LoadArtifactService;
 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
-import de.intevation.flys.client.client.services.RemoveArtifactService;
 import de.intevation.flys.client.client.services.RemoveArtifactServiceAsync;
-
 import de.intevation.flys.client.client.ui.DatacagePairWidget;
 import de.intevation.flys.client.client.ui.DatacageTwinPanel;
 import de.intevation.flys.client.client.ui.RecommendationPairRecord;
-
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
 import de.intevation.flys.client.shared.model.DataList;
-
+import de.intevation.flys.client.shared.model.Recommendation;
 import de.intevation.flys.client.shared.model.Recommendation.Facet;
 import de.intevation.flys.client.shared.model.Recommendation.Filter;
-
-import de.intevation.flys.client.shared.model.Recommendation;
 import de.intevation.flys.client.shared.model.User;
 
 import java.util.ArrayList;
@@ -54,6 +41,7 @@
  */
 public class BedHeightsDatacagePanel
 extends      DatacageTwinPanel {
+    private static final long serialVersionUID = -4237734158851386530L;
 
     protected static FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
@@ -84,6 +72,7 @@
      * @param from string in format as shown above.
      * @return recommendation from input string.
      */
+    @Override
     public Recommendation createRecommendationFromString(String from) {
         // TODO Construct "real" filter.
         String[] parts = unbracket(from).split(";");
@@ -143,6 +132,7 @@
     /**
      * Add record to list of removed records.
      */
+    @Override
     public void trackRemoved(Record r) {
         RecommendationPairRecord pr = (RecommendationPairRecord) r;
         this.removedPairs.add(pr);
@@ -236,9 +226,11 @@
                 uuid,
                 locale,
                 new AsyncCallback<Collection>() {
+                    @Override
                     public void onFailure(Throwable caught) {
                         GWT.log("RemoveArtifact (" + uuid + ") failed.");
                     }
+                    @Override
                     public void onSuccess(Collection collection) {
                         GWT.log("RemoveArtifact succeeded");
                     }
@@ -253,9 +245,11 @@
             null,
             locale,
             new AsyncCallback<Artifact[]>() {
+                @Override
                 public void onFailure(Throwable caught) {
                     GWT.log("Failure of cloning with factories!");
                 }
+                @Override
                 public void onSuccess(Artifact[] artifacts) {
                     GWT.log("Successfully cloned " + toClone.length +
                         " with factories.");
@@ -272,6 +266,7 @@
      * @param artifact Artifacts UUID.
      * @param recommendation Recommendation to wrap in string.
      */
+    @Override
     protected String createDataString(
         String artifact,
         Recommendation recommendation)

http://dive4elements.wald.intevation.org