diff options
author | Matti Hosio <mhosio@vaadin.com> | 2014-12-09 14:42:57 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-10 06:40:40 +0000 |
commit | 786fed171a52379bbabc7ddffff58172e5f90d2b (patch) | |
tree | 96e595cf2bfb66118a93a2db9b25ed91dfa7d209 /server/src/com | |
parent | db0403214329e77624caf6e592016a80e6195f6a (diff) | |
download | vaadin-framework-786fed171a52379bbabc7ddffff58172e5f90d2b.tar.gz vaadin-framework-786fed171a52379bbabc7ddffff58172e5f90d2b.zip |
Declarative support for CssLayout (#7749)
Change-Id: Ic99fb1e9af921b3e14127888e2b3dffbd54f493e
Diffstat (limited to 'server/src/com')
-rw-r--r-- | server/src/com/vaadin/ui/CssLayout.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index e7b63cc87a..33b8c9fcbc 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -18,6 +18,8 @@ package com.vaadin.ui; import java.util.Iterator; import java.util.LinkedList; +import org.jsoup.nodes.Element; + import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickNotifier; @@ -26,6 +28,7 @@ import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.csslayout.CssLayoutServerRpc; import com.vaadin.shared.ui.csslayout.CssLayoutState; +import com.vaadin.ui.declarative.DesignContext; /** * CssLayout is a layout component that can be used in browser environment only. @@ -358,4 +361,46 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { return components.get(index); } + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes + * .Element, com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void synchronizeFromDesign(Element design, + DesignContext designContext) { + // process default attributes + super.synchronizeFromDesign(design, designContext); + // remove current children + removeAllComponents(); + // handle children + for (Element childComponent : design.children()) { + DesignSynchronizable newChild = designContext + .createChild(childComponent); + addComponent(newChild); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element + * , com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void synchronizeToDesign(Element design, DesignContext designContext) { + // synchronize default attributes + super.synchronizeToDesign(design, designContext); + // handle children + Element designElement = design; + for (Component child : this) { + DesignSynchronizable childComponent = (DesignSynchronizable) child; + Element childNode = designContext.createNode(childComponent); + designElement.appendChild(childNode); + } + } + } |