diff options
author | Artur Signell <artur@vaadin.com> | 2014-08-08 16:01:30 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-21 05:37:44 +0000 |
commit | 8476b57ce2261313f47b21764ddc02cc128b2fd4 (patch) | |
tree | dfa2ded0e48cbed3a0b9611212c81c9bfbebf400 /uitest/src/com/vaadin/tests/components/gridlayout | |
parent | eb50df0edb0c6eb86620127f3aa99da557a02f2b (diff) | |
download | vaadin-framework-8476b57ce2261313f47b21764ddc02cc128b2fd4.tar.gz vaadin-framework-8476b57ce2261313f47b21764ddc02cc128b2fd4.zip |
Add option for collapsing empty rows/columns in GridLayout (#14392)
This reverts the new default behavior introduced in fix for #8855.
If you want empty rows/columns to be ignored when rendering,
use GridLayout.setHideEmptyRowsAndColumns(true)
Change-Id: I38a8717d79cec7739b649174654b615db9d8dc7e
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/gridlayout')
5 files changed, 125 insertions, 2 deletions
diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java index c20148743a..2a533e4eda 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java @@ -37,9 +37,12 @@ public class GridLayoutExpandRatio extends AbstractTestUI { labels = new Label[ROWS][COLS]; layout = new HorizontalLayout(); gridLayout = new GridLayout(ROWS, COLS); + gridLayout.setHideEmptyRowsAndColumns(true); + layout.setImmediate(true); gridLayout.setImmediate(true); gridLayout2 = new GridLayout(4, 4); + gridLayout2.setHideEmptyRowsAndColumns(true); for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLS; j++) { Label label = new Label("Slot " + i + " " + j); diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java index 16b3742c64..4712b8fb26 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java @@ -39,7 +39,11 @@ public class GridLayoutHideMiddleCells extends AbstractTestUI { VerticalLayout mainLayout = new VerticalLayout(); HorizontalLayout horLayout = new HorizontalLayout(); gridLayout = new GridLayout(ROWS, COLS); + gridLayout.setHideEmptyRowsAndColumns(true); + gridLayout2 = new GridLayout(4, 4); + gridLayout2.setHideEmptyRowsAndColumns(true); + for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { Label label = new Label("Slot " + i + " " + j); diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java index 4f5b29c91f..1da2322dc9 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java @@ -2,9 +2,12 @@ package com.vaadin.tests.components.gridlayout; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.*; +import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ComponentContainer; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; public class MoveComponentsFromGridLayoutToInnerLayout extends AbstractTestUI { @@ -15,6 +18,7 @@ public class MoveComponentsFromGridLayoutToInnerLayout extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { gl = new GridLayout(); + gl.setHideEmptyRowsAndColumns(true); gl.setWidth("200px"); gl.setHeight("200px"); diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/UniformGridLayoutUI.java b/uitest/src/com/vaadin/tests/components/gridlayout/UniformGridLayoutUI.java new file mode 100644 index 0000000000..07abb61785 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/UniformGridLayoutUI.java @@ -0,0 +1,77 @@ +package com.vaadin.tests.components.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class UniformGridLayoutUI extends UI { + + @Override + protected void init(VaadinRequest request) { + final VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + layout.setSpacing(true); + boolean hide = (request.getParameter("collapse") != null); + layout.addComponent(createGridWithoutGridBuilder(1, hide)); + layout.addComponent(createGridWithoutGridBuilder(2, hide)); + layout.addComponent(createGridWithoutGridBuilder(3, hide)); + } + + private GridLayout createGridWithoutGridBuilder(int rows, boolean collapse) { + GridLayout grid = new GridLayout(30, 3); + grid.setWidth("100%"); + // grid.setMargin(true); + // grid.setSpacing(true); + grid.setHideEmptyRowsAndColumns(collapse); + + // Row 1 + Label label1 = new Label("Row1"); + label1.setWidth(100.0F, Unit.PERCENTAGE); + grid.addComponent(label1, 0, 0, 10, 0); + grid.setComponentAlignment(label1, Alignment.MIDDLE_LEFT); + + TextField textField1 = new TextField(); + textField1.setWidth(100.0F, Unit.PERCENTAGE); + grid.addComponent(textField1, 12, 0, 14, 0); + grid.setComponentAlignment(textField1, Alignment.MIDDLE_LEFT); + + if (rows < 2) { + return grid; + } + + // Row 2 + Label label2 = new Label("Row2"); + label2.setWidth(100.0F, Unit.PERCENTAGE); + grid.addComponent(label2, 0, 1, 10, 1); + grid.setComponentAlignment(label2, Alignment.MIDDLE_LEFT); + + TextField textField2 = new TextField(); + textField2.setWidth(100.0F, Unit.PERCENTAGE); + grid.addComponent(textField2, 12, 1, 20, 1); + grid.setComponentAlignment(textField2, Alignment.MIDDLE_LEFT); + + if (rows < 3) { + return grid; + } + + // Row 3 + Label label3 = new Label("Row3"); + label3.setWidth(100.0F, Unit.PERCENTAGE); + grid.addComponent(label3, 0, 2, 10, 2); + grid.setComponentAlignment(label3, Alignment.MIDDLE_LEFT); + + TextField textField3 = new TextField(); + textField3.setWidth(100.0F, Unit.PERCENTAGE); + grid.addComponent(textField3, 12, 2, 29, 2); + grid.setComponentAlignment(textField3, Alignment.MIDDLE_LEFT); + + return grid; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/UniformGridLayoutUITest.java b/uitest/src/com/vaadin/tests/components/gridlayout/UniformGridLayoutUITest.java new file mode 100644 index 0000000000..80f85b3b21 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/UniformGridLayoutUITest.java @@ -0,0 +1,35 @@ +/* + * 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.components.gridlayout; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class UniformGridLayoutUITest extends MultiBrowserTest { + + @Test + public void noncollapsed() throws Exception { + openTestURL(); + compareScreen("noncollapsed"); + } + + @Test + public void collapsed() throws Exception { + openTestURL("collapse"); + compareScreen("collapsed"); + } +} |