diff options
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r-- | server/src/com/vaadin/ui/Button.java | 46 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Label.java | 49 |
2 files changed, 95 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index e58ad7bee5..809fbd5e55 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -18,6 +18,9 @@ package com.vaadin.ui; import java.io.Serializable; import java.lang.reflect.Method; +import java.util.Collection; + +import org.jsoup.nodes.Element; import com.vaadin.event.Action; import com.vaadin.event.FieldEvents; @@ -35,6 +38,7 @@ import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.button.ButtonServerRpc; import com.vaadin.shared.ui.button.ButtonState; import com.vaadin.ui.Component.Focusable; +import com.vaadin.ui.declarative.DesignContext; import com.vaadin.util.ReflectTools; /** @@ -660,4 +664,46 @@ public class Button extends AbstractComponent implements return getState(false).htmlContentAllowed; } + /* + * (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 content = design.html(); + setCaption(content); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractComponent#getCustomAttributes() + */ + @Override + protected Collection<String> getCustomAttributes() { + Collection<String> result = super.getCustomAttributes(); + result.add("caption"); + 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 = getCaption(); + if (content != null) { + design.html(content); + } + } } 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<String>, 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<String> getCustomAttributes() { + Collection<String> 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()); + } + } } |