]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge of (#8298) to Vaadin 7. 26/626/1
authorAnna Koskinen <anna@vaadin.com>
Fri, 11 Jan 2013 09:48:32 +0000 (11:48 +0200)
committerAnna Koskinen <anna@vaadin.com>
Fri, 11 Jan 2013 09:48:32 +0000 (11:48 +0200)
Viewport calculation fix.

Change-Id: Ic5195e5f7027ab41f18ddcd8262f9b5a23a0da8b

client/src/com/vaadin/client/ui/VScrollTable.java
uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java [new file with mode: 0644]

index e2f5e9b57d0d74879d862a5411ca022750103a72..a8cee55375a1d8133db07417166ad38ba5d3921f 100644 (file)
@@ -4728,7 +4728,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
              */
             public boolean isInViewPort() {
                 int absoluteTop = getAbsoluteTop();
-                int scrollPosition = scrollBodyPanel.getScrollPosition();
+                int scrollPosition = scrollBodyPanel.getAbsoluteTop()
+                        + scrollBodyPanel.getScrollPosition();
                 if (absoluteTop < scrollPosition) {
                     return false;
                 }
diff --git a/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html
new file mode 100644 (file)
index 0000000..aa2b29b
--- /dev/null
@@ -0,0 +1,61 @@
+<?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>ViewPortCalculation</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ViewPortCalculation</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.table.ViewPortCalculation?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>doubleClickAt</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[0]</td>
+       <td>25,7</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]</td>
+       <td>v-table-focus</td>
+</tr>
+<tr>
+       <td>doubleClickAt</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[2]/domChild[0]</td>
+       <td>22,7</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]</td>
+       <td>v-table-focus</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[2]/domChild[0]</td>
+       <td>15,9</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td>
+       <td>v-table-focus</td>
+</tr>
+<tr>
+       <td>doubleClickAt</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]/domChild[2]</td>
+       <td>23,7</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]</td>
+       <td>v-table-focus</td>
+</tr>
+</tbody></table>
+</body>
+</html>
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java
new file mode 100644 (file)
index 0000000..878dd0d
--- /dev/null
@@ -0,0 +1,73 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.CellStyleGenerator;
+
+public class ViewPortCalculation extends TestBase {
+
+    private Object lastDoubleClickedItemId;
+
+    @Override
+    protected void setup() {
+        getLayout().setSpacing(true);
+        addComponent(createTestTable(10));
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Table rows that are too far down (but still visible) don't get focus after refreshRowCache/select (double-click)."
+                + "<br> Double-clicking on the seventh (or any further) row of causes focus to jump to the first row.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 8298;
+    }
+
+    private Table createTestTable(int rows) {
+        final Table table = new Table();
+        table.setId("table");
+        table.setSelectable(true);
+        table.setPageLength(0);
+
+        table.addContainerProperty("col1", String.class, null);
+        table.addContainerProperty("col2", String.class, null);
+        table.addContainerProperty("col3", String.class, null);
+
+        for (int i = 1; i <= rows; ++i) {
+            testData(table.addItem("row" + i), i);
+        }
+
+        table.setCellStyleGenerator(new CellStyleGenerator() {
+            public String getStyle(Table source, Object itemId,
+                    Object propertyId) {
+                if (itemId.equals(lastDoubleClickedItemId)) {
+                    return "bold";
+                }
+                return null;
+            }
+        });
+
+        table.addItemClickListener(new ItemClickListener() {
+            public void itemClick(ItemClickEvent event) {
+                if (event.isDoubleClick()) {
+                    lastDoubleClickedItemId = event.getItemId();
+                    table.refreshRowCache();
+                    table.select(event.getItemId());
+                }
+            }
+        });
+        return table;
+    }
+
+    private void testData(Item item, int i) {
+        item.getItemProperty("col1").setValue("test1-" + i);
+        item.getItemProperty("col2").setValue("test2-" + i);
+        item.getItemProperty("col3").setValue("test3-" + i);
+    }
+
+}