From: Anna Koskinen Date: Fri, 11 Jan 2013 09:48:32 +0000 (+0200) Subject: Merge of (#8298) to Vaadin 7. X-Git-Tag: 7.0.0.rc1~31^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f9dca2ef3f4b25ef5516fefc5cf3b037e75996cd;p=vaadin-framework.git Merge of (#8298) to Vaadin 7. Viewport calculation fix. Change-Id: Ic5195e5f7027ab41f18ddcd8262f9b5a23a0da8b --- diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index e2f5e9b57d..a8cee55375 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -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 index 0000000000..aa2b29b3b7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html @@ -0,0 +1,61 @@ + + + + + + +ViewPortCalculation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ViewPortCalculation
open/run/com.vaadin.tests.components.table.ViewPortCalculation?restartApplication
doubleClickAtvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[0]25,7
assertCSSClassvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]v-table-focus
doubleClickAtvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[2]/domChild[0]22,7
assertCSSClassvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]v-table-focus
mouseClickvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[2]/domChild[0]15,9
assertCSSClassvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]v-table-focus
doubleClickAtvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]/domChild[2]23,7
assertCSSClassvaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]v-table-focus
+ + \ 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 index 0000000000..878dd0d3c4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java @@ -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)." + + "
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); + } + +}