]> source.dussan.org Git - vaadin-framework.git/commitdiff
Run a new layout phase after VScrollTable.sizeInit (#8313)
authorLeif Åstrand <leif@vaadin.com>
Tue, 13 Mar 2012 08:32:19 +0000 (10:32 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 13 Mar 2012 08:32:19 +0000 (10:32 +0200)
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/LayoutManager.java
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

index 869c387a2f23240e49d0787449789fe76c4900fd..7bd8199992530cb368b6b7a01c5dad922fdcbfe7 100644 (file)
@@ -2071,21 +2071,32 @@ public class ApplicationConnection {
                 eventIdentifier);
     }
 
-    private boolean layoutScheduled = false;
+    private boolean layoutPending = false;
     private ScheduledCommand layoutCommand = new ScheduledCommand() {
         public void execute() {
-            layoutScheduled = false;
-
-            layoutManager.doLayout();
+            /*
+             * Layout again if a new layout is requested while the current one
+             * is running.
+             */
+            while (layoutPending) {
+                layoutPending = false;
+                layoutManager.doLayout();
+            }
         }
     };
 
     public void doLayout(boolean lazy) {
+        layoutPending = true;
         if (!lazy) {
             layoutCommand.execute();
-        } else if (!layoutScheduled) {
-            layoutScheduled = true;
-            Scheduler.get().scheduleDeferred(layoutCommand);
+        } else if (!layoutPending) {
+            /*
+             * Current layoutCommand will do layouts again if layoutScheduled is
+             * set to true -> no need to schedule another command
+             */
+            if (!layoutManager.isLayoutRunning()) {
+                Scheduler.get().scheduleDeferred(layoutCommand);
+            }
         }
     }
 
index 3adfc017fd88a1627aafc32e1bc0fe740c2b12dd..44b652b5308a6cadf408face3723d5193832f376 100644 (file)
@@ -17,6 +17,7 @@ public class LayoutManager {
     private final ApplicationConnection connection;
     private final Set<Element> nonPaintableElements = new HashSet<Element>();
     private final MeasuredSize nullSize = new MeasuredSize();
+    private boolean layoutRunning = false;
 
     public LayoutManager(ApplicationConnection connection) {
         this.connection = connection;
@@ -101,8 +102,17 @@ public class LayoutManager {
         }
     }
 
+    public boolean isLayoutRunning() {
+        return layoutRunning;
+    }
+
     public void doLayout() {
+        if (layoutRunning) {
+            throw new IllegalStateException(
+                    "Can't start a new layout phase before the previous layout phase ends.");
+        }
         VConsole.log("Starting layout phase");
+        layoutRunning = true;
 
         ConnectorMap paintableMap = connection.getConnectorMap();
         ComponentConnector[] paintableWidgets = paintableMap
@@ -225,6 +235,7 @@ public class LayoutManager {
             }
         }
 
+        layoutRunning = false;
         VConsole.log("Total layout phase time: "
                 + totalDuration.elapsedMillis() + "ms");
     }
index 6a08ccb7dfc98a62752e24a7aa87ecf562d5b748..809a4dcb7228b826665634878a777cb6ffe72915 100644 (file)
@@ -1862,6 +1862,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
                 Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
             }
         });
+
+        client.doLayout(true);
     }
 
     /**
@@ -5511,7 +5513,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
                     scrollBodyPanel.setScrollPosition(scrollTop - 1);
                 }
 
-                sizeInit();
+                sizeNeedsInit = true;
             }
         }