]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #1737 (Method for components to request whole screen re-layout + imgage embedde...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 12 Aug 2008 07:00:09 +0000 (07:00 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 12 Aug 2008 07:00:09 +0000 (07:00 +0000)
svn changeset:5171/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java

index cac97257308f4d00b14934f26eebba09401deedc..3516b0a5f79424d917e4c897d390413457b30f0f 100755 (executable)
@@ -983,4 +983,33 @@ public class ApplicationConnection {
         }
     }
 
+    /*
+     * Helper to run layout functions triggered by child components with a
+     * decent interval.
+     */
+    private final Timer layoutTimer = new Timer() {
+
+        private boolean isPending = false;
+
+        public void schedule(int delayMillis) {
+            if (!isPending) {
+                super.schedule(delayMillis);
+                isPending = true;
+            }
+        }
+
+        public void run() {
+            getConsole().log("Running re-layout");
+            Util.runDescendentsLayout(view);
+            isPending = false;
+        }
+    };
+
+    /**
+     * Components can call this function to run all layout functions. This is
+     * usually done, when component knows that its size has changed.
+     */
+    public void requestLayoutPhase() {
+        layoutTimer.schedule(500);
+    }
 }
index d1df5601e83b8a2478ebddb316eeb8eeaee62a57..9519b08c8610c87542cd8c9bf3b919b60d418e51 100644 (file)
@@ -6,6 +6,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.HTML;
 import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
@@ -18,6 +19,8 @@ public class IEmbedded extends HTML implements Paintable {
     private String width;
     private Element browserElement;
 
+    private ApplicationConnection client;
+
     public IEmbedded() {
         setStyleName(CLASSNAME);
     }
@@ -26,6 +29,7 @@ public class IEmbedded extends HTML implements Paintable {
         if (client.updateComponent(this, uidl, true)) {
             return;
         }
+        this.client = client;
 
         boolean clearBrowserElement = true;
 
@@ -44,9 +48,13 @@ public class IEmbedded extends HTML implements Paintable {
                 } else {
                     h = "";
                 }
+
                 setHTML("<img src=\"" + getSrc(uidl, client) + "\"" + w + h
                         + "/>");
-                client.addPngFix(DOM.getFirstChild(getElement()));
+
+                Element el = DOM.getFirstChild(getElement());
+                DOM.sinkEvents(el, Event.ONLOAD);
+                client.addPngFix(el);
 
             } else if (type.equals("browser")) {
                 if (browserElement == null) {
@@ -124,4 +132,11 @@ public class IEmbedded extends HTML implements Paintable {
         }
         super.onDetach();
     }
+
+    public void onBrowserEvent(Event event) {
+        super.onBrowserEvent(event);
+        if (DOM.eventGetType(event) == Event.ONLOAD) {
+            client.requestLayoutPhase();
+        }
+    }
 }