aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-05-18 14:51:28 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-18 16:23:21 +0300
commit7d7f41bc2ab9a37eb2a1ef56fa99740ecfd2e05e (patch)
treed1434c9117187c14aadf2bbf62a73d034b5b2913 /server
parent23d65678faf5b0ae59b380d7dbc86e0f9db858cf (diff)
downloadvaadin-framework-7d7f41bc2ab9a37eb2a1ef56fa99740ecfd2e05e.tar.gz
vaadin-framework-7d7f41bc2ab9a37eb2a1ef56fa99740ecfd2e05e.zip
Add HasHierarchicalDataProvider#setTreeData
Additionally removes TreeData constructors from Tree and TreeGrid.
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/data/HasHierarchicalDataProvider.java13
-rw-r--r--server/src/main/java/com/vaadin/ui/Tree.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/TreeGrid.java19
3 files changed, 13 insertions, 29 deletions
diff --git a/server/src/main/java/com/vaadin/data/HasHierarchicalDataProvider.java b/server/src/main/java/com/vaadin/data/HasHierarchicalDataProvider.java
index 52ea205663..56aeb315c6 100644
--- a/server/src/main/java/com/vaadin/data/HasHierarchicalDataProvider.java
+++ b/server/src/main/java/com/vaadin/data/HasHierarchicalDataProvider.java
@@ -38,6 +38,16 @@ import com.vaadin.data.provider.TreeDataProvider;
public interface HasHierarchicalDataProvider<T> extends HasDataProvider<T> {
/**
+ * Sets a new {@link TreeDataProvider} wrapping the given {@link TreeData}.
+ *
+ * @param treeData
+ * the tree data to set
+ */
+ public default void setTreeData(TreeData<T> treeData) {
+ setDataProvider(new TreeDataProvider<>(treeData));
+ }
+
+ /**
* Gets the backing {@link TreeData} instance of the data provider, if the
* data provider is a {@link TreeDataProvider}.
*
@@ -51,7 +61,8 @@ public interface HasHierarchicalDataProvider<T> extends HasDataProvider<T> {
if (getDataProvider() instanceof TreeDataProvider) {
return ((TreeDataProvider<T>) getDataProvider()).getTreeData();
} else {
- throw new IllegalStateException("");
+ throw new IllegalStateException(
+ "Data provider is not an instance of TreeDataProvider");
}
}
diff --git a/server/src/main/java/com/vaadin/ui/Tree.java b/server/src/main/java/com/vaadin/ui/Tree.java
index 4ddd74caa4..c89d0796bc 100644
--- a/server/src/main/java/com/vaadin/ui/Tree.java
+++ b/server/src/main/java/com/vaadin/ui/Tree.java
@@ -261,16 +261,6 @@ public class Tree<T> extends Composite
}
/**
- * 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}.
*
diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java
index b73794e25a..310a7c6cf5 100644
--- a/server/src/main/java/com/vaadin/ui/TreeGrid.java
+++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java
@@ -107,23 +107,6 @@ public class TreeGrid<T> extends Grid<T>
}
/**
- * Creates a {@code TreeGrid} using the given in-memory data, without
- * support for creating columns based on property names. Use an alternative
- * constructor, such as {@link TreeGrid#TreeGrid(Class)}, to create a
- * {@code TreeGrid} that automatically sets up columns based on the type of
- * presented data.
- *
- * @see TreeData
- *
- * @param data
- * the data to use, not {@code null}
- */
- public TreeGrid(TreeData<T> data) {
- this();
- setDataProvider(new TreeDataProvider<>(data));
- }
-
- /**
* Creates a {@code TreeGrid} using a custom {@link PropertySet}
* implementation and custom data communicator.
* <p>
@@ -551,7 +534,7 @@ public class TreeGrid<T> extends Grid<T>
/**
* Gets the item collapse allowed provider.
- *
+ *
* @return the item collapse allowed provider
*/
public ItemCollapseAllowedProvider<T> getItemCollapseAllowedProvider() {