diff options
3 files changed, 114 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/ui/VGridLayout.java b/client/src/com/vaadin/client/ui/VGridLayout.java index 10e5c00a38..17131ce63b 100644 --- a/client/src/com/vaadin/client/ui/VGridLayout.java +++ b/client/src/com/vaadin/client/ui/VGridLayout.java @@ -95,7 +95,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the column widths measured in pixels - * + * * @return */ protected int[] getColumnWidths() { @@ -104,7 +104,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the row heights measured in pixels - * + * * @return */ protected int[] getRowHeights() { @@ -113,7 +113,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the spacing between the cells horizontally in pixels - * + * * @return */ protected int getHorizontalSpacing() { @@ -122,7 +122,7 @@ public class VGridLayout extends ComplexPanel { /** * Returns the spacing between the cells vertically in pixels - * + * * @return */ protected int getVerticalSpacing() { @@ -271,7 +271,7 @@ public class VGridLayout extends ComplexPanel { } for (SpanList l : rowSpans) { for (Cell cell : l.cells) { - if (cell.row >= i && i < cell.row + cell.rowspan) { + if (cell.row <= i && i < cell.row + cell.rowspan) { return true; } } @@ -287,7 +287,7 @@ public class VGridLayout extends ComplexPanel { } for (SpanList l : colSpans) { for (Cell cell : l.cells) { - if (cell.col >= i && i < cell.col + cell.colspan) { + if (cell.col <= i && i < cell.col + cell.colspan) { return true; } } @@ -751,7 +751,7 @@ public class VGridLayout extends ComplexPanel { * Creates a new Cell with the given coordinates. * <p> * For internal use only. May be removed or replaced in the future. - * + * * @param row * @param col * @return @@ -767,7 +767,7 @@ public class VGridLayout extends ComplexPanel { * child component is also returned if "element" is part of its caption. * <p> * For internal use only. May be removed or replaced in the future. - * + * * @param element * An element that is a nested sub element of the root element in * this layout @@ -788,13 +788,13 @@ public class VGridLayout extends ComplexPanel { * child component is also returned if "element" is part of its caption. * <p> * For internal use only. May be removed or replaced in the future. - * + * * @param element * An element that is a nested sub element of the root element in * this layout * @return The Paintable which the element is a part of. Null if the element * belongs to the layout and not to a child. - * + * * @since 7.2 */ public ComponentConnector getComponent(Element element) { diff --git a/uitest/src/com/vaadin/tests/layouts/gridlayout/GridSpanEmptyColumns.java b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridSpanEmptyColumns.java new file mode 100644 index 0000000000..fc37455752 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridSpanEmptyColumns.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.layouts.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridSpanEmptyColumns extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + GridLayout gridLayout = new GridLayout(3, 1); + gridLayout.setWidth("1000px"); + + Label bigCell = new Label("big cell"); + bigCell.setId("bigCell"); + Label smallCell = new Label("small cell"); + smallCell.setId("smallCell"); + gridLayout.addComponent(bigCell, 0, 0, 1, 0); // spans first two columns + gridLayout.addComponent(smallCell, 2, 0, 2, 0); // last column only + + addComponent(gridLayout); + } + + @Override + protected String getTestDescription() { + return "A 3x1 grid has a spanned component on the first two cells and a component on the last cell. The two components should occupy 2/3 and 1/3 of the available space respectively, instead of 1/2 each."; + } + + @Override + protected Integer getTicketNumber() { + return 14335; + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/gridlayout/GridSpanEmptyColumnsTest.java b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridSpanEmptyColumnsTest.java new file mode 100644 index 0000000000..f2b86fb69b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridSpanEmptyColumnsTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.layouts.gridlayout; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that GridLayout handles elements spanning otherwise empty columns + * correctly (#14335) + * + * @since 7.2.5 + * @author markus + */ +public class GridSpanEmptyColumnsTest extends MultiBrowserTest { + + @Test + public void componentsShouldMoveRight() throws IOException { + openTestURL(); + + LabelElement bigCell = $(LabelElement.class).id("bigCell"); + LabelElement smallCell = $(LabelElement.class).id("smallCell"); + + // Width is 1000px. Big cell should take up 2/3, small cell should take + // up 1/3. + assertEquals(667, bigCell.getSize().width); + assertEquals(333, smallCell.getSize().width); + + } + +}
\ No newline at end of file |