]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #4542
authorJohn Alhroos <john.ahlroos@itmill.com>
Mon, 24 May 2010 08:41:15 +0000 (08:41 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Mon, 24 May 2010 08:41:15 +0000 (08:41 +0000)
svn changeset:13311/svn branch:6.3

src/com/vaadin/ui/GridLayout.java
tests/src/com/vaadin/tests/server/components/TestGridLayoutLastRowRemoval.java

index 1e31eb9b65b18e65648d854be1d3bdc9d4da8150..18a602280b225069597961e01ffe353c252b348b 100644 (file)
@@ -1185,7 +1185,8 @@ public class GridLayout extends AbstractLayout implements
      * row.
      * <p>
      * 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.
      * </p>
      * 
      * @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);
index 8881b9e273f6a3b24c05ce5368f07ee1a586e164..3af9d12a83f4f2056c3f5cde5c86465a7abc3afa 100644 (file)
@@ -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());
     }
 }