From 117bf2b791b70d4e85916acf5e43a5c3b2ba66ca Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Thu, 4 Dec 2014 17:25:05 +0200 Subject: Declarative: handle inner html for Button and Label (#7749). Change-Id: Ie98d633e8583efed142a6a3d2cc980070cbc73f7 --- server/src/com/vaadin/ui/Label.java | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'server/src/com/vaadin/ui/Label.java') diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index c73840e6e9..6001e30446 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -17,8 +17,11 @@ package com.vaadin.ui; import java.lang.reflect.Method; +import java.util.Collection; import java.util.Locale; +import org.jsoup.nodes.Element; + import com.vaadin.data.Property; import com.vaadin.data.util.AbstractProperty; import com.vaadin.data.util.LegacyPropertyHelper; @@ -27,6 +30,7 @@ import com.vaadin.data.util.converter.ConverterUtil; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.LabelState; import com.vaadin.shared.util.SharedUtil; +import com.vaadin.ui.declarative.DesignContext; /** * Label component for showing non-editable short texts. @@ -570,4 +574,49 @@ public class Label extends AbstractComponent implements Property, return LegacyPropertyHelper.legacyPropertyToString(this); } } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.DesignSynchronizable#synchronizeFromDesign(org.jsoup.nodes + * .Element, com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void synchronizeFromDesign(Element design, + DesignContext designContext) { + super.synchronizeFromDesign(design, designContext); + String innerHtml = design.html(); + if (innerHtml != null && !"".equals(innerHtml)) { + setValue(innerHtml); + } + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractComponent#getCustomAttributes() + */ + @Override + protected Collection getCustomAttributes() { + Collection result = super.getCustomAttributes(); + result.add("value"); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.DesignSynchronizable#synchronizeToDesign(org.jsoup.nodes + * .Element, com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void synchronizeToDesign(Element design, DesignContext designContext) { + super.synchronizeToDesign(design, designContext); + String content = getValue(); + if (content != null) { + design.html(getValue()); + } + } } -- cgit v1.2.3