]> source.dussan.org Git - vaadin-framework.git/commitdiff
Partly reverted [21883] as it caused unnecessary rendering in some cases
authorArtur Signell <artur.signell@itmill.com>
Thu, 3 Nov 2011 15:15:05 +0000 (15:15 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 3 Nov 2011 15:15:05 +0000 (15:15 +0000)
svn changeset:21886/svn branch:6.7

src/com/vaadin/ui/Table.java

index ddea78854c411360d50a4e4cb198c6ce3c46d6b4..d4ccedfd61b7454a8f64a50a2be4f9bb533a6701 100644 (file)
@@ -720,8 +720,9 @@ public class Table extends AbstractSelect implements Action.Container,
         }
         this.columnAlignments = newCA;
 
-        // Assures the visual refresh
-        refreshRowCache();
+        // Assures the visual refresh. No need to reset the page buffer before
+        // as the content has not changed, only the alignments.
+        refreshRenderedCells();
     }
 
     /**
@@ -1103,8 +1104,9 @@ public class Table extends AbstractSelect implements Action.Container,
             columnAlignments.put(propertyId, alignment);
         }
 
-        // Assures the visual refresh
-        refreshRowCache();
+        // Assures the visual refresh. No need to reset the page buffer before
+        // as the content has not changed, only the alignments.
+        refreshRenderedCells();
     }
 
     /**
@@ -1168,8 +1170,9 @@ public class Table extends AbstractSelect implements Action.Container,
             collapsedColumns.clear();
         }
 
-        // Assures the visual refresh
-        refreshRowCache();
+        // Assures the visual refresh. No need to reset the page buffer before
+        // as the content has not changed, only the alignments.
+        refreshRenderedCells();
     }
 
     /**
@@ -1411,7 +1414,9 @@ public class Table extends AbstractSelect implements Action.Container,
     }
 
     /**
-     * Refreshes rendered rows
+     * Refreshes the rows in the internal cache. Only if
+     * {@link #resetPageBuffer()} is called before this then all values are
+     * guaranteed to be recreated.
      */
     protected void refreshRenderedCells() {
         if (getParent() == null) {
@@ -1923,8 +1928,9 @@ public class Table extends AbstractSelect implements Action.Container,
             setItemCaptionMode(mode);
         }
 
-        // Assure visual refresh
-        refreshRowCache();
+        // Assures the visual refresh. No need to reset the page buffer before
+        // as the content has not changed, only the alignments.
+        refreshRenderedCells();
     }
 
     /**
@@ -2513,6 +2519,21 @@ public class Table extends AbstractSelect implements Action.Container,
         // Rows
         if (isPartialRowUpdate() && painted && !target.isFullRepaint()) {
             paintPartialRowUpdate(target, actionSet);
+            /*
+             * Send the page buffer indexes to ensure that the client side stays
+             * in sync. Otherwise we _might_ have the situation where the client
+             * side discards too few or too many rows, causing out of sync
+             * issues.
+             * 
+             * This could probably be done for full repaints also to simplify
+             * the client side.
+             */
+            int pageBufferLastIndex = pageBufferFirstIndex
+                    + pageBuffer[CELL_ITEMID].length - 1;
+            target.addAttribute(VScrollTable.ATTRIBUTE_PAGEBUFFER_FIRST,
+                    pageBufferFirstIndex);
+            target.addAttribute(VScrollTable.ATTRIBUTE_PAGEBUFFER_LAST,
+                    pageBufferLastIndex);
         } else if (target.isFullRepaint() || isRowCacheInvalidated()) {
             paintRows(target, cells, actionSet);
             setRowCacheInvalidated(false);
@@ -3279,7 +3300,10 @@ public class Table extends AbstractSelect implements Action.Container,
 
             if (!actionHandlers.contains(actionHandler)) {
                 actionHandlers.add(actionHandler);
-                refreshRowCache();
+                // Assures the visual refresh. No need to reset the page buffer
+                // before as the content has not changed, only the action
+                // handlers.
+                refreshRenderedCells();
             }
 
         }
@@ -3302,7 +3326,10 @@ public class Table extends AbstractSelect implements Action.Container,
                 actionMapper = null;
             }
 
-            refreshRowCache();
+            // Assures the visual refresh. No need to reset the page buffer
+            // before as the content has not changed, only the action
+            // handlers.
+            refreshRenderedCells();
         }
     }
 
@@ -3312,7 +3339,10 @@ public class Table extends AbstractSelect implements Action.Container,
     public void removeAllActionHandlers() {
         actionHandlers = null;
         actionMapper = null;
-        refreshRowCache();
+        // Assures the visual refresh. No need to reset the page buffer
+        // before as the content has not changed, only the action
+        // handlers.
+        refreshRenderedCells();
     }
 
     /* Property value change listening support */
@@ -3336,6 +3366,11 @@ public class Table extends AbstractSelect implements Action.Container,
         requestRepaint();
     }
 
+    /**
+     * Clears the current page buffer. Call this before
+     * {@link #refreshRenderedCells()} to ensure that all content is updated
+     * from the properties.
+     */
     protected void resetPageBuffer() {
         firstToBeRenderedInClient = -1;
         lastToBeRenderedInClient = -1;
@@ -4097,7 +4132,10 @@ public class Table extends AbstractSelect implements Action.Container,
      */
     public void setCellStyleGenerator(CellStyleGenerator cellStyleGenerator) {
         this.cellStyleGenerator = cellStyleGenerator;
-        refreshRowCache();
+        // Assures the visual refresh. No need to reset the page buffer
+        // before as the content has not changed, only the style generators
+        refreshRenderedCells();
+
     }
 
     /**
@@ -4789,7 +4827,9 @@ public class Table extends AbstractSelect implements Action.Container,
     public void setItemDescriptionGenerator(ItemDescriptionGenerator generator) {
         if (generator != itemDescriptionGenerator) {
             itemDescriptionGenerator = generator;
-            refreshRowCache();
+            // Assures the visual refresh. No need to reset the page buffer
+            // before as the content has not changed, only the descriptions
+            refreshRenderedCells();
         }
     }