diff options
author | Maciej PrzepioĢra <mac@vaadin.com> | 2015-09-21 11:05:32 +0200 |
---|---|---|
committer | Markus Koivisto <markus@vaadin.com> | 2015-09-29 18:11:24 +0300 |
commit | bdfd5a524e8f030186f1116c44fc58b83911606d (patch) | |
tree | 34920210142436867ba37d1eaebedb1678d5266e /server/src | |
parent | 51fe8a556d4f4c6d7d695f5a6a80ab9023a307bb (diff) | |
download | vaadin-framework-bdfd5a524e8f030186f1116c44fc58b83911606d.tar.gz vaadin-framework-bdfd5a524e8f030186f1116c44fc58b83911606d.zip |
Write all empty cells for empty GridLayout in declarative #18805
Change-Id: I589ba0dbb4aea7578f85894046e99903d9202e37
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/com/vaadin/ui/GridLayout.java | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 792ad72dcc..8837ad71d1 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -1456,8 +1456,12 @@ public class GridLayout extends AbstractLayout implements writeMargin(design, getMargin(), def.getMargin(), designContext); - if (components.isEmpty() - || !designContext.shouldWriteChildren(this, def)) { + if (!designContext.shouldWriteChildren(this, def)) { + return; + } + + if (components.isEmpty()) { + writeEmptyColsAndRows(design, designContext); return; } @@ -1593,6 +1597,35 @@ public class GridLayout extends AbstractLayout implements } } + /** + * Fills in the design with rows and empty columns. This needs to be done + * for empty {@link GridLayout}, because there's no other way to serialize + * info about number of columns and rows if there are absolutely no + * components in the {@link GridLayout} + * + * @since + * @param design + * @param designContext + */ + private void writeEmptyColsAndRows(Element design, + DesignContext designContext) { + int rowCount = getState(false).rows; + int colCount = getState(false).columns; + + // only write cols and rows tags if size is not 1x1 + if (rowCount == 1 && colCount == 1) { + return; + } + + for (int i = 0; i < rowCount; i++) { + Element row = design.appendElement("row"); + for (int j = 0; j < colCount; j++) { + row.appendElement("column"); + } + } + + } + private int getRowSpan(Component[][] compMap, int i, int j, int colspan, Component child) { int rowspan = 1; |