From dbbcd599b0cf09bb20b7267d966978886074162f Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Mon, 24 May 2010 08:41:15 +0000 Subject: [PATCH] Fix for #4542 svn changeset:13311/svn branch:6.3 --- src/com/vaadin/ui/GridLayout.java | 8 +++++--- .../components/TestGridLayoutLastRowRemoval.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java index 1e31eb9b65..18a602280b 100644 --- a/src/com/vaadin/ui/GridLayout.java +++ b/src/com/vaadin/ui/GridLayout.java @@ -1185,7 +1185,8 @@ public class GridLayout extends AbstractLayout implements * row. *

* If the last row is removed then all remaining components will be removed - * and the grid will be reduced to one row and one column. + * and the grid will be reduced to one row. The cursor will be moved to the + * upper left cell of the grid. *

* * @param row @@ -1217,9 +1218,10 @@ public class GridLayout extends AbstractLayout implements if (rows == 1) { /* * Removing the last row means that the dimensions of the Grid - * layout will be truncated to 1x1 and all components removed. + * layout will be truncated to 1 empty row and the cursor is moved + * to the first cell */ - setColumns(1); + cursorX = 0; cursorY = 0; } else { setRows(rows - 1); diff --git a/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java b/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java index 8881b9e273..3af9d12a83 100644 --- a/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java +++ b/tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java @@ -21,12 +21,20 @@ public class TestGridLayoutLastRowRemoval extends TestCase { fail("removeRow(0) threw an IllegalArgumentExcetion when removing the last row"); } - // The grid should now be empty with one row and one column - assertEquals(1, grid.getColumns()); + // The column amount should be preserved + assertEquals(2, grid.getColumns()); + + // There should be one row left assertEquals(1, grid.getRows()); // There should be no component left in the grid layout assertNull("A component should not be left in the layout", grid .getComponent(0, 0)); + assertNull("A component should not be left in the layout", grid + .getComponent(1, 0)); + + // The cursor should be in the first cell + assertEquals(0, grid.getCursorX()); + assertEquals(0, grid.getCursorY()); } } -- 2.39.5