]> source.dussan.org Git - vaadin-framework.git/commitdiff
#7988 no partial refresh for an item that is not in the buffer, improved test
authorHenri Sara <henri.sara@itmill.com>
Thu, 24 Nov 2011 11:38:37 +0000 (11:38 +0000)
committerHenri Sara <henri.sara@itmill.com>
Thu, 24 Nov 2011 11:38:37 +0000 (11:38 +0000)
svn changeset:22120/svn branch:6.7

src/com/vaadin/ui/TreeTable.java
tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.html
tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java

index c3731ebaef39cc32009684753ab4cb496cc57a8e..fa80476fc82bf8586f3428f2bd58318b6c34e0d4 100644 (file)
@@ -657,7 +657,8 @@ public class TreeTable extends Table implements Hierarchical {
      */
     public void setCollapsed(Object itemId, boolean collapsed) {
         if (isCollapsed(itemId) != collapsed) {
-            if (null == toggledItemId && !isRowCacheInvalidated()) {
+            if (null == toggledItemId && getVisibleItemIds().contains(itemId)
+                    && !isRowCacheInvalidated()) {
                 // optimization: partial refresh if only one item is
                 // collapsed/expanded
                 toggledItemId = itemId;
index a9eb80e4d857008a6f412bd31eb0e2e0dec95ab1..44dd8583788d5dc2cbf542fd48ced5ef9a19f522 100644 (file)
@@ -18,7 +18,7 @@
 </tr>
 <tr>
        <td>click</td>
-       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
        <td></td>
 </tr>
 <tr>
@@ -33,7 +33,7 @@
 </tr>
 <tr>
        <td>click</td>
-       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
        <td></td>
 </tr>
 <tr>
        <td>//body/div[2]</td>
        <td>0,0</td>
 </tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>closeNotification</td>
+       <td>//body/div[2]</td>
+       <td>0,0</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>lastexpanded</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>closeNotification</td>
+       <td>//body/div[2]</td>
+       <td>0,0</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>lastcollapsed</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>closeNotification</td>
+       <td>//body/div[2]</td>
+       <td>0,0</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>manyexpanded</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>closeNotification</td>
+       <td>//body/div[2]</td>
+       <td>0,0</td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>manycollapsed</td>
+</tr>
 
 </tbody></table>
 </body>
index f37e5c5888ee7a1593aada0518871d1a7796102a..6f2e507ce3b18e5781635396ac3d63d6331df854 100644 (file)
@@ -4,20 +4,28 @@ import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.VerticalLayout;
 
 public class ProgrammaticCollapse extends TestBase {
 
     @Override
     protected void setup() {
-        HorizontalLayout layout = new HorizontalLayout();
+        VerticalLayout layout = new VerticalLayout();
         final TreeTable table = new TreeTable();
+        table.setPageLength(10);
         table.addContainerProperty("A", String.class, null);
         table.addContainerProperty("B", String.class, null);
-        table.addItem(new Object[] { "A1", "B1" }, 1);
-        table.addItem(new Object[] { "A2", "B2" }, 2);
-        table.setParent(2, 1);
+        for (int i = 1; i <= 100; ++i) {
+            int parentid = i;
+            table.addItem(new Object[] { "A" + i, "B" + i }, parentid);
+            for (int j = 1; j < 5; ++j) {
+                int id = 1000 * i + j;
+                table.addItem(new Object[] { "A" + i + "." + j,
+                        "B" + i + "." + j }, id);
+                table.setParent(id, parentid);
+            }
+        }
         layout.addComponent(table);
         layout.addComponent(new Button("Expand / Collapse",
                 new ClickListener() {
@@ -28,6 +36,28 @@ public class ProgrammaticCollapse extends TestBase {
                         table.setCollapsed(1, collapsed);
                     }
                 }));
+        layout.addComponent(new Button("Expand / Collapse last",
+                new ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        boolean collapsed = !table.isCollapsed(100);
+                        table.getWindow().showNotification(
+                                "set collapsed: " + collapsed);
+                        table.setCollapsed(100, collapsed);
+                    }
+                }));
+        layout.addComponent(new Button("Expand / Collapse multiple",
+                new ClickListener() {
+                    private boolean collapsed = true;
+
+                    public void buttonClick(ClickEvent event) {
+                        collapsed = !collapsed;
+                        table.getWindow().showNotification(
+                                "set collapsed: " + collapsed);
+                        for (int i = 0; i < 50; ++i) {
+                            table.setCollapsed(i * 2, collapsed);
+                        }
+                    }
+                }));
         addComponent(layout);
     }