From 0e7673b718c4e76617febdf34e4afda3b80c3fa4 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 21 Nov 2011 13:45:31 +0000 Subject: [PATCH] #7908 TreeTable should resize on container change when page length is zero, related test svn changeset:22082/svn branch:6.7 --- .../terminal/gwt/client/ui/VTreeTable.java | 7 +- .../ChangeDataSourcePageLengthZero.html | 67 +++++++++++++++++++ .../ChangeDataSourcePageLengthZero.java | 17 +++++ 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.html diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java index f7bd0b115d..2e9dfd6164 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java @@ -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 index 0000000000..8391ca186d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.html @@ -0,0 +1,67 @@ + + + + + + +ChangeDataSourcePageLengthZero + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ChangeDataSourcePageLengthZero
open/run/com.vaadin.tests.components.treetable.ChangeDataSourcePageLengthZero?restartApplication
screenCaptureinitial
clickvaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
screenCapturesmallcontainer
mouseClickvaadin=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]12,8
screenCaptureexpanded
clickvaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
screenCaptureaddeditem
clickvaadin=runcomvaadintestscomponentstreetableChangeDataSourcePageLengthZero::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturebigcontainer
+ + diff --git a/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java b/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java index 701c7a6a36..3d01883deb 100644 --- a/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java +++ b/tests/testbench/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java @@ -31,8 +31,25 @@ public class ChangeDataSourcePageLengthZero extends TestBase { setupContainer(tt, 10); } }); + Button addButton = new Button("Add item"); + addButton.addListener(new Button.ClickListener() { + private int i = 1; + + public void buttonClick(ClickEvent event) { + HierarchicalContainer container = (HierarchicalContainer) tt + .getContainerDataSource(); + Object itemId = container.addItem(); + container.getContainerProperty(itemId, "i").setValue(i++); + container.getContainerProperty(itemId, "link").setValue( + new Link(String.valueOf(i + 1), new ExternalResource( + "http://www.google.fi"))); + container.setChildrenAllowed(itemId, false); + container.setParent(itemId, null); + } + }); addComponent(page1); addComponent(page2); + addComponent(addButton); } private static void setupContainer(TreeTable tt, int num) { -- 2.39.5