diff options
author | Artur Signell <artur@vaadin.com> | 2015-07-08 20:04:43 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-08-26 05:43:09 +0000 |
commit | 1cef2d2f428ee1555c8b933314582b16112941bd (patch) | |
tree | 360ba7a71a0e38a64f4a9ab51446f3e394527bc0 /server/src/com/vaadin/data/util/ContainerOrderedWrapper.java | |
parent | 672e035c36f4bd2b38c69c2ef9b50428dbc266d7 (diff) | |
download | vaadin-framework-1cef2d2f428ee1555c8b933314582b16112941bd.tar.gz vaadin-framework-1cef2d2f428ee1555c8b933314582b16112941bd.zip |
Fix multiple book keeping problems in ContainerOrderedWrapper (#5934, #18422)
Change-Id: Ia749252ebf7034da5f3273ef117ab4ba35ad39b6
Diffstat (limited to 'server/src/com/vaadin/data/util/ContainerOrderedWrapper.java')
-rw-r--r-- | server/src/com/vaadin/data/util/ContainerOrderedWrapper.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java index 4bb4e4c1b2..4329219e96 100644 --- a/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java +++ b/server/src/com/vaadin/data/util/ContainerOrderedWrapper.java @@ -51,12 +51,14 @@ public class ContainerOrderedWrapper implements Container.Ordered, private final Container container; /** - * Ordering information, ie. the mapping from Item ID to the next item ID + * Ordering information, ie. the mapping from Item ID to the next item ID. + * The last item id should not be present */ private Hashtable<Object, Object> next; /** - * Reverse ordering information for convenience and performance reasons. + * Reverse ordering information for convenience and performance reasons. The + * first item id should not be present */ private Hashtable<Object, Object> prev; @@ -124,13 +126,21 @@ public class ContainerOrderedWrapper implements Container.Ordered, first = nid; } if (last.equals(id)) { - first = pid; + last = pid; } if (nid != null) { - prev.put(nid, pid); + if (pid == null) { + prev.remove(nid); + } else { + prev.put(nid, pid); + } } if (pid != null) { - next.put(pid, nid); + if (nid == null) { + next.remove(pid); + } else { + next.put(pid, nid); + } } next.remove(id); prev.remove(id); @@ -200,7 +210,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, final Collection<?> ids = container.getItemIds(); // Recreates ordering if some parts of it are missing - if (next == null || first == null || last == null || prev != null) { + if (next == null || first == null || last == null || prev == null) { first = null; last = null; next = new Hashtable<Object, Object>(); @@ -219,7 +229,7 @@ public class ContainerOrderedWrapper implements Container.Ordered, // Adds missing items for (final Iterator<?> i = ids.iterator(); i.hasNext();) { final Object id = i.next(); - if (!next.containsKey(id)) { + if (!next.containsKey(id) && last != id) { addToOrderWrapper(id); } } |