From 3588a2fad586f1ec05b4381e66ddc4a1446483a7 Mon Sep 17 00:00:00 2001
From: Henri Sara
* Each paintable being painted should be closed by a matching - * {@link #endPaintable(Paintable)}. + * {@link #endPaintable(Paintable)} regardless of the {@link PaintStatus} + * returned. *
* * @param paintable * the paintable to start. * @param tag * the name of the start tag. - * @returntrue
if paintable found in cache, false
- * otherwise.
+ * @return {@link PaintStatus} - ready to paint, already cached on the
+ * client or defer painting to another change
* @throws PaintException
* if the paint operation failed.
* @see #startTag(String)
* @since 7.0 (previously using startTag(Paintable, String))
*/
- public boolean startPaintable(Paintable paintable, String tag)
+ public PaintStatus startPaintable(Paintable paintable, String tag)
throws PaintException;
/**
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 1415e8a0ff..b41b4f1b3c 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -1865,6 +1865,8 @@ public class ApplicationConnection {
*/
public VPaintableWidget getPaintable(UIDL uidl) {
final String pid = uidl.getId();
+ // the actual content UIDL may be deferred, but it always contains
+ // enough information to create a paintable instance
if (!paintableMap.hasPaintable(pid)) {
// Create and register a new paintable if no old was found
VPaintableWidget p = widgetSet.createWidget(uidl.getTag(),
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
index 355516ccd1..746bc99ba4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
@@ -106,7 +106,8 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
}
protected static boolean isRealUpdate(UIDL uidl) {
- return !isCachedUpdate(uidl) && !uidl.getBooleanAttribute("invisible");
+ return !isCachedUpdate(uidl) && !uidl.getBooleanAttribute("invisible")
+ && !uidl.hasAttribute("deferred");
}
protected static boolean isCachedUpdate(UIDL uidl) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayoutPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayoutPaintable.java
index 752462dcf6..3a5030e606 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayoutPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/layout/CellBasedLayoutPaintable.java
@@ -15,25 +15,24 @@ public abstract class CellBasedLayoutPaintable extends
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
getWidgetForPaintable().client = client;
- // Only non-cached UIDL:s can introduce changes
- if (isCachedUpdate(uidl)) {
- return;
+ if (isRealUpdate(uidl)) {
+ /**
+ * Margin and spacing detection depends on classNames and must be
+ * set before setting size. Here just update the details from UIDL
+ * and from overridden setStyleName run actual margin detections.
+ */
+ updateMarginAndSpacingInfo(uidl);
}
- /**
- * Margin and spacind detection depends on classNames and must be set
- * before setting size. Here just update the details from UIDL and from
- * overridden setStyleName run actual margin detections.
- */
- updateMarginAndSpacingInfo(uidl);
-
/*
* This call should be made first. Ensure correct implementation, handle
* size etc.
*/
super.updateFromUIDL(uidl, client);
- handleDynamicDimensions(uidl);
+ if (isRealUpdate(uidl)) {
+ handleDynamicDimensions(uidl);
+ }
}
private void handleDynamicDimensions(UIDL uidl) {
@@ -58,18 +57,15 @@ public abstract class CellBasedLayoutPaintable extends
}
void updateMarginAndSpacingInfo(UIDL uidl) {
- if (!uidl.hasAttribute("invisible")) {
- int bitMask = uidl.getIntAttribute("margins");
- if (getWidgetForPaintable().activeMarginsInfo.getBitMask() != bitMask) {
- getWidgetForPaintable().activeMarginsInfo = new VMarginInfo(
- bitMask);
- getWidgetForPaintable().marginsNeedsRecalculation = true;
- }
- boolean spacing = uidl.getBooleanAttribute("spacing");
- if (spacing != getWidgetForPaintable().spacingEnabled) {
- getWidgetForPaintable().marginsNeedsRecalculation = true;
- getWidgetForPaintable().spacingEnabled = spacing;
- }
+ int bitMask = uidl.getIntAttribute("margins");
+ if (getWidgetForPaintable().activeMarginsInfo.getBitMask() != bitMask) {
+ getWidgetForPaintable().activeMarginsInfo = new VMarginInfo(bitMask);
+ getWidgetForPaintable().marginsNeedsRecalculation = true;
+ }
+ boolean spacing = uidl.getBooleanAttribute("spacing");
+ if (spacing != getWidgetForPaintable().spacingEnabled) {
+ getWidgetForPaintable().marginsNeedsRecalculation = true;
+ getWidgetForPaintable().spacingEnabled = spacing;
}
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 4421001a3f..7b75592442 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -856,12 +856,13 @@ public abstract class AbstractCommunicationManager implements
// rendered already (changes with only cached flag)
if (paintTarget.needsToBePainted(p)) {
paintTarget.startTag("change");
- paintTarget.addAttribute("format", "uidl");
final String pid = getPaintableId(p);
paintTarget.addAttribute("pid", pid);
- // TODO this should paint subcomponents as references and
- // defer painting their contents to another top-level change
+ // paints subcomponents as references (via
+ // JsonPaintTarget.startPaintable()) and defers painting
+ // their contents to another top-level change (via
+ // queuePaintable())
p.paint(paintTarget);
paintTarget.endTag("change");
diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
index 3f68577f8c..4470970095 100644
--- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
+++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java
@@ -11,6 +11,7 @@ import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -90,6 +91,8 @@ public class JsonPaintTarget implements PaintTarget {
private Collection