]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add asMultiSelect() to Tree class (#11949)
authorTarek Oraby <42799254+tarekoraby@users.noreply.github.com>
Tue, 21 Apr 2020 11:37:54 +0000 (14:37 +0300)
committerGitHub <noreply@github.com>
Tue, 21 Apr 2020 11:37:54 +0000 (14:37 +0300)
Tree class doesn't currently provide an obvious way that would enable a Tree object to be treated as a multi select. This commit extends the Tree API, enabling it to be used as a multi select, which would importantly facilitate the selection/deselection of multiple items in trees whose SelectionMode is MULTI.

closes #11948

server/src/main/java/com/vaadin/ui/Tree.java

index cf8bb49f2b6c67f9d39ea1ebbd74ef00f2505bd4..9e8030daae7bce1fdf2ed6bc1e49a504f198bd68 100644 (file)
@@ -573,6 +573,18 @@ public class Tree<T> extends Composite
     public Registration addSelectionListener(SelectionListener<T> listener) {
         return treeGrid.addSelectionListener(listener);
     }
+    
+    /**
+     * Use this tree as a multi select in {@link Binder}. Throws
+     * {@link IllegalStateException} if the tree is not using
+     * {@link SelectionMode#MULTI}.
+     *
+     * @return the multi select wrapper that can be used in binder
+     * @since 8.11
+     */
+    public MultiSelect<T> asMultiSelect() {
+        return treeGrid.asMultiSelect();
+    }
 
     /**
      * Use this tree as a single select in {@link Binder}. Throws