From: Artur Signell Date: Thu, 3 Nov 2011 15:15:05 +0000 (+0000) Subject: Partly reverted [21883] as it caused unnecessary rendering in some cases X-Git-Tag: 7.0.0.alpha1~225^2~37 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=75ad8a685076402a7b0df09f1b0142173a47319a;p=vaadin-framework.git Partly reverted [21883] as it caused unnecessary rendering in some cases svn changeset:21886/svn branch:6.7 --- diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index ddea78854c..d4ccedfd61 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -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(); } }