aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorMatti Hosio <mhosio@vaadin.com>2014-12-10 12:42:41 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-10 15:20:55 +0000
commita0e1fe4b61ff2b2bf1e35f983e1926b6fa694020 (patch)
tree2120d2fe0ecd044c673e15ebe24ce6c0e18370f3 /server/src/com
parent5d6271489b2ce52f3c4eb3ce40cc1148c1092501 (diff)
downloadvaadin-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.java30
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());
}