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-27 10:43:45 +0200
commitc75bca44962893fba9c767e5d216ac6e59cc03a9 (patch)
treee29b312810d0079c1dd7c1a43873b7e6a5ac31b0
parent1208457162fac5502090ee792ff46ddb4768744d (diff)
downloadvaadin-framework-c75bca44962893fba9c767e5d216ac6e59cc03a9.tar.gz
vaadin-framework-c75bca44962893fba9c767e5d216ac6e59cc03a9.zip
Fix TreeGrid to use correct super constructor (#10291)
Fixes #10195
-rw-r--r--server/src/main/java/com/vaadin/ui/TreeGrid.java64
-rw-r--r--server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java6
2 files changed, 35 insertions, 35 deletions
diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java
index 8ee154a56e..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,39 +120,7 @@ public class TreeGrid<T> extends Grid<T>
protected TreeGrid(PropertySet<T> propertySet,
HierarchicalDataCommunicator<T> dataCommunicator) {
super(propertySet, dataCommunicator);
-
- registerRpc(new NodeCollapseRpc() {
- @Override
- public void setNodeCollapsed(String rowKey, int rowIndex,
- boolean collapse, boolean 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(new FocusParentRpc() {
- @Override
- public void focusParent(String rowKey, int cellIndex) {
- Integer parentIndex = getDataCommunicator().getParentIndex(
- getDataCommunicator().getKeyMapper().get(rowKey));
- if (parentIndex != null) {
- getRpcProxy(FocusRpc.class).focusCell(parentIndex,
- cellIndex);
- }
- }
- });
+ registerTreeGridRpc();
}
/**
@@ -203,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 1876d8de35..58fb3bac61 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
@@ -5,6 +5,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;
@@ -56,4 +57,9 @@ public class TreeGridTest {
column, treeGrid.getHierarchyColumn());
}
+ @Test
+ public void testBeanTypeConstructor() {
+ TreeGrid<Person> treeGrid = new TreeGrid<>(Person.class);
+ assertEquals(Person.class, treeGrid.getBeanType());
+ }
}