diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2017-05-16 11:57:02 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-16 11:57:02 +0300 |
commit | efa7f5a4d069556061ba4ceef4fb4d76dae84ef4 (patch) | |
tree | 767b0fdb3146930919cec37e5eaab75422b0867d /uitest | |
parent | eb743d965278d263a4c496bb4e39c067fe2b1a8c (diff) | |
download | vaadin-framework-efa7f5a4d069556061ba4ceef4fb4d76dae84ef4.tar.gz vaadin-framework-efa7f5a4d069556061ba4ceef4fb4d76dae84ef4.zip |
Refactor common methods in in-memory data providers (#9308)
* Refactor common methods of InMemoryHierarchicalDataProvider and ListDataProvider to a single interface
* Rename HierarchyData and InMemoryHierarchicalDataProvider, introduce HasHierarchicalDataProvider
* Additionally adds a helper method for recursive constructing
TreeData with a child item provider.
Diffstat (limited to 'uitest')
9 files changed, 45 insertions, 45 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java index e0fa469fa8..a579c98a12 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java @@ -5,8 +5,8 @@ import java.util.List; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Widgetset; -import com.vaadin.data.HierarchyData; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.TreeData; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.icons.VaadinIcons; import com.vaadin.server.ClassResource; import com.vaadin.server.ThemeResource; @@ -27,7 +27,7 @@ import com.vaadin.ui.VerticalLayout; public class TreeBasicFeatures extends AbstractTestUIWithLog { private Tree<HierarchicalTestBean> tree; - private InMemoryHierarchicalDataProvider<HierarchicalTestBean> inMemoryDataProvider; + private TreeDataProvider<HierarchicalTestBean> inMemoryDataProvider; private IconGenerator<HierarchicalTestBean> iconGenerator = i -> { switch (i.getDepth()) { case 0: @@ -126,7 +126,7 @@ public class TreeBasicFeatures extends AbstractTestUIWithLog { } private void setupDataProvider() { - HierarchyData<HierarchicalTestBean> data = new HierarchyData<>(); + TreeData<HierarchicalTestBean> data = new TreeData<>(); List<Integer> ints = Arrays.asList(0, 1, 2); @@ -145,7 +145,7 @@ public class TreeBasicFeatures extends AbstractTestUIWithLog { }); }); - inMemoryDataProvider = new InMemoryHierarchicalDataProvider<>(data); + inMemoryDataProvider = new TreeDataProvider<>(data); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java index 8151aa8c88..13064c4c39 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java @@ -8,11 +8,11 @@ import java.util.stream.Stream; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Widgetset; -import com.vaadin.data.HierarchyData; +import com.vaadin.data.TreeData; import com.vaadin.data.provider.DataProvider; import com.vaadin.data.provider.HierarchicalDataProvider; import com.vaadin.data.provider.HierarchicalQuery; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.server.SerializablePredicate; import com.vaadin.shared.Range; import com.vaadin.tests.components.AbstractComponentTest; @@ -24,7 +24,7 @@ import com.vaadin.ui.TreeGrid; public class TreeGridBasicFeatures extends AbstractComponentTest<TreeGrid> { private TreeGrid<HierarchicalTestBean> grid; - private InMemoryHierarchicalDataProvider<HierarchicalTestBean> inMemoryDataProvider; + private TreeDataProvider<HierarchicalTestBean> inMemoryDataProvider; private LazyHierarchicalDataProvider lazyDataProvider; private HierarchicalDataProvider<HierarchicalTestBean, ?> loggingDataProvider; @@ -70,7 +70,7 @@ public class TreeGridBasicFeatures extends AbstractComponentTest<TreeGrid> { } private void initializeDataProviders() { - HierarchyData<HierarchicalTestBean> data = new HierarchyData<>(); + TreeData<HierarchicalTestBean> data = new TreeData<>(); List<Integer> ints = Arrays.asList(0, 1, 2); @@ -89,9 +89,9 @@ public class TreeGridBasicFeatures extends AbstractComponentTest<TreeGrid> { }); }); - inMemoryDataProvider = new InMemoryHierarchicalDataProvider<>(data); + inMemoryDataProvider = new TreeDataProvider<>(data); lazyDataProvider = new LazyHierarchicalDataProvider(3, 2); - loggingDataProvider = new InMemoryHierarchicalDataProvider<HierarchicalTestBean>( + loggingDataProvider = new TreeDataProvider<HierarchicalTestBean>( data) { @Override @@ -118,7 +118,7 @@ public class TreeGridBasicFeatures extends AbstractComponentTest<TreeGrid> { @SuppressWarnings("rawtypes") LinkedHashMap<String, DataProvider> options = new LinkedHashMap<>(); options.put("LazyHierarchicalDataProvider", lazyDataProvider); - options.put("InMemoryHierarchicalDataProvider", inMemoryDataProvider); + options.put("TreeDataProvider", inMemoryDataProvider); options.put("LoggingDataProvider", loggingDataProvider); createSelectAction("Set data provider", CATEGORY_FEATURES, options, diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridChangingHierarchy.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridChangingHierarchy.java index c7943524e4..d630e36292 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridChangingHierarchy.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridChangingHierarchy.java @@ -2,10 +2,10 @@ package com.vaadin.tests.components.treegrid; import java.util.stream.Stream; -import com.vaadin.data.HierarchyData; +import com.vaadin.data.TreeData; import com.vaadin.data.ValueProvider; import com.vaadin.data.provider.HierarchicalQuery; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.server.SerializablePredicate; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; @@ -15,18 +15,18 @@ import com.vaadin.ui.TreeGrid; public class TreeGridChangingHierarchy extends AbstractTestUI { private static class TestDataProvider - extends InMemoryHierarchicalDataProvider<String> { + extends TreeDataProvider<String> { - private HierarchyData<String> hierarchyData; + private TreeData<String> treeData; - public TestDataProvider(HierarchyData<String> hierarchyData) { - super(hierarchyData); - this.hierarchyData = hierarchyData; + public TestDataProvider(TreeData<String> treeData) { + super(treeData); + this.treeData = treeData; } @Override public boolean hasChildren(String item) { - if (!hierarchyData.contains(item)) { + if (!treeData.contains(item)) { return false; } return super.hasChildren(item); @@ -35,7 +35,7 @@ public class TreeGridChangingHierarchy extends AbstractTestUI { @Override public Stream<String> fetchChildren( HierarchicalQuery<String, SerializablePredicate<String>> query) { - if (!hierarchyData.contains(query.getParent())) { + if (!treeData.contains(query.getParent())) { return Stream.empty(); } return super.fetchChildren(query); @@ -44,7 +44,7 @@ public class TreeGridChangingHierarchy extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - HierarchyData<String> data = new HierarchyData<>(); + TreeData<String> data = new TreeData<>(); data.addItems(null, "a", "b", "c").addItem("b", "b/a"); TreeGrid<String> grid = new TreeGrid<>(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTree.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTree.java index 7cfb926849..f56052400e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTree.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTree.java @@ -2,8 +2,8 @@ package com.vaadin.tests.components.treegrid; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Widgetset; -import com.vaadin.data.HierarchyData; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.TreeData; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; @@ -15,10 +15,10 @@ public class TreeGridHugeTree extends AbstractTestUI { private TreeGrid<String> treeGrid; - private InMemoryHierarchicalDataProvider<String> inMemoryDataProvider; + private TreeDataProvider<String> inMemoryDataProvider; private void initializeDataProvider() { - HierarchyData<String> data = new HierarchyData<>(); + TreeData<String> data = new TreeData<>(); for (int i = 0; i < 3; i++) { String granddad = "Granddad " + i; data.addItem(null, granddad); @@ -31,7 +31,7 @@ public class TreeGridHugeTree } } } - inMemoryDataProvider = new InMemoryHierarchicalDataProvider<>(data); + inMemoryDataProvider = new TreeDataProvider<>(data); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeNavigation.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeNavigation.java index fc550a9570..02bfd65a28 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeNavigation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeNavigation.java @@ -2,8 +2,8 @@ package com.vaadin.tests.components.treegrid; import com.vaadin.annotations.Theme; import com.vaadin.annotations.Widgetset; -import com.vaadin.data.HierarchyData; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.TreeData; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.tests.components.AbstractComponentTest; import com.vaadin.ui.TreeGrid; @@ -12,7 +12,7 @@ import com.vaadin.ui.TreeGrid; public class TreeGridHugeTreeNavigation extends AbstractComponentTest<TreeGrid> { private TreeGrid<String> treeGrid; - private InMemoryHierarchicalDataProvider<String> inMemoryDataProvider; + private TreeDataProvider<String> inMemoryDataProvider; @Override public TreeGrid getComponent() { @@ -40,7 +40,7 @@ public class TreeGridHugeTreeNavigation extends AbstractComponentTest<TreeGrid> } private void initializeDataProvider() { - HierarchyData<String> data = new HierarchyData<>(); + TreeData<String> data = new TreeData<>(); for (int i = 0; i < 3; i++) { String granddad = "Granddad " + i; data.addItem(null, granddad); @@ -53,7 +53,7 @@ public class TreeGridHugeTreeNavigation extends AbstractComponentTest<TreeGrid> } } } - inMemoryDataProvider = new InMemoryHierarchicalDataProvider<>(data); + inMemoryDataProvider = new TreeDataProvider<>(data); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridInitialExpand.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridInitialExpand.java index db5b8c54b6..4c4b95c3d1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridInitialExpand.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridInitialExpand.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.treegrid; -import com.vaadin.data.HierarchyData; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.TreeData; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.TreeGrid; @@ -13,13 +13,13 @@ public class TreeGridInitialExpand extends AbstractTestUI { TreeGrid<String> treeGrid = new TreeGrid<>(); treeGrid.setCaption("Test"); treeGrid.addColumn(String::toString).setCaption("String"); - HierarchyData<String> data = new HierarchyData<>(); + TreeData<String> data = new TreeData<>(); data.addItem(null, "parent1"); data.addItem("parent1", "parent1-child1"); data.addItem("parent1", "parent1-child2"); data.addItem(null, "parent2"); data.addItem("parent2", "parent2-child2"); - treeGrid.setDataProvider(new InMemoryHierarchicalDataProvider<>(data)); + treeGrid.setDataProvider(new TreeDataProvider<>(data)); treeGrid.setHeightByRows(5); treeGrid.expand("parent1"); treeGrid.expand("parent2"); diff --git a/uitest/src/main/java/com/vaadin/tests/performance/TreeGridMemory.java b/uitest/src/main/java/com/vaadin/tests/performance/TreeGridMemory.java index 531cd8e283..3f4047e457 100644 --- a/uitest/src/main/java/com/vaadin/tests/performance/TreeGridMemory.java +++ b/uitest/src/main/java/com/vaadin/tests/performance/TreeGridMemory.java @@ -7,8 +7,8 @@ import java.util.Optional; import javax.servlet.annotation.WebServlet; import com.vaadin.annotations.VaadinServletConfiguration; -import com.vaadin.data.HierarchyData; -import com.vaadin.data.provider.InMemoryHierarchicalDataProvider; +import com.vaadin.data.TreeData; +import com.vaadin.data.provider.TreeDataProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServlet; import com.vaadin.tests.data.bean.Address; @@ -54,22 +54,22 @@ public class TreeGridMemory extends AbstractBeansMemoryTest<TreeGrid<Person>> { @Override protected void setInMemoryContainer(TreeGrid<Person> treeGrid, List<Person> data) { - HierarchyData<Person> hierarchyData = new HierarchyData<>(); + TreeData<Person> treeData = new TreeData<>(); treeGrid.setDataProvider( - new InMemoryHierarchicalDataProvider<>(hierarchyData)); + new TreeDataProvider<>(treeData)); List<Person> toExpand = new ArrayList<>(); if (data.size() != 0 && data.size() % 2 == 0) { // treat list as if it were a balanced binary tree - hierarchyData.addItem(null, data.get(0)); + treeData.addItem(null, data.get(0)); int n = 0; while (2 * n + 2 < data.size()) { - hierarchyData.addItems(data.get(n), + treeData.addItems(data.get(n), data.subList(2 * n + 1, 2 * n + 3)); toExpand.add(data.get(n)); n++; } } else { - hierarchyData.addItems(null, data); + treeData.addItems(null, data); } if (initiallyExpanded) { treeGrid.expand(toExpand); diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java index 18b320abba..a766490017 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java @@ -32,7 +32,7 @@ public class TreeGridBasicFeaturesTest extends MultiBrowserTest { @Parameters public static Collection<String> getDataProviders() { return Arrays.asList("LazyHierarchicalDataProvider", - "InMemoryHierarchicalDataProvider"); + "TreeDataProvider"); } @Before diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridClientSortTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridClientSortTest.java index 2000d1388b..4e56e8445e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridClientSortTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridClientSortTest.java @@ -19,7 +19,7 @@ public class TreeGridClientSortTest extends SingleBrowserTest { openTestURL(); TreeGridElement grid = $(TreeGridElement.class).first(); selectMenuPath("Component", "Features", "Set data provider", - "InMemoryHierarchicalDataProvider"); + "TreeDataProvider"); grid.getHeaderCell(0, 0).doubleClick(); grid.expandWithClick(0); grid.expandWithClick(1); |