aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-11-21 12:54:17 +0200
committerPekka Hyvönen <pekka@vaadin.com>2016-11-30 11:49:04 +0200
commitc3ad14183d72ed48088b7a5bb528e896a9797e32 (patch)
tree8bbc0b880f819b188f5eea42a6469a08f8952864 /server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java
parent373bd63dcd2ed659d953ad591c4099b658aec8f6 (diff)
downloadvaadin-framework-c3ad14183d72ed48088b7a5bb528e896a9797e32.tar.gz
vaadin-framework-c3ad14183d72ed48088b7a5bb528e896a9797e32.zip
Enable select all checkbox for MultiSelection Grid.
It is by default shown only if used data provider is in-memory. Can be configured to be explicitly shown or hidden. Change-Id: I50569d915604c3722a22e14b7628663d5680ed83
Diffstat (limited to 'server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java')
-rw-r--r--server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java b/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java
index 7718b5a1a6..e08ba491af 100644
--- a/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java
+++ b/server/src/main/java/com/vaadin/event/selection/MultiSelectionEvent.java
@@ -16,6 +16,7 @@
package com.vaadin.event.selection;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.Optional;
import java.util.Set;
@@ -100,6 +101,36 @@ public class MultiSelectionEvent<T> extends ValueChangeEvent<Set<T>>
return Collections.unmodifiableSet(oldSelection);
}
+ /**
+ * Gets the items that were removed from selection.
+ * <p>
+ * This is just a convenience method for checking what was previously
+ * selected in {@link #getOldSelection()} but not selected anymore in
+ * {@link #getNewSelection()}.
+ *
+ * @return the items that were removed from selection
+ */
+ public Set<T> getRemovedSelection() {
+ LinkedHashSet<T> copy = new LinkedHashSet<>(oldSelection);
+ copy.removeAll(getNewSelection());
+ return copy;
+ }
+
+ /**
+ * Gets the items that were added to selection.
+ * <p>
+ * This is just a convenience method for checking what is new selected in
+ * {@link #getNewSelection()} and wasn't selected in
+ * {@link #getOldSelection()}.
+ *
+ * @return the items that were removed from selection
+ */
+ public Set<T> getAddedSelection() {
+ LinkedHashSet<T> copy = new LinkedHashSet<>(getValue());
+ copy.removeAll(oldSelection);
+ return copy;
+ }
+
@Override
public Optional<T> getFirstSelected() {
return getValue().stream().findFirst();