summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeppo Kurki <teppo.kurki@vaadin.com>2015-06-07 23:54:37 +0300
committerVaadin Code Review <review@vaadin.com>2015-06-08 07:19:06 +0000
commitb0d5315e8ba95d099f93dc2d16339033a6525b59 (patch)
treee9b5633df45bef160b7352348b51ee296b32e79f /server
parent7456b6cf0c2c7e66b7040af2e793566607d2a447 (diff)
downloadvaadin-framework-b0d5315e8ba95d099f93dc2d16339033a6525b59.tar.gz
vaadin-framework-b0d5315e8ba95d099f93dc2d16339033a6525b59.zip
Forget GridLayout row expand ratios for removed rows (#18166)
Change-Id: I90a28fbc9c7eadac56a1d505d7cc80bb67342aae
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/GridLayout.java8
-rw-r--r--server/tests/src/com/vaadin/ui/GridLayoutExpandRatioTest.java39
2 files changed, 42 insertions, 5 deletions
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index e510fa09fb..96b58d7e67 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -833,7 +833,13 @@ public class GridLayout extends AbstractLayout implements
}
}
}
- // TODO forget expands for removed rows
+ // Forget expands for removed rows
+ if (rows < getRows()) {
+ for (int i = rows - 1; i < getRows(); i++) {
+ rowExpandRatio.remove(i);
+ getState().explicitRowRatios.remove(i);
+ }
+ }
getState().rows = rows;
}
diff --git a/server/tests/src/com/vaadin/ui/GridLayoutExpandRatioTest.java b/server/tests/src/com/vaadin/ui/GridLayoutExpandRatioTest.java
index 685befaab4..617c7f54ed 100644
--- a/server/tests/src/com/vaadin/ui/GridLayoutExpandRatioTest.java
+++ b/server/tests/src/com/vaadin/ui/GridLayoutExpandRatioTest.java
@@ -30,6 +30,7 @@ public class GridLayoutExpandRatioTest {
public void testColExpandRatioIsForgotten() {
gridLayout = new GridLayout(4, 1);
gridLayout.setWidth(100, Unit.PERCENTAGE);
+ gridLayout.setSizeFull();
gridLayout.setSpacing(true);
addComponents(true);
@@ -46,7 +47,9 @@ public class GridLayoutExpandRatioTest {
assertFalse(gridLayout.getState().explicitColRatios.contains(2));
assertTrue(gridLayout.getState().explicitColRatios.contains(3));
- remove();
+ gridLayout.removeAllComponents();
+ gridLayout.setColumns(3);
+ addComponents(false);
assertTrue(gridLayout.getColumnExpandRatio(0) == 0);
assertTrue(gridLayout.getColumnExpandRatio(1) == 1);
@@ -56,13 +59,41 @@ public class GridLayoutExpandRatioTest {
assertTrue(gridLayout.getState().explicitColRatios.contains(1));
assertFalse(gridLayout.getState().explicitColRatios.contains(2));
assertFalse(gridLayout.getState().explicitColRatios.contains(3));
-
}
- private void remove() {
+ @Test
+ public void testRowExpandRatioIsForgotten() {
+ gridLayout = new GridLayout(1, 4);
+ gridLayout.setWidth(100, Unit.PERCENTAGE);
+ gridLayout.setSizeFull();
+ gridLayout.setSpacing(true);
+
+ addComponents(true);
+
+ gridLayout.setRowExpandRatio(1, 1);
+ gridLayout.setRowExpandRatio(3, 1);
+
+ assertTrue(gridLayout.getRowExpandRatio(0) == 0);
+ assertTrue(gridLayout.getRowExpandRatio(1) == 1);
+ assertTrue(gridLayout.getRowExpandRatio(2) == 0);
+ assertTrue(gridLayout.getRowExpandRatio(3) == 1);
+ assertFalse(gridLayout.getState().explicitRowRatios.contains(0));
+ assertTrue(gridLayout.getState().explicitRowRatios.contains(1));
+ assertFalse(gridLayout.getState().explicitRowRatios.contains(2));
+ assertTrue(gridLayout.getState().explicitRowRatios.contains(3));
+
gridLayout.removeAllComponents();
- gridLayout.setColumns(3);
+ gridLayout.setRows(3);
addComponents(false);
+
+ assertTrue(gridLayout.getRowExpandRatio(0) == 0);
+ assertTrue(gridLayout.getRowExpandRatio(1) == 1);
+ assertTrue(gridLayout.getRowExpandRatio(2) == 0);
+ assertTrue(gridLayout.getRowExpandRatio(3) == 0);
+ assertFalse(gridLayout.getState().explicitRowRatios.contains(0));
+ assertTrue(gridLayout.getState().explicitRowRatios.contains(1));
+ assertFalse(gridLayout.getState().explicitRowRatios.contains(2));
+ assertFalse(gridLayout.getState().explicitRowRatios.contains(3));
}
private void addComponents(boolean includeLastOne) {