summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonatan Kronqvist <jonatan.kronqvist@itmill.com>2011-10-21 07:23:22 +0000
committerJonatan Kronqvist <jonatan.kronqvist@itmill.com>2011-10-21 07:23:22 +0000
commitc9c1a83c4e9fa47fb16d53a9242285613d3b2fc2 (patch)
treeef2d5a3ef92e790a0c29fa40ac08a6f523d4fcee
parentd1e39177bac3a6ce05e84ac5a6c5b4e0484408d4 (diff)
downloadvaadin-framework-c9c1a83c4e9fa47fb16d53a9242285613d3b2fc2.tar.gz
vaadin-framework-c9c1a83c4e9fa47fb16d53a9242285613d3b2fc2.zip
Test app for #7780
svn changeset:21770/svn branch:6.7
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java113
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java b/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java
new file mode 100644
index 0000000000..db4e93b1f6
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/treetable/DynamicallyModified.java
@@ -0,0 +1,113 @@
+package com.vaadin.tests.components.treetable;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.TreeTable;
+
+public class DynamicallyModified extends TestBase implements
+ Tree.ExpandListener, Tree.CollapseListener {
+ protected static final String NAME_PROPERTY = "Name";
+ protected static final String HOURS_PROPERTY = "Hours done";
+ protected static final String MODIFIED_PROPERTY = "Last Modified";
+
+ protected TreeTable treetable;
+
+ @Override
+ protected void setup() {
+ getLayout().setWidth("100%");
+
+ // Calendar
+ Calendar cal = Calendar.getInstance();
+ cal.set(2011, 10, 30, 14, 40, 26);
+
+ // Create the treetable
+ treetable = new TreeTable();
+ treetable.setWidth("100%");
+ treetable.addListener((Tree.ExpandListener) this);
+ treetable.addListener((Tree.CollapseListener) this);
+
+ addComponent(treetable);
+
+ // Add Table columns
+ treetable.addContainerProperty(NAME_PROPERTY, String.class, "");
+ treetable.addContainerProperty(HOURS_PROPERTY, Integer.class, 0);
+ treetable.addContainerProperty(MODIFIED_PROPERTY, Date.class,
+ cal.getTime());
+
+ // Populate table
+ Object allProjects = treetable.addItem(new Object[] { "All Projects",
+ 18, cal.getTime() }, null);
+ Object year2010 = treetable.addItem(
+ new Object[] { "Year 2010", 18, cal.getTime() }, null);
+ Object customerProject1 = treetable.addItem(new Object[] {
+ "Customer Project 1", 13, cal.getTime() }, null);
+ Object customerProject1Implementation = treetable.addItem(new Object[] {
+ "Implementation", 5, cal.getTime() }, null);
+ Object customerProject1Planning = treetable.addItem(new Object[] {
+ "Planning", 2, cal.getTime() }, null);
+ Object customerProject1Prototype = treetable.addItem(new Object[] {
+ "Prototype", 5, cal.getTime() }, null);
+ Object customerProject2 = treetable.addItem(new Object[] {
+ "Customer Project 2", 5, cal.getTime() }, null);
+ Object customerProject2Planning = treetable.addItem(new Object[] {
+ "Planning", 5, cal.getTime() }, null);
+
+ // Set hierarchy
+ treetable.setParent(year2010, allProjects);
+ treetable.setParent(customerProject1, year2010);
+ treetable.setParent(customerProject1Implementation, customerProject1);
+ treetable.setParent(customerProject1Planning, customerProject1);
+ treetable.setParent(customerProject1Prototype, customerProject1);
+ treetable.setParent(customerProject2, year2010);
+ treetable.setParent(customerProject2Planning, customerProject2);
+
+ // Disallow children from leaves
+ treetable.setChildrenAllowed(customerProject1Implementation, false);
+ treetable.setChildrenAllowed(customerProject1Planning, false);
+ treetable.setChildrenAllowed(customerProject1Prototype, false);
+ treetable.setChildrenAllowed(customerProject2Planning, false);
+
+ // Expand all
+ treetable.setCollapsed(allProjects, false);
+ treetable.setCollapsed(year2010, false);
+ treetable.setCollapsed(customerProject1, false);
+ treetable.setCollapsed(customerProject2, false);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Expanding and collapsing nodes should actually expand and collapse them even when modifying the container in a collapse listener.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7780;
+ }
+
+ public void nodeExpand(ExpandEvent event) {
+
+ }
+
+ public void nodeCollapse(CollapseEvent event) {
+
+ Collection<Object> childs = (Collection<Object>) treetable
+ .getChildren(event.getItemId());
+
+ if (childs == null) {
+ return;
+ }
+ Object[] arr = childs.toArray();
+
+ for (Object obj : arr) {
+ System.out.println("remove " + obj.toString());
+ treetable.removeItem(obj);
+ }
+
+ }
+}