diff options
author | Artur Signell <artur@vaadin.com> | 2015-08-03 23:42:27 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-10-09 09:53:52 +0000 |
commit | 98f9c438d8d03c4dbc5d896ef245d252a166b9ed (patch) | |
tree | d0e5fbe545f6fc3fe5547888fcbf73294041fc61 /client | |
parent | a0637c8feb47dc4d83ce976a7c1db769238a6c95 (diff) | |
download | vaadin-framework-98f9c438d8d03c4dbc5d896ef245d252a166b9ed.tar.gz vaadin-framework-98f9c438d8d03c4dbc5d896ef245d252a166b9ed.zip |
Add Grid.deselectAll() (#18339)
Change-Id: I5d5237fcc06ae184a884cb17fa9b6eee5c37179a
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index e01edcddd7..db7b25720e 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -151,6 +151,7 @@ import com.vaadin.client.widget.grid.selection.SelectionEvent; import com.vaadin.client.widget.grid.selection.SelectionHandler; import com.vaadin.client.widget.grid.selection.SelectionModel; import com.vaadin.client.widget.grid.selection.SelectionModel.Multi; +import com.vaadin.client.widget.grid.selection.SelectionModel.Single; import com.vaadin.client.widget.grid.selection.SelectionModelMulti; import com.vaadin.client.widget.grid.selection.SelectionModelNone; import com.vaadin.client.widget.grid.selection.SelectionModelSingle; @@ -7514,6 +7515,31 @@ public class Grid<T> extends ResizeComposite implements } /** + * Deselect all rows using the current selection model. + * + * @param row + * a row object + * @return <code>true</code> iff the current selection changed + * @throws IllegalStateException + * if the current selection model is not an instance of + * {@link SelectionModel.Single} or {@link SelectionModel.Multi} + */ + public boolean deselectAll() { + if (selectionModel instanceof SelectionModel.Single<?>) { + Single<T> single = ((SelectionModel.Single<T>) selectionModel); + if (single.getSelectedRow() != null) { + return single.deselect(single.getSelectedRow()); + } else { + return false; + } + } else if (selectionModel instanceof SelectionModel.Multi<?>) { + return ((SelectionModel.Multi<T>) selectionModel).deselectAll(); + } else { + throw new IllegalStateException("Unsupported selection model"); + } + } + + /** * Gets last selected row from the current SelectionModel. * <p> * Only selection models implementing {@link SelectionModel.Single} are |