diff options
Diffstat (limited to 'src/com/vaadin/ui/Table.java')
-rw-r--r-- | src/com/vaadin/ui/Table.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index 60b6122270..c4d90d7790 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -2295,7 +2295,7 @@ public class Table extends AbstractSelect implements Action.Container, * @return */ private Set<Object> getItemIdsInRange(Object itemId, final int length) { - HashSet<Object> ids = new HashSet<Object>(); + HashSet<Object> ids = new LinkedHashSet<Object>(); for (int i = 0; i < length; i++) { assert itemId != null; // should not be null unless client-server // are out of sync @@ -2318,18 +2318,12 @@ public class Table extends AbstractSelect implements Action.Container, Set<Object> renderedItemIds = getCurrentlyRenderedItemIds(); @SuppressWarnings("unchecked") - HashSet<Object> newValue = new HashSet<Object>( + HashSet<Object> newValue = new LinkedHashSet<Object>( (Collection<Object>) getValue()); if (variables.containsKey("clearSelections")) { // the client side has instructed to swipe all previous selections newValue.clear(); - } else { - /* - * first clear all selections that are currently rendered rows (the - * ones that the client side counterpart is aware of) - */ - newValue.removeAll(renderedItemIds); } /* @@ -2346,6 +2340,7 @@ public class Table extends AbstractSelect implements Action.Container, requestRepaint(); } else if (id != null && containsId(id)) { newValue.add(id); + renderedItemIds.remove(id); } } @@ -2355,9 +2350,17 @@ public class Table extends AbstractSelect implements Action.Container, String[] split = range.split("-"); Object startItemId = itemIdMapper.get(split[0]); int length = Integer.valueOf(split[1]); - newValue.addAll(getItemIdsInRange(startItemId, length)); + Set<Object> itemIdsInRange = getItemIdsInRange(startItemId, + length); + newValue.addAll(itemIdsInRange); + renderedItemIds.removeAll(itemIdsInRange); } } + /* + * finally clear all currently rendered rows (the ones that the client + * side counterpart is aware of) that the client didn't send as selected + */ + newValue.removeAll(renderedItemIds); if (!isNullSelectionAllowed() && newValue.isEmpty()) { // empty selection not allowed, keep old value |