aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-12-18 18:28:49 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-18 21:12:47 +0000
commit6e35854213946f2400f50d9e1d1dee04b5c84cb2 (patch)
tree7d4475a11a1a3b75d7a4b4ee25017b49cde6b08f /client
parentfe6f23946a39f87c6b67c91c550404024a487043 (diff)
downloadvaadin-framework-6e35854213946f2400f50d9e1d1dee04b5c84cb2.tar.gz
vaadin-framework-6e35854213946f2400f50d9e1d1dee04b5c84cb2.zip
Fix indexing when adding rows to AbstractRemoteDataSource (#13334)
Change-Id: Ifa7c8dacb71d2f6ff612e3801b869652fa0a7bc7
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/data/AbstractRemoteDataSource.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java
index 26b60bd2ae..6799c0bd23 100644
--- a/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java
+++ b/client/src/com/vaadin/client/data/AbstractRemoteDataSource.java
@@ -502,7 +502,16 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> {
size += count;
- if (cached.contains(firstRowIndex)) {
+ if (firstRowIndex < cached.getStart()) {
+ Range oldCached = cached;
+ cached = cached.offsetBy(count);
+
+ for (int i = 1; i <= indexToRowMap.size(); i++) {
+ int oldIndex = oldCached.getEnd() - i;
+ int newIndex = cached.getEnd() - i;
+ moveRowFromIndexToIndex(oldIndex, newIndex);
+ }
+ } else if (cached.contains(firstRowIndex)) {
int oldCacheEnd = cached.getEnd();
/*
* We need to invalidate the cache from the inserted row onwards,
@@ -519,18 +528,6 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> {
keyToIndexMap.remove(getRowKey(row));
}
}
-
- else if (firstRowIndex < cached.getStart()) {
- Range oldCached = cached;
- cached = cached.offsetBy(count);
-
- for (int i = 0; i < indexToRowMap.size(); i++) {
- int oldIndex = oldCached.getEnd() - i;
- int newIndex = cached.getEnd() - i;
- moveRowFromIndexToIndex(oldIndex, newIndex);
- }
- }
-
assertDataChangeHandlerIsInjected();
dataChangeHandler.dataAdded(firstRowIndex, count);
ensureCoverageCheck();
@@ -545,7 +542,9 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> {
keyToIndexMap.remove(getRowKey(indexToRowMap.get(newIndex)));
}
indexToRowMap.put(newIndex, row);
- keyToIndexMap.put(getRowKey(row), newIndex);
+ if (row != null) {
+ keyToIndexMap.put(getRowKey(row), newIndex);
+ }
}
/**