[Dive4elements-commits] [PATCH 1 of 3] d4e/client: Map preview in DigitizePanel is now properly resized (as long as the project is not reopened)

Wald Commits scm-commit at wald.intevation.org
Wed Apr 3 16:00:24 CEST 2013


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1364218599 -3600
# Node ID ef32ab3c16794eeb75ae1f8e4188691d3ad8797d
# Parent  7eb6e1f16e9df7b146d6a6ad67f625caa609037d
d4e/client: Map preview in DigitizePanel is now properly resized (as long as the project is not reopened).

diff -r 7eb6e1f16e9d -r ef32ab3c1679 flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Mon Mar 25 12:41:00 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Mon Mar 25 14:36:39 2013 +0100
@@ -1,19 +1,16 @@
 package de.intevation.flys.client.client.ui;
 
-import java.util.List;
-
-import org.gwtopenmaps.openlayers.client.Map;
-import org.gwtopenmaps.openlayers.client.control.Attribution;
-import org.gwtopenmaps.openlayers.client.layer.WMS;
-import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
-import org.gwtopenmaps.openlayers.client.layer.WMSParams;
-
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
+
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
+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.events.VisibilityChangedEvent;
 import com.smartgwt.client.widgets.events.VisibilityChangedHandler;
 import com.smartgwt.client.widgets.layout.VLayout;
@@ -34,6 +31,14 @@
 import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.MapInfo;
 
+import java.util.List;
+
+import org.gwtopenmaps.openlayers.client.Map;
+import org.gwtopenmaps.openlayers.client.control.Attribution;
+import org.gwtopenmaps.openlayers.client.layer.WMS;
+import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
+import org.gwtopenmaps.openlayers.client.layer.WMSParams;
+
 
 public class DigitizePanel
 extends SelectProvider
@@ -58,7 +63,7 @@
 
     @Override
     public Canvas create(DataList list) {
-        List<Data> data = list.getAll();
+        List<Data> data = list.getAll(); // FIXME: data is not used? getAll() side-effects?
         helperContainer.addVisibilityChangedHandler(this);
 
         DataList clone = (DataList) list.clone();
@@ -150,7 +155,22 @@
         floodMap = mapPanel.getFloodMap();
         Map map  = floodMap.getMap();
 
+        helperContainer.addResizedHandler(new ResizedHandler() {
+
+            @Override
+            public void onResized(ResizedEvent event) {
+                mapPanel.doLayout(helperContainer.getWidth(), helperContainer.getHeight());
+            }
+        });
+        helperContainer.addParentMovedHandler(new ParentMovedHandler() {
+
+            @Override
+            public void onParentMoved(ParentMovedEvent event) {
+                mapPanel.updateSize();
+            }
+        });
         helperContainer.addMember(mapPanel);
+        //helperContainer.setSize(helperContainer.getWidthAsString()(), helperContainer.getHeightAsString()());
 
         parameterList.registerCollectionViewTabHandler(this);
 
diff -r 7eb6e1f16e9d -r ef32ab3c1679 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	Mon Mar 25 12:41:00 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Mon Mar 25 14:36:39 2013 +0100
@@ -1,11 +1,7 @@
 package de.intevation.flys.client.client.ui.map;
 
 import com.google.gwt.core.client.GWT;
-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;
+import com.google.gwt.user.client.ui.AbsolutePanel;
 
 import de.intevation.flys.client.shared.model.BBox;
 import de.intevation.flys.client.shared.model.MapInfo;
@@ -17,7 +13,7 @@
  * Panel that contains a MapWidget and a MapToolbar.
  * This panel is used by the flood map calculation input helper.
  */
-public class MapPanel extends VLayout {
+public class MapPanel extends AbsolutePanel {
 
     protected MapToolbar      toolbar;
 
@@ -43,33 +39,23 @@
 
 
     private void initLayout() {
-        setWidth100();
-        setHeight100();
+        setWidth("100%");
+        setHeight("100%");
 
         floodMapWidget = floodMap.getMapWidget();
         toolbar = new MapToolbar(floodMap, digitizeEnabled);
 
-        addMember(toolbar);
-        addMember(floodMapWidget);
-
-        addResizedHandler(new ResizedHandler() {
-            @Override
-            public void onResized(ResizedEvent event) {
-                doLayout();
-            }
-        });
-
-        addParentMovedHandler(new ParentMovedHandler() {
-            @Override
-            public void onParentMoved(ParentMovedEvent event) {
-                floodMapWidget.getMap().updateSize();
-            }
-        });
+        add(toolbar);
+        add(floodMapWidget);
     }
 
-    protected void doLayout() {
-        int width = getWidth();
-        int height = getHeight();
+    public void updateSize() {
+        floodMapWidget.getMap().updateSize();
+    }
+
+    public void doLayout(int w, int h) {
+        int width = w;
+        int height = h;
         GWT.log("MapPanel.size: " + width + "x" + height);
 
         width -= 2; // minus black borders


More information about the Dive4elements-commits mailing list