]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge some changes from 6.7 to 6.8
authorHenri Sara <henri.sara@itmill.com>
Tue, 22 Nov 2011 11:01:14 +0000 (11:01 +0000)
committerHenri Sara <henri.sara@itmill.com>
Tue, 22 Nov 2011 11:01:14 +0000 (11:01 +0000)
svn changeset:22091/svn branch:6.8

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..c10e3e11a4c76fe300430f65f15b9b2dd5f23675 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) {
@@ -96,15 +97,19 @@ public class VTreeTable extends VScrollTable {
                 widget.setScrollPosition(scrollPosition);
             }
 
-            /*
-             * Triggers row calculations, removes cached rows etc. Basically
-             * cleans up state. Be careful if touching this, you will brake
-             * pageLength=0 if you remove this.
-             */
+            // check which rows are needed from the server and initiate a
+            // deferred fetch
             onScroll(null);
-
+        }
+        // Recalculate table size if collapse request, or if page length is zero
+        // (not sent by server) and row count changes (#7908).
+        if (collapseRequest
+                || (!uidl.hasAttribute("pagelength") && getTotalRows() != oldTotalRows)) {
             /*
              * Ensure that possibly removed/added scrollbars are considered.
+             * Triggers row calculations, removes cached rows etc. Basically
+             * cleans up state. Be careful if touching this, you will break
+             * pageLength=0 if you remove this.
              */
             triggerLazyColumnAdjustment(true);
 
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