aboutsummaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-05-18 09:48:10 +0300
committerHenri Sara <henri.sara@gmail.com>2017-05-18 09:48:10 +0300
commitc93b842947d5aab1d7eca1ff7f1426fe17432467 (patch)
tree67deb5352e2c413a569db150bbd7b0a58a448271 /documentation
parent7fa0e96cbc068f1c4e1b49312275bac85cff5260 (diff)
downloadvaadin-framework-c93b842947d5aab1d7eca1ff7f1426fe17432467.tar.gz
vaadin-framework-c93b842947d5aab1d7eca1ff7f1426fe17432467.zip
Clarify TreeData and TreeDataProvider javadocs, improve documentation (#9349)
Diffstat (limited to 'documentation')
-rw-r--r--documentation/components/components-treegrid.asciidoc15
-rw-r--r--documentation/datamodel/datamodel-hierarchical.asciidoc16
2 files changed, 9 insertions, 22 deletions
diff --git a/documentation/components/components-treegrid.asciidoc b/documentation/components/components-treegrid.asciidoc
index 7f444602d9..d85178507d 100644
--- a/documentation/components/components-treegrid.asciidoc
+++ b/documentation/components/components-treegrid.asciidoc
@@ -37,20 +37,11 @@ Populating a [classname]#TreeGrid# with in-memory data can be done as follows
[source, java]
----
-Project rootProject = getRootRroject();
-
-TreeData<Project> data = new TreeData<>();
-// add a root level item with null parent
-data.addItem(null, rootProject);
-
-// Add all children for root item
-rootProject.flattened().forEach(
- project -> data.addItems(project, project.getSubProjects()));
-
+// Initialize a TreeGrid and set in-memory data
TreeGrid<Project> treeGrid = new TreeGrid<>();
-treeGrid.setDataProvider(new TreeDataProvider<>(data));
+treeGrid.setItems(getRootProjects(), Project::getSubProjects);
-// the first column gets the hierarchy indicator by default
+// The first column gets the hierarchy indicator by default
treeGrid.addColumn(Project::getName).setCaption("Project Name");
treeGrid.addColumn(Project::getHoursDone).setCaption("Hours Done");
treeGrid.addColumn(Project::getLastModified).setCaption("Last Modified");
diff --git a/documentation/datamodel/datamodel-hierarchical.asciidoc b/documentation/datamodel/datamodel-hierarchical.asciidoc
index f405bc775f..24605adc53 100644
--- a/documentation/datamodel/datamodel-hierarchical.asciidoc
+++ b/documentation/datamodel/datamodel-hierarchical.asciidoc
@@ -27,7 +27,7 @@ Collection<Project> projects = service.getProjects();
TreeData<Project> data = new TreeData<>();
// add root level items
-data.addItems(null, projects);
+data.addItems(null, Project::getSubProjects);
// add children for the root level items
projects.forEach(project -> data.addItems(project, project.getChildren()));
@@ -42,7 +42,7 @@ When adding or removing items from the [classname]#TreeData#, you need to always
[source, java]
----
-TreeData<Project> data = dataProvider.getData();
+TreeData<Project> data = dataProvider.getTreeData();
data.addItem(null, newProject);
data.addItems(newProject, newProject.getChildren());
@@ -93,8 +93,9 @@ The following code snippet shows a simple example on how to building a lazy hier
[source, java]
----
-class FileSystemDataProvider
- extends AbstractHierarchicalDataProvider<File, FilenameFilter> {
+class FileSystemDataProvider extends
+ AbstractBackEndHierarchicalDataProvider<File, FilenameFilter> {
+
private final File root;
public FileSystemDataProvider(File root) {
@@ -108,7 +109,7 @@ class FileSystemDataProvider
}
@Override
- public Stream<File> fetchChildren(
+ public Stream<File> fetchChildrenFromBackEnd(
HierarchicalQuery<File, FilenameFilter> query) {
final File parent = query.getParentOptional().orElse(root);
return query.getFilter()
@@ -121,11 +122,6 @@ class FileSystemDataProvider
public boolean hasChildren(File item) {
return item.list() != null && item.list().length > 0;
}
-
- @Override
- public boolean isInMemory() {
- return false;
- }
}
----