[PATCH] MapOutputTab fix

Wald Commits scm-commit at wald.intevation.org
Thu Oct 25 17:01:03 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1540479658 -7200
# Node ID 5397555d74c948481cdf18ea7bfeccb2affe8525
# Parent  a39ae474f8d573f89f07233865be60e8a8bb6854
MapOutputTab fix

diff -r a39ae474f8d5 -r 5397555d74c9 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java	Thu Oct 25 09:38:11 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java	Thu Oct 25 17:00:58 2018 +0200
@@ -36,6 +36,7 @@
 import org.dive4elements.river.client.client.services.DescribeCollectionServiceAsync;
 import org.dive4elements.river.client.client.services.LoadArtifactService;
 import org.dive4elements.river.client.client.services.LoadArtifactServiceAsync;
+import org.dive4elements.river.client.client.ui.map.MapOutputTab;
 import org.dive4elements.river.client.shared.model.Artifact;
 import org.dive4elements.river.client.shared.model.ArtifactDescription;
 import org.dive4elements.river.client.shared.model.Collection;
@@ -478,15 +479,9 @@
             // we don't want to display report modes at all
             return;
         } else if (out instanceof MapMode) {
-            // Der Workflow von dem ganzen ist derart merkwürdig. Ständig werden Tabs entfernt und wieder hinzugefügt,
-            // alles wird neu erzeugt und wieder entfernt.
-            // normalerweise klappt das auch ("tabset.remove")
-            // beim Karten-Tab komischerweise nicht.
-            // Diese Sonderbehandlung "löst" das Problem der Doppelten Karten-Tabs mit nur wenigen zusätzlichen Zeilen
-            // (neuer Member "tabNames" )
-            // Wenn die Liste den Namen schon enthält, wird der Tab einfach nicht nochmal erzeugt.
-            if (this.tabNames.contains("map"))
-                return;
+            // this workaround is not needed anymore - it is now in clearOuputTabs
+            // if (this.tabNames.contains("map"))
+            // return;
         }
 
         GWT.log("Add new output tab for '" + name + "'");
@@ -507,9 +502,12 @@
         final int num = this.tabs.getNumTabs();
 
         for (int i = num - 1; i >= 1; i--) {
-            this.tabs.removeTab(i); // does not work for the Maps-panel
+            if (this.tabs.getTab(i) instanceof MapOutputTab) {
+                final MapOutputTab mot = (MapOutputTab) this.tabs.getTab(i);
+                mot.cancelMapService(); // MapOutputTab needs special treatment
+            }
+            this.tabs.removeTab(i);
         }
-
         this.outputTabs.clear();
     }
 
diff -r a39ae474f8d5 -r 5397555d74c9 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/FloodMap.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/FloodMap.java	Thu Oct 25 09:38:11 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/FloodMap.java	Thu Oct 25 17:00:58 2018 +0200
@@ -334,5 +334,11 @@
             this.map.removeControl(scaleLine);
         }
     }
+
+
+    public void destroy() {
+        if( this.map != null)
+            this.map.destroy();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r a39ae474f8d5 -r 5397555d74c9 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java	Thu Oct 25 09:38:11 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java	Thu Oct 25 17:00:58 2018 +0200
@@ -97,6 +97,8 @@
     protected AbsolutePanel absPan = new AbsolutePanel();
     protected FloodMap floodMap;
 
+    private boolean cancel = false;
+
     private final java.util.Map<String, String> wmsUrls = new HashMap<String, String>();
 
     public MapOutputTab(final String title, final Collection collection, final OutputMode mode, final CollectionView collectionView) {
@@ -114,26 +116,37 @@
             public void onSuccess(final MapConfig c) {
                 GWT.log("MAP SUCCESS!");
 
-                final Bounds max = boundsFromString(c.getMaxExtent());
-                Bounds initial = boundsFromString(c.getInitialExtent());
+                if (!MapOutputTab.this.cancel) {
+                    final Bounds max = boundsFromString(c.getMaxExtent());
+                    Bounds initial = boundsFromString(c.getInitialExtent());
 
-                if (initial == null) {
-                    GWT.log("Warning: No initial extent set.");
-                    initial = max;
+                    if (initial == null) {
+                        GWT.log("Warning: No initial extent set.");
+                        initial = max;
+                    }
+
+                    setFloodmap(new FloodMap(c.getSrid(), max, 640, 480));
+
+                    initLayout();
+
+                    initBarriers();
+
+                    GWT.log("MAX EXTENT: " + max);
+                    GWT.log("ZOOM TO: " + initial);
+                    getMap().zoomToExtent(initial);
                 }
-
-                setFloodmap(new FloodMap(c.getSrid(), max, 640, 480));
-
-                initLayout();
-                initBarriers();
-
-                GWT.log("MAX EXTENT: " + max);
-                GWT.log("ZOOM TO: " + initial);
-                getMap().zoomToExtent(initial);
             }
         });
     }
 
+    public void cancelMapService() {
+
+        this.cancel = true;
+
+        // if (this.floodMap != null)
+        // this.floodMap.destroy();
+    }
+
     protected void initLayout() {
         this.rootLayout.setHeight100();
         this.rootLayout.setWidth100();


More information about the Dive4Elements-commits mailing list