]> source.dussan.org Git - vaadin-framework.git/commitdiff
dirty components list was previously only sorted by windows, but needs to be ordered...
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 29 Nov 2007 14:47:36 +0000 (14:47 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 29 Nov 2007 14:47:36 +0000 (14:47 +0000)
svn changeset:3044/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java

index f72a655996b4fc7a6a4f4e5db2b28089f24dab6e..30ee4e66f441f8bd70d2afc3329a844b8393a1da 100644 (file)
@@ -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;
+    }
+
 }