diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-02-11 14:03:12 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2008-02-11 14:03:12 +0000 |
commit | a609933e5b58c4d19ca6c8a74131c37465b3739f (patch) | |
tree | d818f1639620166aaab3edea3a1a063365fcbf7d /src/com/itmill/toolkit/ui/Table.java | |
parent | d17b8baa95b3b7116fa2b633795a180c56c45220 (diff) | |
download | vaadin-framework-a609933e5b58c4d19ca6c8a74131c37465b3739f.tar.gz vaadin-framework-a609933e5b58c4d19ca6c8a74131c37465b3739f.zip |
trying to fix table issues
svn changeset:3766/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/Table.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/Table.java | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 59df6747b2..3913809f8f 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -281,6 +281,8 @@ public class Table extends AbstractSelect implements Action.Container, private boolean isContentRefreshesEnabled = true; + private int pageBufferFirstIndex; + /* Table constructors *************************************************** */ /** @@ -1186,6 +1188,13 @@ public class Table extends AbstractSelect implements Action.Container, iscomponent[i] = Component.class .isAssignableFrom(getType(colids[i])); } + int firstIndexNotInCache; + if (pageBuffer != null) { + firstIndexNotInCache = pageBufferFirstIndex + + pageBuffer[CELL_ITEMID].length; + } else { + firstIndexNotInCache = -1; + } // Creates the page contents int filledRows = 0; @@ -1203,10 +1212,13 @@ public class Table extends AbstractSelect implements Action.Container, } cells[CELL_ICON][i] = getItemIcon(id); } + if (cols > 0) { for (int j = 0; j < cols; j++) { - Object value = null; final Property p = getContainerProperty(id, colids[j]); + Object value = null; + // check in current pageBuffer already has row + int index = firstIndex + i; if (p != null) { if (p instanceof Property.ValueChangeNotifier) { if (oldListenedProperties == null @@ -1216,12 +1228,24 @@ public class Table extends AbstractSelect implements Action.Container, } listenedProperties.add(p); } - if (iscomponent[j]) { - value = p.getValue(); - } else if (p != null) { - value = getPropertyValue(id, colids[j], p); + if (index < firstIndexNotInCache + && index >= pageBufferFirstIndex) { + // we have data already in our cache, + // recycle it instead of fetching it via + // getValue/getPropertyValue + int indexInOldBuffer = index + - pageBufferFirstIndex; + value = pageBuffer[CELL_FIRSTCOL + j][indexInOldBuffer]; } else { - value = getPropertyValue(id, colids[j], null); + + if (iscomponent[j]) { + value = p.getValue(); + } else if (p != null) { + value = getPropertyValue(id, colids[j], p); + } else { + value = getPropertyValue(id, colids[j], + null); + } } } else { value = ""; @@ -1235,9 +1259,9 @@ public class Table extends AbstractSelect implements Action.Container, visibleComponents.add(value); } cells[CELL_FIRSTCOL + j][i] = value; - } } + id = ((Container.Ordered) items).nextItemId(id); filledRows++; @@ -1254,6 +1278,8 @@ public class Table extends AbstractSelect implements Action.Container, cells = temp; } + pageBufferFirstIndex = firstIndex; + // Saves the results to internal buffer pageBuffer = cells; @@ -1523,7 +1549,7 @@ public class Table extends AbstractSelect implements Action.Container, } if (doSort) { this.sort(); - clientNeedsContentRefresh = true; + resetPageBuffer(); } } @@ -2008,10 +2034,21 @@ public class Table extends AbstractSelect implements Action.Container, public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty() == this) { super.valueChange(event); + } else { + resetPageBuffer(); + refreshRenderedCells(); } requestRepaint(); } + private void resetPageBuffer() { + firstToBeRenderedInClient = -1; + lastToBeRenderedInClient = -1; + reqFirstRowToPaint = -1; + reqRowsToPaint = -1; + pageBuffer = null; + } + /** * Notifies the component that it is connected to an application. * @@ -2178,6 +2215,7 @@ public class Table extends AbstractSelect implements Action.Container, } // ensure that page still has first item in page setCurrentPageFirstItemIndex(getCurrentPageFirstItemIndex()); + refreshRenderedCells(); } @@ -2190,6 +2228,7 @@ public class Table extends AbstractSelect implements Action.Container, public void containerPropertySetChange( Container.PropertySetChangeEvent event) { super.containerPropertySetChange(event); + refreshRenderedCells(); } |