diff options
author | Artur Signell <artur@vaadin.com> | 2016-02-14 13:50:12 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-03-08 13:59:05 +0200 |
commit | 85bb775c32526a3657a912f326249d7dadb4f6f0 (patch) | |
tree | f21881fa2a43f1b9938d929df0f2f48a29651c6a /server/src/com/vaadin/ui/GridLayout.java | |
parent | 0e8ce22d2b2fde5576c9b8e42135a297c6992d79 (diff) | |
download | vaadin-framework-85bb775c32526a3657a912f326249d7dadb4f6f0.tar.gz vaadin-framework-85bb775c32526a3657a912f326249d7dadb4f6f0.zip |
Read GridLayout component alignments from declarative files (#19536)
Change-Id: I1bfb5c7416d10d4872b2b0c217422ca0427a5b1d
Diffstat (limited to 'server/src/com/vaadin/ui/GridLayout.java')
-rw-r--r-- | server/src/com/vaadin/ui/GridLayout.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 8517962e91..148fd85fff 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -1330,7 +1330,7 @@ public class GridLayout extends AbstractLayout implements } } setRows(Math.max(rows.size(), 1)); - + Map<Component, Alignment> alignments = new HashMap<Component, Alignment>(); List<Integer> columnExpandRatios = new ArrayList<Integer>(); for (int row = 0; row < rowElements.size(); ++row) { Element rowElement = rowElements.get(row); @@ -1357,7 +1357,10 @@ public class GridLayout extends AbstractLayout implements Component child = null; if (col.children().size() > 0) { - child = designContext.readDesign(col.child(0)); + Element childElement = col.child(0); + child = designContext.readDesign(childElement); + alignments.put(child, DesignAttributeHandler + .readAlignment(childElement.attributes())); // TODO: Currently ignoring any extra children. // Needs Error handling? } // Else: Empty placeholder. No child component. @@ -1441,6 +1444,7 @@ public class GridLayout extends AbstractLayout implements // Add component with area addComponent(child, j, i, j + colspan, i + rowspan); + setComponentAlignment(child, alignments.get(child)); } } // Set cursor position explicitly @@ -1511,16 +1515,8 @@ public class GridLayout extends AbstractLayout implements ChildComponentData coords = childData.get(child); Alignment alignment = getComponentAlignment(child); - if (alignment.isMiddle()) { - childElement.attr(":middle", true); - } else if (alignment.isBottom()) { - childElement.attr(":bottom", true); - } - if (alignment.isCenter()) { - childElement.attr(":center", true); - } else if (alignment.isRight()) { - childElement.attr(":right", true); - } + DesignAttributeHandler.writeAlignment(childElement, + alignment); col.appendChild(childElement); if (coords.row1 != coords.row2) { |