summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-05-07 13:06:34 +0000
committerVaadin Code Review <review@vaadin.com>2013-05-10 14:22:27 +0000
commit55ea6dce33bec44140984633a6d3aee7910b89da (patch)
tree77701ce3368c8704ff8303cbcfaa0117abdb0e88
parent19e27a15ca765de477fbe929a1cb6a7412c523f7 (diff)
downloadvaadin-framework-55ea6dce33bec44140984633a6d3aee7910b89da.tar.gz
vaadin-framework-55ea6dce33bec44140984633a6d3aee7910b89da.zip
More specific workaround for no rows in TreeTable with pagelenght = 0 (#9203)
svn changeset:25915/svn branch:6.8 Conflicts: client/src/com/vaadin/client/ui/VScrollTable.java Change-Id: I3f5b9dc988f5911023f77f184f5bd6770bbd9f1b
-rw-r--r--client/src/com/vaadin/client/ui/VScrollTable.java33
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.html47
-rw-r--r--tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java87
3 files changed, 161 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 4d61fba429..b03fa945cd 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -1113,10 +1113,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
if (firstvisible != lastRequestedFirstvisible && scrollBody != null) {
// received 'surprising' firstvisible from server: scroll there
firstRowInViewPort = firstvisible;
-
+
/*
- * Schedule the scrolling to be executed last so no updates to the rows
- * affect scrolling measurements.
+ * Schedule the scrolling to be executed last so no updates to the
+ * rows affect scrolling measurements.
*/
Scheduler.get().scheduleFinally(lazyScroller);
}
@@ -2104,6 +2104,15 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* might have been (incorrectly) calculated earlier
*/
+ /*
+ * TreeTable updates stuff in a funky order, so we must set the
+ * height as zero here before doing the real update to make it
+ * realize that there is no content,
+ */
+ if (pageLength == totalRows && pageLength == 0) {
+ scrollBody.setHeight("0px");
+ }
+
int bodyHeight;
if (pageLength == totalRows) {
/*
@@ -3056,7 +3065,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
.hasNext(); columnIndex++) {
if (it.next() == this) {
break;
- }
+ }
}
}
final int cw = scrollBody.getColWidth(columnIndex);
@@ -4796,8 +4805,20 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
prepx = 0;
}
preSpacer.getStyle().setPropertyPx("height", prepx);
- int postpx = measureRowHeightOffset(totalRows - 1)
- - measureRowHeightOffset(lastRendered);
+ int postpx;
+ if (pageLength == 0 && totalRows == pageLength) {
+ /*
+ * TreeTable depends on having lastRendered out of sync in some
+ * situations, which makes this method miss the special
+ * situation in which one row worth of post spacer to be added
+ * if there are no rows in the table. #9203
+ */
+ postpx = measureRowHeightOffset(1);
+ } else {
+ postpx = measureRowHeightOffset(totalRows - 1)
+ - measureRowHeightOffset(lastRendered);
+ }
+
if (postpx < 0) {
postpx = 0;
}
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.html b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.html
new file mode 100644
index 0000000000..e8cb0ccfe6
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.html
@@ -0,0 +1,47 @@
+<?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="http://localhost:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.treetable.RowHeightWithoutRows?restartApplication=</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>two</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableRowHeightWithoutRows::/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>empty</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstreetableRowHeightWithoutRows::/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>five</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java
new file mode 100644
index 0000000000..5e94fc1270
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java
@@ -0,0 +1,87 @@
+package com.vaadin.tests.components.treetable;
+
+import com.vaadin.data.util.BeanItemContainer;
+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.TreeTable;
+
+public class RowHeightWithoutRows extends TestBase {
+
+ private TreeTable treeTable = new TreeTable();
+
+ private BeanItemContainer<User> container = new BeanItemContainer<User>(
+ User.class);
+
+ @Override
+ public void setup() {
+ treeTable.setContainerDataSource(container);
+ treeTable.setPageLength(0);
+
+ addComponent(treeTable);
+
+ Button refresh = new Button("Add two elements");
+ addComponent(refresh);
+ refresh.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ addTwoElements();
+ }
+ });
+
+ Button reset = new Button("Reset");
+ addComponent(reset);
+ reset.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ container.removeAllItems();
+ }
+ });
+
+ Button refresh5 = new Button("Add five elements");
+ addComponent(refresh5);
+ refresh5.addListener(new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ container.addBean(new User("John", "Doe"));
+ container.addBean(new User("Mark", "Twain"));
+ container.addBean(new User("M", "T"));
+ container.addBean(new User("J", "D"));
+ container.addBean(new User("J", "T"));
+ }
+ });
+ addTwoElements();
+ }
+
+ private void addTwoElements() {
+ container.addBean(new User("John", "Doe"));
+ container.addBean(new User("Mark", "Twain"));
+ }
+
+ public static class User {
+ private String firstName;
+
+ private String lastName;
+
+ public User(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Reseting the tree table and then adding five elements should properly update the height of the TreeTable";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(9203);
+ }
+} \ No newline at end of file