aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Meyer <peergynt@users.noreply.github.com>2017-11-14 09:26:57 -0500
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-11-14 16:26:57 +0200
commit2b73e6eb08412e9b37b312421bdda2651095529f (patch)
tree4efd625a413903dda6391c0b80305a9af667de67
parent99d8b1d16fef357fe857f53c1131022a7b952b46 (diff)
downloadvaadin-framework-2b73e6eb08412e9b37b312421bdda2651095529f.tar.gz
vaadin-framework-2b73e6eb08412e9b37b312421bdda2651095529f.zip
Fix TreeGrid to use correct super constructor (#10291)
Fixes #10195
-rw-r--r--server/src/main/java/com/vaadin/ui/TreeGrid.java55
-rw-r--r--server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java6
2 files changed, 35 insertions, 26 deletions
diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java
index 24c55fce2b..2ff026a758 100644
--- a/server/src/main/java/com/vaadin/ui/TreeGrid.java
+++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java
@@ -85,8 +85,8 @@ public class TreeGrid<T> extends Grid<T>
* the bean type to use, not {@code null}
*/
public TreeGrid(Class<T> beanType) {
- this(BeanPropertySet.get(beanType),
- new HierarchicalDataCommunicator<>());
+ super(beanType, new HierarchicalDataCommunicator<>());
+ registerTreeGridRpc();
}
/**
@@ -120,30 +120,7 @@ public class TreeGrid<T> extends Grid<T>
protected TreeGrid(PropertySet<T> propertySet,
HierarchicalDataCommunicator<T> dataCommunicator) {
super(propertySet, dataCommunicator);
-
- registerRpc((NodeCollapseRpc) (rowKey, rowIndex, collapse,
- userOriginated) -> {
- T item = getDataCommunicator().getKeyMapper().get(rowKey);
- if (collapse && getDataCommunicator().isExpanded(item)) {
- getDataCommunicator().doCollapse(item, Optional.of(rowIndex));
- fireCollapseEvent(
- getDataCommunicator().getKeyMapper().get(rowKey),
- userOriginated);
- } else if (!collapse && !getDataCommunicator().isExpanded(item)) {
- getDataCommunicator().doExpand(item, Optional.of(rowIndex));
- fireExpandEvent(
- getDataCommunicator().getKeyMapper().get(rowKey),
- userOriginated);
- }
- });
-
- registerRpc((FocusParentRpc) (rowKey, cellIndex) -> {
- Integer parentIndex = getDataCommunicator().getParentIndex(
- getDataCommunicator().getKeyMapper().get(rowKey));
- if (parentIndex != null) {
- getRpcProxy(FocusRpc.class).focusCell(parentIndex, cellIndex);
- }
- });
+ registerTreeGridRpc();
}
/**
@@ -194,6 +171,32 @@ public class TreeGrid<T> extends Grid<T>
new HierarchicalDataCommunicator<>());
}
+ private void registerTreeGridRpc() {
+ registerRpc((NodeCollapseRpc) (rowKey, rowIndex, collapse,
+ userOriginated) -> {
+ T item = getDataCommunicator().getKeyMapper().get(rowKey);
+ if (collapse && getDataCommunicator().isExpanded(item)) {
+ getDataCommunicator().doCollapse(item, Optional.of(rowIndex));
+ fireCollapseEvent(
+ getDataCommunicator().getKeyMapper().get(rowKey),
+ userOriginated);
+ } else if (!collapse && !getDataCommunicator().isExpanded(item)) {
+ getDataCommunicator().doExpand(item, Optional.of(rowIndex));
+ fireExpandEvent(
+ getDataCommunicator().getKeyMapper().get(rowKey),
+ userOriginated);
+ }
+ });
+
+ registerRpc((FocusParentRpc) (rowKey, cellIndex) -> {
+ Integer parentIndex = getDataCommunicator().getParentIndex(
+ getDataCommunicator().getKeyMapper().get(rowKey));
+ if (parentIndex != null) {
+ getRpcProxy(FocusRpc.class).focusCell(parentIndex, cellIndex);
+ }
+ });
+ }
+
/**
* Adds an ExpandListener to this TreeGrid.
*
diff --git a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java
index 18b6a31b0d..279f4fd24c 100644
--- a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java
+++ b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java
@@ -8,6 +8,7 @@ import org.junit.Test;
import com.vaadin.data.TreeData;
import com.vaadin.data.provider.TreeDataProvider;
+import com.vaadin.tests.data.bean.Person;
import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.TreeGrid;
import com.vaadin.ui.renderers.TextRenderer;
@@ -59,4 +60,9 @@ public class TreeGridTest {
treeGrid.getHierarchyColumn());
}
+ @Test
+ public void testBeanTypeConstructor() {
+ TreeGrid<Person> treeGrid = new TreeGrid<>(Person.class);
+ assertEquals(Person.class, treeGrid.getBeanType());
+ }
}