summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAutomerge <automerge@vaadin.com>2012-02-13 14:14:37 +0000
committerAutomerge <automerge@vaadin.com>2012-02-13 14:14:37 +0000
commit36f749b4f83086a5306726ad607c9bb3a0fa7526 (patch)
treed6e21b0b330877596c881a7c5b7a1645a56678f7
parentf5834102cf6e75e1d05546001015585868a38a63 (diff)
downloadvaadin-framework-36f749b4f83086a5306726ad607c9bb3a0fa7526.tar.gz
vaadin-framework-36f749b4f83086a5306726ad607c9bb3a0fa7526.zip
[merge from 6.7] #8264 fix long range selection in multi-selectable table, related test
svn changeset:22984/svn branch:6.8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java5
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/LongMultiselect.html72
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/LongMultiselect.java74
3 files changed, 148 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index ee9c03d421..cae0b65a5a 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -257,9 +257,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
int endOfFirstRange = row.getIndex() - 1;
if (!(endOfFirstRange - startRow.getIndex() < 0)) {
// create range of first part unless its length is < 1
- VScrollTableRow endOfRange = scrollBody
- .getRowByRowIndex(endOfFirstRange);
- ranges.add(new SelectionRange(startRow, endOfRange));
+ ranges.add(new SelectionRange(startRow, endOfFirstRange
+ - startRow.getIndex() + 1));
}
int startOfSecondRange = row.getIndex() + 1;
if (!(getEndIndex() - startOfSecondRange < 0)) {
diff --git a/tests/testbench/com/vaadin/tests/components/table/LongMultiselect.html b/tests/testbench/com/vaadin/tests/components/table/LongMultiselect.html
new file mode 100644
index 0000000000..82778d5bac
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/LongMultiselect.html
@@ -0,0 +1,72 @@
+<?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>LongMultiselect</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">LongMultiselect</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.LongMultiselect?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]</td>
+ <td>38,13</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
+ <td>18330</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>300</td>
+ <td></td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
+ <td>18330</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>300</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[22]/domChild[0]/domChild[0]</td>
+ <td>41,-1823:shift</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>selected-5-99</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[18]/domChild[1]/domChild[0]</td>
+ <td>updated</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[19]/domChild[1]</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/table/LongMultiselect.java b/tests/testbench/com/vaadin/tests/components/table/LongMultiselect.java
new file mode 100644
index 0000000000..4db9b69070
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/LongMultiselect.java
@@ -0,0 +1,74 @@
+package com.vaadin.tests.components.table;
+
+import java.util.Collection;
+
+import com.vaadin.Application;
+import com.vaadin.data.Property;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class LongMultiselect extends TestBase {
+
+ private enum ItemProperty {
+ COLUMN1,
+ COLUMN2
+ }
+
+ @Override
+ protected void setup() {
+ VerticalLayout layout = generateLayout();
+ addComponent(layout);
+ layout.setSizeFull();
+ }
+
+ private VerticalLayout generateLayout() {
+ VerticalLayout layout = new VerticalLayout();
+
+ final Table table = new Table("Ticket #8264 table");
+ layout.addComponent(table);
+ table.setWidth("200px");
+ table.setHeight("170px");
+ table.setSelectable(true);
+ table.setMultiSelect(true);
+ table.setImmediate(true);
+
+ // Create example data
+ table.addContainerProperty(ItemProperty.COLUMN1, String.class, null);
+ table.addContainerProperty(ItemProperty.COLUMN2, String.class, null);
+ for (int i=1;i<100;i++) {
+ table.addItem(new String[]{"Item " + i, null}, i);
+ }
+
+ //Add action button
+ layout.addComponent(new Button("Do It", new Button.ClickListener() {
+ public void buttonClick(Button.ClickEvent event) {
+ // Set ItemProperty.COLUMN2 for all selected values of table
+ Collection selectedIds = (Collection)table.getValue();
+ for (final Object itemId : selectedIds) {
+ final Property p = table.getItem(itemId).getItemProperty(ItemProperty.COLUMN2);
+ if (p.getValue() instanceof String) {
+ p.setValue(null);
+ } else {
+ p.setValue("updated");
+ }
+ }
+ }
+ }));
+
+ return layout;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Multiselecting 94 rows (from \"item 5\" to \"item 98\") and modifying second column of each row selected (press Do It). This should work (update the 2nd column) and not cause JS exception.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8264;
+ }
+}