diff options
author | Matti Hosio <mhosio@vaadin.com> | 2014-12-10 12:42:41 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-10 15:20:55 +0000 |
commit | a0e1fe4b61ff2b2bf1e35f983e1926b6fa694020 (patch) | |
tree | 2120d2fe0ecd044c673e15ebe24ce6c0e18370f3 /server/src/com | |
parent | 5d6271489b2ce52f3c4eb3ce40cc1148c1092501 (diff) | |
download | vaadin-framework-a0e1fe4b61ff2b2bf1e35f983e1926b6fa694020.tar.gz vaadin-framework-a0e1fe4b61ff2b2bf1e35f983e1926b6fa694020.zip |
Add support for margins in AbstractOrderedLayout (#7749)
Change-Id: I9793d37998549c410e9e17dc14402acc3b85f4f0
Diffstat (limited to 'server/src/com')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractOrderedLayout.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 87b2ff6f48..afe7a65d67 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -16,6 +16,7 @@ package com.vaadin.ui; +import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.logging.Logger; @@ -481,6 +482,17 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements super.synchronizeFromDesign(design, designContext); // remove current children removeAllComponents(); + // handle margin + AbstractOrderedLayout def = designContext.getDefaultInstance(this + .getClass()); + if (design.hasAttr("margin")) { + String value = design.attr("margin"); + setMargin(value.isEmpty() || value.equalsIgnoreCase("true")); + + } else { + // we currently support only on-off margins + setMargin(def.getMargin().getBitMask() != 0); + } // handle children for (Node childComponent : design.childNodes()) { if (childComponent instanceof Element) { @@ -535,6 +547,12 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements public void synchronizeToDesign(Element design, DesignContext designContext) { // synchronize default attributes super.synchronizeToDesign(design, designContext); + // handle margin + AbstractOrderedLayout def = designContext.getDefaultInstance(this + .getClass()); + if (getMargin().getBitMask() != def.getMargin().getBitMask()) { + design.attr("margin", ""); + } // handle children Element designElement = design; for (Component child : this) { @@ -564,6 +582,18 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } } + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractComponent#getCustomAttributes() + */ + @Override + protected Collection<String> getCustomAttributes() { + Collection<String> customAttributes = super.getCustomAttributes(); + customAttributes.add("margin"); + return customAttributes; + } + private static Logger getLogger() { return Logger.getLogger(AbstractOrderedLayout.class.getName()); } |