]> source.dussan.org Git - vaadin-framework.git/commitdiff
#7908 TreeTable should resize on container change when page length is zero, related...
authorHenri Sara <henri.sara@itmill.com>
Mon, 21 Nov 2011 13:45:31 +0000 (13:45 +0000)
committerHenri Sara <henri.sara@itmill.com>
Mon, 21 Nov 2011 13:45:31 +0000 (13:45 +0000)
svn changeset:22082/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.html [new file with mode: 0644]
tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java

index f7bd0b115dfb2a4ea0f4ed6baacd0c9950ada146..2e9dfd616461b23e50d7d0b490cb4a1cc2be7627 100644 (file)
@@ -81,6 +81,7 @@ public class VTreeTable extends VScrollTable {
         colIndexOfHierarchy = uidl
                 .hasAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) ? uidl
                 .getIntAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) : 0;
+        int oldTotalRows = getTotalRows();
         super.updateFromUIDL(uidl, client);
         if (collapseRequest) {
             if (collapsedRowKey != null && scrollBody != null) {
@@ -95,10 +96,12 @@ public class VTreeTable extends VScrollTable {
             if (scrollPosition != scrollPosition2) {
                 widget.setScrollPosition(scrollPosition);
             }
-
+        }
+        if (collapseRequest
+                || (!uidl.hasAttribute("pagelength") && getTotalRows() != oldTotalRows)) {
             /*
              * Triggers row calculations, removes cached rows etc. Basically
-             * cleans up state. Be careful if touching this, you will brake
+             * cleans up state. Be careful if touching this, you will break
              * pageLength=0 if you remove this.
              */
             onScroll(null);
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.html b/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.html
new file mode 100644 (file)
index 0000000..8391ca1
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>ChangeDataSourcePageLengthZero</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ChangeDataSourcePageLengthZero</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.treetable.ChangeDataSourcePageLengthZero?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>initial</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>smallcontainer</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]</td>
+       <td>12,8</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>expanded</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>addeditem</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>bigcontainer</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
index 701c7a6a363c1f0cde61f0e2718c1cf3297d36e9..3d01883debb56342ae9ff7fe7782a06a989951a1 100644 (file)
@@ -31,8 +31,25 @@ public class ChangeDataSourcePageLengthZero extends TestBase {
                 setupContainer(tt, 10);\r
             }\r
         });\r
+        Button addButton = new Button("Add item");\r
+        addButton.addListener(new Button.ClickListener() {\r
+            private int i = 1;\r
+\r
+            public void buttonClick(ClickEvent event) {\r
+                HierarchicalContainer container = (HierarchicalContainer) tt\r
+                        .getContainerDataSource();\r
+                Object itemId = container.addItem();\r
+                container.getContainerProperty(itemId, "i").setValue(i++);\r
+                container.getContainerProperty(itemId, "link").setValue(\r
+                        new Link(String.valueOf(i + 1), new ExternalResource(\r
+                                "http://www.google.fi")));\r
+                container.setChildrenAllowed(itemId, false);\r
+                container.setParent(itemId, null);\r
+            }\r
+        });\r
         addComponent(page1);\r
         addComponent(page2);\r
+        addComponent(addButton);\r
     }\r
 \r
     private static void setupContainer(TreeTable tt, int num) {\r