diff options
author | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-09-09 07:01:32 +0000 |
---|---|---|
committer | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-09-09 07:01:32 +0000 |
commit | 8c6e1de310737c9309d15eff8432e04254201ac8 (patch) | |
tree | 20afaa49df14e76ee11c276e722ed16f96cced8b /src | |
parent | e21098304736e32a74f359e8dfb80e587337085d (diff) | |
download | vaadin-framework-8c6e1de310737c9309d15eff8432e04254201ac8.tar.gz vaadin-framework-8c6e1de310737c9309d15eff8432e04254201ac8.zip |
Fix for the indexing problems in #7561
svn changeset:20937/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 6a2aeaa299..637d41aa08 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -3980,13 +3980,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } } else { // insert in the middle - int realIx = firstIndex - firstRendered; + int ix = firstIndex; while (it.hasNext()) { VScrollTableRow row = prepareRow((UIDL) it.next()); - insertRowAt(row, realIx); + insertRowAt(row, ix); insertedRows.add(row); lastRendered++; - realIx++; + ix++; } fixSpacers(); } @@ -4058,11 +4058,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, sibling.getElement()); } adopt(row); - renderedRows.add(index, row); + int actualIx = index - firstRendered; + renderedRows.add(actualIx, row); // TODO: could this be made more efficient? like looping only once // after all rows have been inserted - for (int ix = index + 1; ix < renderedRows.size(); ix++) { + for (int ix = actualIx + 1; ix < renderedRows.size(); ix++) { VScrollTableRow r = (VScrollTableRow) renderedRows.get(ix); r.setIndex(r.getIndex() + 1); } @@ -4079,21 +4080,20 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, if (lastRendered - firstRendered < 0) { return false; } - int index; + int actualIx; if (fromBeginning) { - index = 0; + actualIx = 0; firstRendered++; } else { - index = renderedRows.size() - 1; + actualIx = renderedRows.size() - 1; lastRendered--; } - if (index >= 0) { - unlinkRowAtIndex(index); + if (actualIx >= 0) { + unlinkRowAtActualIndex(actualIx); fixSpacers(); return true; - } else { - return false; } + return false; } protected void unlinkRows(int firstIndex, int count) { @@ -4109,7 +4109,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, lastIndex = lastRendered; } for (int ix = lastIndex; ix >= firstIndex; ix--) { - unlinkRowAtIndex(ix); + unlinkRowAtActualIndex(actualIndex(ix)); lastRendered--; } fixSpacers(); @@ -4120,13 +4120,17 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, index = firstRendered; } for (int ix = renderedRows.size() - 1; ix >= index; ix--) { - unlinkRowAtIndex(ix); + unlinkRowAtActualIndex(actualIndex(ix)); lastRendered--; } fixSpacers(); } - private void unlinkRowAtIndex(int index) { + private int actualIndex(int index) { + return index - firstRendered; + } + + private void unlinkRowAtActualIndex(int index) { final VScrollTableRow toBeRemoved = (VScrollTableRow) renderedRows .get(index); // Unregister row tooltip |