Browse Source

Add convenience constructors for Tree component

tags/8.1.0.beta1
Teemu Suo-Anttila 7 years ago
parent
commit
6b3482da66
1 changed files with 51 additions and 1 deletions
  1. 51
    1
      server/src/main/java/com/vaadin/ui/Tree.java

+ 51
- 1
server/src/main/java/com/vaadin/ui/Tree.java View File

@@ -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();

Loading…
Cancel
Save