}
}
+ /*
+ * 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);
+ }
}
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;
private String width;
private Element browserElement;
+ private ApplicationConnection client;
+
public IEmbedded() {
setStyleName(CLASSNAME);
}
if (client.updateComponent(this, uidl, true)) {
return;
}
+ this.client = client;
boolean clearBrowserElement = true;
} 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) {
}
super.onDetach();
}
+
+ public void onBrowserEvent(Event event) {
+ super.onBrowserEvent(event);
+ if (DOM.eventGetType(event) == Event.ONLOAD) {
+ client.requestLayoutPhase();
+ }
+ }
}