[Dive4elements-commits] [PATCH] flys-client: Map.updateSize() is now called on every windows movement

Wald Commits scm-commit at wald.intevation.org
Tue Nov 20 14:30:44 CET 2012


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1353418233 -3600
# Node ID 8ca06d3040d012842599f90923bd1131bd4993b8
# Parent  276d9bd3c77d66af77b995e567cdd672856ab8d2
flys-client: Map.updateSize() is now called on every windows movement
which fixes the cursor offset problem (flys/#422).

diff -r 276d9bd3c77d -r 8ca06d3040d0 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Tue Nov 20 12:53:14 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Tue Nov 20 14:30:33 2012 +0100
@@ -3,9 +3,10 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.AbsolutePanel;
-
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.ParentMovedEvent;
+import com.smartgwt.client.widgets.events.ParentMovedHandler;
 import com.smartgwt.client.widgets.events.ResizedEvent;
 import com.smartgwt.client.widgets.events.ResizedHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
@@ -164,6 +165,13 @@
             }
         });
 
+        rootLayout.addParentMovedHandler(new ParentMovedHandler() {
+            @Override
+            public void onParentMoved(ParentMovedEvent event) {
+                mapPanel.getMap().updateSize();
+            }
+        });
+
         setPane(rootLayout);
     }
 
diff -r 276d9bd3c77d -r 8ca06d3040d0 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Tue Nov 20 12:53:14 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Tue Nov 20 14:30:33 2012 +0100
@@ -1,7 +1,10 @@
 package de.intevation.flys.client.client.ui.map;
 
 import com.google.gwt.core.client.GWT;
-
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.WidgetCanvas;
+import com.smartgwt.client.widgets.events.ParentMovedEvent;
+import com.smartgwt.client.widgets.events.ParentMovedHandler;
 import com.smartgwt.client.widgets.events.ResizedEvent;
 import com.smartgwt.client.widgets.events.ResizedHandler;
 import com.smartgwt.client.widgets.layout.VLayout;
@@ -52,14 +55,34 @@
         addMember(floodMapWidget);
 
         addResizedHandler(new ResizedHandler() {
-
             @Override
             public void onResized(ResizedEvent event) {
                 doLayout();
             }
         });
+
+        addParentMovedHandler(new ParentMovedHandler() {
+            @Override
+            public void onParentMoved(ParentMovedEvent event) {
+                floodMapWidget.getMap().updateSize();
+            }
+        });
     }
 
+    /**
+     * Due to the fact that SmartGWT Layout misses a removeMember(Widget)
+     * method we use this method to remove all WidgetCanvas members.
+     * WidgetCanvas is the wrapper class used by Layout to handle Widget
+     * objects.
+     */
+    protected void removeWidgetCanvasMember() {
+        Canvas[] allCanvas = getMembers();
+        for (Canvas canvas : allCanvas) {
+            if (canvas instanceof WidgetCanvas) {
+                removeMember(canvas);
+            }
+        }
+    }
 
     protected void doLayout() {
         int width = getWidth();
@@ -69,6 +92,12 @@
         width -= 2; // minus black borders
         height -= toolbar.getHeight() + 4;
 
+        // Recreate Map widget
+        /*removeWidgetCanvasMember();
+        floodMap.recreateWidget(width, height);
+        floodMapWidget = floodMap.getMapWidget();
+        addMember(floodMapWidget);
+*/
         floodMapWidget.setSize(Integer.toString(width), Integer.toString(height));
         floodMapWidget.getMap().updateSize();
     }


More information about the Dive4elements-commits mailing list