1 package com.vaadin.tests.components.treetable;
3 import com.vaadin.server.VaadinRequest;
4 import com.vaadin.tests.components.AbstractTestUI;
5 import com.vaadin.v7.data.util.BeanItemContainer;
6 import com.vaadin.v7.data.util.ContainerHierarchicalWrapper;
7 import com.vaadin.v7.ui.Tree.ExpandEvent;
8 import com.vaadin.v7.ui.Tree.ExpandListener;
9 import com.vaadin.v7.ui.TreeTable;
11 @SuppressWarnings("serial")
12 public class TreeTableContainerHierarchicalWrapper extends AbstractTestUI {
14 TreeTable treetable = new TreeTable();
15 BeanItemContainer<Bean> beanContainer = new BeanItemContainer<Bean>(
17 ContainerHierarchicalWrapper hierarchicalWrapper = new ContainerHierarchicalWrapper(
21 protected void setup(VaadinRequest request) {
22 treetable = new TreeTable();
23 treetable.setImmediate(true);
24 treetable.setWidth("100%");
25 treetable.setHeight(null);
26 treetable.setPageLength(0);
27 treetable.setContainerDataSource(hierarchicalWrapper);
29 treetable.addExpandListener(new ExpandListener() {
31 public void nodeExpand(ExpandEvent event) {
32 Bean parent = ((Bean) event.getItemId());
33 if (!hierarchicalWrapper.hasChildren(parent)) {
34 for (int i = 1; i <= 5; i++) {
35 Bean newChild = new Bean(parent.getId() + "-" + i);
36 beanContainer.addBean(newChild);
37 hierarchicalWrapper.setParent(newChild, parent);
44 for (int i = 0; i < 3; i++) {
45 beanContainer.addBean(new Bean("Item " + i));
48 addComponent(treetable);
52 public static final String PROP_ID = "id";
59 public Bean(String id) {
63 public void setId(String id) {
67 public String getId() {
73 protected String getTestDescription() {
74 return "Tests that TreeTable with ContainerHierarchicalWrapper is updated correctly when the setParent() is called for the item just added";
78 protected Integer getTicketNumber() {