diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2007-11-29 14:47:36 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2007-11-29 14:47:36 +0000 |
commit | f2e2e833db2b4b40a6332535f821956829820d6d (patch) | |
tree | df852fc8eb38a6f13b3e272f2a87e919e0b3e776 | |
parent | 73f7a9df0d8f2aced517b6d177ec68a93af2d5f3 (diff) | |
download | vaadin-framework-f2e2e833db2b4b40a6332535f821956829820d6d.tar.gz vaadin-framework-f2e2e833db2b4b40a6332535f821956829820d6d.zip |
dirty components list was previously only sorted by windows, but needs to be ordered by all parent - children relations
svn changeset:3044/svn branch:trunk
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index f72a655996..30ee4e66f4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -74,6 +74,7 @@ import com.itmill.toolkit.terminal.UploadStream; import com.itmill.toolkit.terminal.VariableOwner; import com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent; import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.ComponentContainer; import com.itmill.toolkit.ui.Upload; import com.itmill.toolkit.ui.Window; @@ -305,24 +306,18 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // Creates "working copy" of the current state. List currentPaintables = new ArrayList(paintables); - // Sorts the paintable so that parent windows - // are always painted before child windows + // Sorts the Paintable list so that parents + // are always painted before children Collections.sort(currentPaintables, new Comparator() { - public int compare(Object o1, Object o2) { - - // If first argumement is now window - // the second is "smaller" if it is. - if (!(o1 instanceof Window)) { - return (o2 instanceof Window) ? 1 : 0; - } - - // Now, if second is not window the - // first is smaller. - if (!(o2 instanceof Window)) { + Component c1 = (Component) o1; + Component c2 = (Component) o2; + if (isChildOf(c1, c2)) { return -1; } - + if (isChildOf(c2, c1)) { + return 1; + } return 0; } }); @@ -347,6 +342,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, * Component requested repaint, but is no // longer * attached: skip paintablePainted(p); continue; } } */ + + // TODO we may still get changes that have been + // rendered already (changes with only cached flag) paintTarget.startTag("change"); paintTarget.addAttribute("format", "uidl"); String pid = getPaintableId(p); @@ -1105,4 +1103,24 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, } } + /** + * Helper method to test if a component contains another + * + * @param parent + * @param child + */ + private static boolean isChildOf(Component parent, Component child) { + if (parent instanceof ComponentContainer) { + Component p; + p = child.getParent(); + while (p != null) { + if (parent == p) { + return true; + } + p = p.getParent(); + } + } + return false; + } + } |