diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2017-05-17 11:08:35 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-05-17 14:29:18 +0300 |
commit | 6b3482da66bb6781128fd2d34adec3655617fb6c (patch) | |
tree | 905fc6b17f0d0617d1bbb769bd1c5814273c1cb1 /server | |
parent | 00394ba9a2622aca32e400b1e1c7efdf2d493481 (diff) | |
download | vaadin-framework-6b3482da66bb6781128fd2d34adec3655617fb6c.tar.gz vaadin-framework-6b3482da66bb6781128fd2d34adec3655617fb6c.zip |
Add convenience constructors for Tree component
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Tree.java | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Tree.java b/server/src/main/java/com/vaadin/ui/Tree.java index 6ecbaac597..85a9e3a615 100644 --- a/server/src/main/java/com/vaadin/ui/Tree.java +++ b/server/src/main/java/com/vaadin/ui/Tree.java @@ -26,9 +26,11 @@ import java.util.Set; import com.vaadin.data.Binder; import com.vaadin.data.HasHierarchicalDataProvider; import com.vaadin.data.SelectionModel; +import com.vaadin.data.TreeData; import com.vaadin.data.provider.DataGenerator; import com.vaadin.data.provider.DataProvider; import com.vaadin.data.provider.HierarchicalDataProvider; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.event.CollapseEvent; import com.vaadin.event.CollapseEvent.CollapseListener; import com.vaadin.event.ConnectorEvent; @@ -220,7 +222,7 @@ public class Tree<T> extends Composite } /** - * Constructs a new Tree Component. + * Constructs a new Tree Component with given caption. * * @param caption * the caption for component @@ -231,6 +233,54 @@ public class Tree<T> extends Composite setCaption(caption); } + /** + * Constructs a new Tree Component with given caption and {@code TreeData}. + * + * @param caption + * the caption for component + * @param treeData + * the tree data for component + */ + public Tree(String caption, TreeData<T> treeData) { + this(caption, new TreeDataProvider<>(treeData)); + } + + /** + * Constructs a new Tree Component with given caption and + * {@code HierarchicalDataProvider}. + * + * @param caption + * the caption for component + * @param dataProvider + * the hierarchical data provider for component + */ + public Tree(String caption, HierarchicalDataProvider<T, ?> dataProvider) { + this(caption); + + treeGrid.setDataProvider(dataProvider); + } + + /** + * Constructs a new Tree Component with given {@code TreeData}. + * + * @param treeData + * the tree data for component + */ + public Tree(TreeData<T> treeData) { + this(null, new TreeDataProvider<>(treeData)); + } + + /** + * Constructs a new Tree Component with given + * {@code HierarchicalDataProvider}. + * + * @param dataProvider + * the hierarchical data provider for component + */ + public Tree(HierarchicalDataProvider<T, ?> dataProvider) { + this(null, dataProvider); + } + @Override public HierarchicalDataProvider<T, ?> getDataProvider() { return treeGrid.getDataProvider(); |