From 864c5c70dc96a4d79985eb3b4fadb952d320f928 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 7 Jan 2015 16:32:36 +0200 Subject: Add getSelected functionality to SelectionEvents (#15513) Change-Id: If88af88b55063f7178b32579963303ee0d621492 --- .../client/widget/grid/selection/SelectionEvent.java | 17 +++++++++++++---- server/src/com/vaadin/event/SelectionEvent.java | 10 ++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java b/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java index 7796425612..528beb5809 100644 --- a/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java +++ b/client/src/com/vaadin/client/widget/grid/selection/SelectionEvent.java @@ -105,7 +105,7 @@ public class SelectionEvent extends GwtEvent { } /** - * Get a reference to the Grid object that fired this event. + * Gets a reference to the Grid object that fired this event. * * @return a grid reference */ @@ -115,8 +115,8 @@ public class SelectionEvent extends GwtEvent { } /** - * Get all rows added to the selection since the last {@link SelectionEvent} - * . + * Gets all rows added to the selection since the last + * {@link SelectionEvent} . * * @return a collection of added rows. Empty collection if no rows were * added. @@ -126,7 +126,7 @@ public class SelectionEvent extends GwtEvent { } /** - * Get all rows removed from the selection since the last + * Gets all rows removed from the selection since the last * {@link SelectionEvent}. * * @return a collection of removed rows. Empty collection if no rows were @@ -136,6 +136,15 @@ public class SelectionEvent extends GwtEvent { return Collections.unmodifiableCollection(removed); } + /** + * Gets currently selected rows. + * + * @return a non-null collection containing all currently selected rows. + */ + public Collection getSelected() { + return grid.getSelectedRows(); + } + /** * Gets a type identifier for this event. * diff --git a/server/src/com/vaadin/event/SelectionEvent.java b/server/src/com/vaadin/event/SelectionEvent.java index b6ade2aa9c..e75369e6da 100644 --- a/server/src/com/vaadin/event/SelectionEvent.java +++ b/server/src/com/vaadin/event/SelectionEvent.java @@ -17,6 +17,7 @@ package com.vaadin.event; import java.io.Serializable; import java.util.Collection; +import java.util.Collections; import java.util.EventObject; import java.util.LinkedHashSet; import java.util.Set; @@ -66,6 +67,15 @@ public class SelectionEvent extends EventObject { return Sets.difference(oldSelection, newSelection); } + /** + * A {@link Collection} of all the itemIds that are currently selected. + * + * @return a Collection of the itemIds that are currently selected + */ + public Set getSelected() { + return Collections.unmodifiableSet(newSelection); + } + /** * The listener interface for receiving {@link SelectionEvent * SelectionEvents}. -- cgit v1.2.3