diff options
author | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-10-07 08:14:06 +0000 |
---|---|---|
committer | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-10-07 08:14:06 +0000 |
commit | 69c95b6bb6225570931a1c2b4a3f32531a65cab0 (patch) | |
tree | 990c7aa1735e4b519607bbd7715ded7cc4b981ea | |
parent | 4bb70102310d681bfdff627443c9707638889bcf (diff) | |
download | vaadin-framework-69c95b6bb6225570931a1c2b4a3f32531a65cab0.tar.gz vaadin-framework-69c95b6bb6225570931a1c2b4a3f32531a65cab0.zip |
Fix and tests for #7720
svn changeset:21636/svn branch:6.7
3 files changed, 122 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 53aa4c407e..933c5de1c9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -1382,7 +1382,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, private void updateBody(UIDL uidl, int firstRow, int reqRows) { if (uidl == null || reqRows < 1) { // container is empty, remove possibly existing rows - if (firstRow < 0) { + if (firstRow <= 0) { while (scrollBody.getLastRendered() > scrollBody.firstRendered) { scrollBody.unlinkRow(false); } diff --git a/tests/testbench/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.html b/tests/testbench/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.html new file mode 100644 index 0000000000..1d4c65498b --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.html @@ -0,0 +1,32 @@ +<?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="" /> +<title>RemoveAllItemsRefresh</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">RemoveAllItemsRefresh</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.treetable.RemoveAllItemsRefresh?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstreetableRemoveAllItemsRefresh::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>cleared</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java b/tests/testbench/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java new file mode 100644 index 0000000000..40d63e1c87 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java @@ -0,0 +1,89 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ +package com.vaadin.tests.components.treetable; + +import com.vaadin.data.Item; +import com.vaadin.data.util.HierarchicalContainer; +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.Table; +import com.vaadin.ui.TreeTable; +import com.vaadin.ui.VerticalLayout; + +public class RemoveAllItemsRefresh extends TestBase { + protected static final String NAME_PROPERTY = "Name"; + protected static final String TITLE_PROPERTY = "Title"; + + private VerticalLayout treeLayout = new VerticalLayout(); + private Table treetable; + + private HierarchicalContainer treeContainer; + + @Override + protected void setup() { + treetable = new TreeTable(); + treeContainer = new HierarchicalContainer(); + // Create the treetable + treetable.setSelectable(true); + treetable.setSizeFull(); + + treeContainer.addContainerProperty(NAME_PROPERTY, String.class, ""); + treeContainer.addContainerProperty(TITLE_PROPERTY, String.class, ""); + treetable.setContainerDataSource(treeContainer); + + treeLayout.addComponent(treetable); + addComponent(treeLayout); + + Button cleanUp = new Button("clear"); + cleanUp.addListener(new ClickListener() { + public void buttonClick(ClickEvent event) { + treeContainer.removeAllItems(); + } + }); + addComponent(cleanUp); + + Button refresh = new Button("fill"); + refresh.addListener(new ClickListener() { + public void buttonClick(ClickEvent event) { + fill(); + } + }); + addComponent(refresh); + + fill(); + } + + private void fill() { + Item containerItem; + + treeLayout.removeAllComponents(); + treeLayout.addComponent(treetable); + + treeContainer.removeAllItems(); + containerItem = treeContainer.addItem("first"); + containerItem.getItemProperty(NAME_PROPERTY) + .setValue("1 NAME_PROPERTY"); + containerItem.getItemProperty(TITLE_PROPERTY).setValue( + "1 TITLE_PROPERTY"); + + containerItem = treeContainer.addItem("second"); + containerItem.getItemProperty(NAME_PROPERTY) + .setValue("2 NAME_PROPERTY"); + containerItem.getItemProperty(TITLE_PROPERTY).setValue( + "2 TITLE_PROPERTY"); + treetable.setContainerDataSource(treeContainer); + } + + @Override + protected String getDescription() { + return "Removing all items from a treetable should refresh the component"; + } + + @Override + protected Integer getTicketNumber() { + return 7720; + } +} |