From a3ea5b10378a349489a26b8d6988028efbe40c0b Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 12 Aug 2008 07:00:09 +0000 Subject: [PATCH] fixes #1737 (Method for components to request whole screen re-layout + imgage embeddeds now using it) svn changeset:5171/svn branch:trunk --- .../gwt/client/ApplicationConnection.java | 29 +++++++++++++++++++ .../terminal/gwt/client/ui/IEmbedded.java | 17 ++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index cac9725730..3516b0a5f7 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -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); + } } diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java index d1df5601e8..9519b08c86 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java @@ -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(""); - 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(); + } + } } -- 2.39.5