diff options
7 files changed, 77 insertions, 25 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index b9e0df3f72..da3e3ff956 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -2647,19 +2647,48 @@ public class Grid<T> extends ResizeComposite implements } private Element getSubPart(RowContainer container, int[] indices) { + Element targetElement = container.getRowElement(indices[0]); + // Scroll wanted column to view if able - if (indices.length > 1 - && escalator.getColumnConfiguration().getFrozenColumnCount() <= indices[1]) { - escalator.scrollToColumn(indices[1], ScrollDestination.ANY, 0); - } + if (indices.length > 1 && targetElement != null) { + if (escalator.getColumnConfiguration().getFrozenColumnCount() <= indices[1]) { + escalator.scrollToColumn(indices[1], ScrollDestination.ANY, 0); + } - Element targetElement = container.getRowElement(indices[0]); - for (int i = 1; i < indices.length && targetElement != null; ++i) { - targetElement = (Element) targetElement.getChild(indices[i]); + targetElement = getCellFromRow(TableRowElement.as(targetElement), + indices[1]); + + for (int i = 2; i < indices.length && targetElement != null; ++i) { + targetElement = (Element) targetElement.getChild(indices[i]); + } } + return targetElement; } + private Element getCellFromRow(TableRowElement rowElement, int index) { + int childCount = rowElement.getCells().getLength(); + if (index < 0 || index >= childCount) { + return null; + } + + TableCellElement currentCell = null; + boolean indexInColspan = false; + int i = 0; + + while (!indexInColspan) { + currentCell = rowElement.getCells().getItem(i); + + // Calculate if this is the cell we are looking for + int colSpan = currentCell.getColSpan(); + indexInColspan = index < colSpan + i; + + // Increment by colspan to skip over hidden cells + i += colSpan; + } + return currentCell; + } + @Override public String getSubPartName(com.google.gwt.user.client.Element subElement) { // Containers and matching SubPart types diff --git a/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java b/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java index 2f333698bf..c108aaecf3 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java @@ -19,8 +19,10 @@ import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.By; +import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; +@TestCategory("grid") public class GridAddAndRemoveDataOnInitTest extends MultiBrowserTest { @Test diff --git a/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java index de7fa40eab..21cc66c8a3 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java @@ -21,9 +21,11 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; +import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.components.grid.GridElement.GridCellElement; import com.vaadin.tests.tb3.MultiBrowserTest; +@TestCategory("grid") public class GridGeneratedPropertiesTest extends MultiBrowserTest { @Test diff --git a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java index c6649326c8..d130eb643c 100644 --- a/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/WidgetRenderersTest.java @@ -22,6 +22,7 @@ import org.junit.Test; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; +import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.components.grid.GridElement.GridCellElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -31,6 +32,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest; * @since * @author Vaadin Ltd */ +@TestCategory("grid") public class WidgetRenderersTest extends MultiBrowserTest { @Test diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridFooterTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridFooterTest.java index 8124e5361f..7c0aa0deb0 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridFooterTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridFooterTest.java @@ -16,7 +16,6 @@ package com.vaadin.tests.components.grid.basicfeatures.client; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; @@ -105,8 +104,9 @@ public class GridFooterTest extends GridStaticSectionTest { assertTrue(spannedCell.isDisplayed()); assertEquals("2", spannedCell.getAttribute("colspan")); - GridCellElement hiddenCell = getGridElement().getFooterCell(0, 1); - assertFalse(hiddenCell.isDisplayed()); + // TestBench returns the spanned cell for all columns + assertEquals(spannedCell.getText(), getGridElement() + .getFooterCell(0, 1).getText()); } @Test @@ -121,8 +121,9 @@ public class GridFooterTest extends GridStaticSectionTest { assertTrue(spannedCell.isDisplayed()); assertEquals("2", spannedCell.getAttribute("colspan")); - GridCellElement hiddenCell = getGridElement().getFooterCell(0, 2); - assertFalse(hiddenCell.isDisplayed()); + // TestBench returns the spanned cell for all columns + assertEquals(spannedCell.getText(), getGridElement() + .getFooterCell(0, 2).getText()); } @Test @@ -141,7 +142,8 @@ public class GridFooterTest extends GridStaticSectionTest { for (int columnIndex = 1; columnIndex < GridBasicFeatures.COLUMNS; columnIndex++) { GridCellElement hiddenCell = getGridElement().getFooterCell(0, columnIndex); - assertFalse(hiddenCell.isDisplayed()); + // TestBench returns the spanned cell for all columns + assertEquals(spannedCell.getText(), hiddenCell.getText()); } } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridHeaderTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridHeaderTest.java index c528571a2e..59a98899f2 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridHeaderTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridHeaderTest.java @@ -175,8 +175,9 @@ public class GridHeaderTest extends GridStaticSectionTest { assertTrue(spannedCell.isDisplayed()); assertEquals("2", spannedCell.getAttribute("colspan")); + // TestBench returns the spanned cell for all spanned columns GridCellElement hiddenCell = getGridElement().getHeaderCell(1, 1); - assertFalse(hiddenCell.isDisplayed()); + assertEquals(spannedCell.getText(), hiddenCell.getText()); } @Test @@ -191,8 +192,9 @@ public class GridHeaderTest extends GridStaticSectionTest { assertTrue(spannedCell.isDisplayed()); assertEquals("2", spannedCell.getAttribute("colspan")); + // TestBench returns the spanned cell for all spanned columns GridCellElement hiddenCell = getGridElement().getHeaderCell(1, 2); - assertFalse(hiddenCell.isDisplayed()); + assertEquals(spannedCell.getText(), hiddenCell.getText()); } @Test @@ -209,9 +211,10 @@ public class GridHeaderTest extends GridStaticSectionTest { spannedCell.getAttribute("colspan")); for (int columnIndex = 1; columnIndex < GridBasicFeatures.COLUMNS; columnIndex++) { + // TestBench returns the spanned cell for all spanned columns GridCellElement hiddenCell = getGridElement().getHeaderCell(1, columnIndex); - assertFalse(hiddenCell.isDisplayed()); + assertEquals(spannedCell.getText(), hiddenCell.getText()); } } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index ec73aa9b2f..36bb6841d4 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -708,7 +708,8 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { row.join(row.getCell(grid.getColumn(0)), - row.getCell(grid.getColumn(1))); + row.getCell(grid.getColumn(1))).setText( + "Join column cells 0, 1"); } }, menuPath); @@ -717,7 +718,9 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { - row.join(grid.getColumn(1), grid.getColumn(2)); + row.join(grid.getColumn(1), grid.getColumn(2)).setText( + "Join columns 1, 2"); + ; } }, menuPath); @@ -727,7 +730,7 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { row.join(grid.getColumn(3), grid.getColumn(4), - grid.getColumn(5)); + grid.getColumn(5)).setText("Join columns 3, 4, 5"); } }, menuPath); @@ -736,8 +739,11 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { - row.join(grid.getColumns().toArray( - new GridColumn[grid.getColumnCount()])); + row.join( + grid.getColumns().toArray( + new GridColumn[grid.getColumnCount()])) + .setText("Join all columns"); + ; } }, menuPath); @@ -838,7 +844,8 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { row.join(row.getCell(grid.getColumn(0)), - row.getCell(grid.getColumn(1))); + row.getCell(grid.getColumn(1))).setText( + "Join column cells 0, 1"); } }, menuPath); @@ -847,7 +854,9 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { - row.join(grid.getColumn(1), grid.getColumn(2)); + row.join(grid.getColumn(1), grid.getColumn(2)).setText( + "Join columns 1, 2"); + ; } }, menuPath); @@ -856,8 +865,11 @@ public class GridBasicClientFeaturesWidget extends @Override public void execute() { - row.join(grid.getColumns().toArray( - new GridColumn[grid.getColumnCount()])); + row.join( + grid.getColumns().toArray( + new GridColumn[grid.getColumnCount()])) + .setText("Join all columns"); + ; } }, menuPath); |