]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes pageLength=0 in TreeTable #7292
authorJohn Alhroos <john.ahlroos@itmill.com>
Fri, 19 Aug 2011 11:29:53 +0000 (11:29 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Fri, 19 Aug 2011 11:29:53 +0000 (11:29 +0000)
svn changeset:20506/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java

index f0db3e55b2a58077b663791a6fa53d43f1df2a86..a96ad3cb4ea012fb7e2bc4b21d859ea65c956db8 100644 (file)
@@ -884,7 +884,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     updateBody(rowData, uidl.getIntAttribute("firstrow"),
                             uidl.getIntAttribute("rows"));
                     if (headerChangedDuringUpdate) {
-                        lazyAdjustColumnWidths.schedule(1);
+                        triggerLazyColumnAdjustment(true);
                     } else {
                         // webkits may still bug with their disturbing scrollbar
                         // bug, see #3457
@@ -1075,7 +1075,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         }
     }
 
-    private void updatePageLength(UIDL uidl) {
+    protected void updatePageLength(UIDL uidl) {
         int oldPageLength = pageLength;
         if (uidl.hasAttribute("pagelength")) {
             pageLength = uidl.getIntAttribute("pagelength");
@@ -3030,7 +3030,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                 } else {
                     tHead.removeCell(colKey);
                     collapsedColumns.add(colKey);
-                    lazyAdjustColumnWidths.schedule(1);
+                    triggerLazyColumnAdjustment(true);
                 }
 
                 // update variable to server
@@ -5488,8 +5488,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             setContentWidth(innerPixels);
 
             // readjust undefined width columns
-            lazyAdjustColumnWidths.cancel();
-            lazyAdjustColumnWidths.schedule(LAZY_COLUMN_ADJUST_TIMEOUT);
+            triggerLazyColumnAdjustment(false);
 
         } else {
             // Undefined width
@@ -5499,8 +5498,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             sizeInit();
 
             // readjust undefined width columns
-            lazyAdjustColumnWidths.cancel();
-            lazyAdjustColumnWidths.schedule(LAZY_COLUMN_ADJUST_TIMEOUT);
+            triggerLazyColumnAdjustment(false);
         }
 
         /*
@@ -6607,4 +6605,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             return function(){ return false; };
     }-*/;
 
+    protected void triggerLazyColumnAdjustment(boolean now) {
+        lazyAdjustColumnWidths.cancel();
+        if (now) {
+            lazyAdjustColumnWidths.run();
+        } else {
+            lazyAdjustColumnWidths.schedule(LAZY_COLUMN_ADJUST_TIMEOUT);
+        }
+    }
 }
index b21a5dfdce74d95cd17b98c7a4ee2ee74c077e41..aa2ebed23da5524a18eb89bdac457f19fd64accd 100644 (file)
@@ -26,7 +26,6 @@ import com.vaadin.terminal.gwt.client.BrowserInfo;
 import com.vaadin.terminal.gwt.client.ComputedStyle;
 import com.vaadin.terminal.gwt.client.RenderSpace;
 import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.VConsole;
 import com.vaadin.terminal.gwt.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow;
 import com.vaadin.terminal.gwt.client.ui.VTreeTable.VTreeTableScrollBody.VTreeTableRow;
 
@@ -64,10 +63,21 @@ public class VTreeTable extends VScrollTable {
 
             int scrollPosition2 = widget.getScrollPosition();
             if (scrollPosition != scrollPosition2) {
-                VConsole.log("TT scrollpos from " + scrollPosition + " to "
-                        + scrollPosition2);
                 widget.setScrollPosition(scrollPosition);
             }
+
+            /*
+             * Triggers row calculations, removes cached rows etc. Basically
+             * cleans up state. Be careful if touching this, you will brake
+             * pageLength=0 if you remove this.
+             */
+            onScroll(null);
+
+            /*
+             * Ensure that possibly removed/added scrollbars are considered.
+             */
+            triggerLazyColumnAdjustment(true);
+
             collapseRequest = false;
         }
         if (uidl.hasAttribute("focusedRow")) {
@@ -765,10 +775,6 @@ public class VTreeTable extends VScrollTable {
         // Make sure that initializedAndAttached & al are not reset when the
         // totalrows are updated on expand/collapse requests.
         int newTotalRows = uidl.getIntAttribute("totalrows");
-        if (collapseRequest) {
-            setTotalRows(newTotalRows);
-        } else {
-            super.setTotalRows(newTotalRows);
-        }
+        setTotalRows(newTotalRows);        
     }
 }