aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2010-09-01 12:11:07 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2010-09-01 12:11:07 +0000
commit152c0947749903c763c15d4ab2fc3515fb787172 (patch)
tree8a7d0457b1cbe9b2c84b5bcf7912b5cffe1edb64 /src/com/vaadin/ui
parent65ed105d30b4b6dc765356841d7e82b1b8c02e3f (diff)
downloadvaadin-framework-152c0947749903c763c15d4ab2fc3515fb787172.tar.gz
vaadin-framework-152c0947749903c763c15d4ab2fc3515fb787172.zip
fixes #5534
svn changeset:14678/svn branch:6.4
Diffstat (limited to 'src/com/vaadin/ui')
-rw-r--r--src/com/vaadin/ui/Table.java44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 770e0416c1..e66a37a449 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -1881,37 +1881,67 @@ public class Table extends AbstractSelect implements Action.Container,
final String[] ka = (String[]) variables.get("selected");
final String[] ranges = (String[]) variables.get("selectedRanges");
- // Converts the key-array to id-set
- final LinkedList s = new LinkedList();
+ Set<Object> renderedItemIds = getCurrentlyRenderedItemIds();
+
+ HashSet<Object> newValue = new HashSet<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);
+ }
+
+ /*
+ * Then add (possibly some of them back) rows that are currently
+ * selected on the client side (the ones that the client side is aware
+ * of).
+ */
for (int i = 0; i < ka.length; i++) {
+ // key to id
final Object id = itemIdMapper.get(ka[i]);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
requestRepaint();
} else if (id != null && containsId(id)) {
- s.add(id);
+ newValue.add(id);
}
}
- if (!isNullSelectionAllowed() && s.size() < 1) {
+ if (!isNullSelectionAllowed() && newValue.size() < 1) {
// empty selection not allowed, keep old value
requestRepaint();
return;
}
- // Add range items
+ /* Add range items aka shift clicked multiselection areas */
if (ranges != null) {
for (String range : ranges) {
String[] limits = range.split("-");
int start = Integer.valueOf(limits[0]);
int end = Integer.valueOf(limits[1]);
- s.addAll(getItemIdsInRange(start, end));
+ newValue.addAll(getItemIdsInRange(start, end));
}
}
- setValue(s, true);
+ setValue(newValue, true);
+
+ }
+ private Set<Object> getCurrentlyRenderedItemIds() {
+ HashSet<Object> ids = new HashSet<Object>();
+ if (pageBuffer != null) {
+ for (int i = 0; i < pageBuffer[CELL_ITEMID].length; i++) {
+ ids.add(pageBuffer[CELL_ITEMID][i]);
+ }
+ }
+ return ids;
}
/* Component basics */