From 2b7369f3b488587e76952cc4c2efc38d440ce980 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 24 Nov 2011 11:38:37 +0000 Subject: [PATCH] #7988 no partial refresh for an item that is not in the buffer, improved test svn changeset:22120/svn branch:6.7 --- src/com/vaadin/ui/TreeTable.java | 3 +- .../treetable/ProgrammaticCollapse.html | 64 ++++++++++++++++++- .../treetable/ProgrammaticCollapse.java | 40 ++++++++++-- 3 files changed, 99 insertions(+), 8 deletions(-) diff --git a/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java index c3731ebaef..fa80476fc8 100644 --- a/src/com/vaadin/ui/TreeTable.java +++ b/src/com/vaadin/ui/TreeTable.java @@ -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; diff --git a/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.html b/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.html index a9eb80e4d8..44dd858378 100644 --- a/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.html +++ b/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.html @@ -18,7 +18,7 @@ click - vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0] + vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0] @@ -33,7 +33,7 @@ click - vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0] + vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0] @@ -46,6 +46,66 @@ //body/div[2] 0,0 + + click + vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0] + + + + closeNotification + //body/div[2] + 0,0 + + + screenCapture + + lastexpanded + + + click + vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0] + + + + closeNotification + //body/div[2] + 0,0 + + + screenCapture + + lastcollapsed + + + click + vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0] + + + + closeNotification + //body/div[2] + 0,0 + + + screenCapture + + manyexpanded + + + click + vaadin=runcomvaadintestscomponentstreetableProgrammaticCollapse::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0] + + + + closeNotification + //body/div[2] + 0,0 + + + screenCapture + + manycollapsed + diff --git a/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java b/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java index f37e5c5888..6f2e507ce3 100644 --- a/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java +++ b/tests/testbench/com/vaadin/tests/components/treetable/ProgrammaticCollapse.java @@ -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); } -- 2.39.5