changeset 9561:5397555d74c9

MapOutputTab fix
author gernotbelger
date Thu, 25 Oct 2018 17:00:58 +0200
parents a39ae474f8d5
children 2b1626fa4a95
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/FloodMap.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java
diffstat 3 files changed, 41 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- 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();
     }
 
--- 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 :
--- 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 (initial == null) {
-                    GWT.log("Warning: No initial extent set.");
-                    initial = max;
-                }
+                if (!MapOutputTab.this.cancel) {
+                    final Bounds max = boundsFromString(c.getMaxExtent());
+                    Bounds initial = boundsFromString(c.getInitialExtent());
 
-                setFloodmap(new FloodMap(c.getSrid(), max, 640, 480));
+                    if (initial == null) {
+                        GWT.log("Warning: No initial extent set.");
+                        initial = max;
+                    }
 
-                initLayout();
-                initBarriers();
+                    setFloodmap(new FloodMap(c.getSrid(), max, 640, 480));
 
-                GWT.log("MAX EXTENT: " + max);
-                GWT.log("ZOOM TO: " + initial);
-                getMap().zoomToExtent(initial);
+                    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();

http://dive4elements.wald.intevation.org