From 7abac6a276a4c8b5317fc97914df09846ee6723a Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 22 Nov 2011 11:01:14 +0000 Subject: [PATCH] Merge some changes from 6.7 to 6.8 svn changeset:22091/svn branch:6.8 --- .../terminal/gwt/client/ui/VTreeTable.java | 17 +++-- .../ChangeDataSourcePageLengthZero.html | 67 +++++++++++++++++++ .../ChangeDataSourcePageLengthZero.java | 17 +++++ 3 files changed, 95 insertions(+), 6 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..c10e3e11a4 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) { @@ -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 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