diff options
author | Sara Seppola <sara@vaadin.com> | 2014-11-04 11:44:45 +0200 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-11-25 14:42:44 +0200 |
commit | 0507127d674d67052ff2e2d9f139e3a69d871169 (patch) | |
tree | 05be65646882d885a2861eaee4210d1e56cd7928 /client/src | |
parent | 53c1e10c0a76f26bdd055916e794621264001f52 (diff) | |
download | vaadin-framework-0507127d674d67052ff2e2d9f139e3a69d871169.tar.gz vaadin-framework-0507127d674d67052ff2e2d9f139e3a69d871169.zip |
Table is not caching thousands of rows in vain (#13576)
Change-Id: I6f6382dd3468db40c36e507b94f84ab1191e100f
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/com/vaadin/client/ui/VScrollTable.java | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 961e32b290..6c241f1033 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -2600,11 +2600,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, @Override public void run() { + if (client.hasActiveRequest() || navKeyDown) { // if client connection is busy, don't bother loading it more VConsole.log("Postponed rowfetch"); schedule(250); - } else if (!updatedReqRows && allRenderedRowsAreNew()) { + } else if (allRenderedRowsAreNew() && !updatedReqRows) { /* * If all rows are new, there might have been a server-side call @@ -2625,6 +2626,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, setReqRows(last - getReqFirstRow() + 1); updatedReqRows = true; schedule(250); + } else { int firstRendered = scrollBody.getFirstRendered(); @@ -2712,6 +2714,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, client.updateVariable(paintableId, "firstvisible", firstRowInViewPort, false); } + client.updateVariable(paintableId, "reqfirstrow", reqFirstRow, false); client.updateVariable(paintableId, "reqrows", reqRows, true); @@ -4208,7 +4211,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } /** - * Returns the expand ration of the cell + * Returns the expand ratio of the cell * * @return The expand ratio */ @@ -4696,10 +4699,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } public int getLastRendered() { + return lastRendered; } public int getFirstRendered() { + return firstRendered; } @@ -4783,10 +4788,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } else if (firstIndex + rows == firstRendered) { final VScrollTableRow[] rowArray = new VScrollTableRow[rows]; int i = rows; + while (it.hasNext()) { i--; rowArray[i] = prepareRow((UIDL) it.next()); } + for (i = 0; i < rows; i++) { addRowBeforeFirstRendered(rowArray[i]); firstRendered--; @@ -4811,10 +4818,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, setLastRendered(lastRendered + 1); setContainerHeight(); fixSpacers(); + while (it.hasNext()) { addRow(prepareRow((UIDL) it.next())); setLastRendered(lastRendered + 1); } + fixSpacers(); } @@ -4829,6 +4838,14 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * has changed since the last request. */ protected void ensureCacheFilled() { + + /** + * Fixes cache issue #13576 where unnecessary rows are fetched + */ + if (isLazyScrollerActive()) { + return; + } + int reactFirstRow = (int) (firstRowInViewPort - pageLength * cache_react_rate); int reactLastRow = (int) (firstRowInViewPort + pageLength + pageLength @@ -6136,7 +6153,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, touchStart = event; Touch touch = event.getChangedTouches().get(0); // save position to fields, touches in events are same - // isntance during the operation. + // instance during the operation. touchStartX = touch.getClientX(); touchStartY = touch.getClientY(); /* @@ -6444,8 +6461,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, startRow = focusedRow; selectionRangeStart = focusedRow; // If start row is null then we have a multipage selection - // from - // above + // from above if (startRow == null) { startRow = (VScrollTableRow) scrollBody.iterator() .next(); @@ -7280,6 +7296,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } if (preLimit < firstRendered) { // need some rows to the beginning of the rendered area + rowRequestHandler .setReqFirstRow((int) (firstRowInViewPort - pageLength * cache_rate)); @@ -7665,13 +7682,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // viewport selectLastItemInNextRender = true; multiselectPending = shift; - scrollByPagelenght(1); + scrollByPagelength(1); } } } } else { /* No selections, go page down by scrolling */ - scrollByPagelenght(1); + scrollByPagelength(1); } return true; } @@ -7717,13 +7734,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // viewport selectFirstItemInNextRender = true; multiselectPending = shift; - scrollByPagelenght(-1); + scrollByPagelength(-1); } } } } else { /* No selections, go page up by scrolling */ - scrollByPagelenght(-1); + scrollByPagelength(-1); } return true; @@ -7797,7 +7814,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, .getRowHeight()); } - private void scrollByPagelenght(int i) { + private void scrollByPagelength(int i) { int pixels = i * scrollBodyPanel.getOffsetHeight(); int newPixels = scrollBodyPanel.getScrollPosition() + pixels; if (newPixels < 0) { |