From 1f2c9803152dc26a885067165a6b99a68d85700a Mon Sep 17 00:00:00 2001
From: Artur Signell <artur@vaadin.com>
Date: Thu, 4 Sep 2014 21:57:34 +0300
Subject: Allow captions to contain HTML (#9426)

Change-Id: I4a0e580aef1a97ce69238ea0d476599883928d84
---
 server/src/com/vaadin/ui/AbstractColorPicker.java |  8 +++++--
 server/src/com/vaadin/ui/AbstractComponent.java   | 29 +++++++++++++++++++++++
 server/src/com/vaadin/ui/Button.java              |  7 +++---
 3 files changed, 39 insertions(+), 5 deletions(-)

(limited to 'server/src/com/vaadin')

diff --git a/server/src/com/vaadin/ui/AbstractColorPicker.java b/server/src/com/vaadin/ui/AbstractColorPicker.java
index acf3b2c042..608a42d33b 100644
--- a/server/src/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/com/vaadin/ui/AbstractColorPicker.java
@@ -455,9 +455,11 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
      * @param htmlContentAllowed
      *            <code>true</code> if caption is rendered as HTML,
      *            <code>false</code> otherwise
+     * @deprecated as of , use {@link #setCaptionAsHtml(boolean)} instead
      */
+    @Deprecated
     public void setHtmlContentAllowed(boolean htmlContentAllowed) {
-        getState().htmlContentAllowed = htmlContentAllowed;
+        setCaptionAsHtml(htmlContentAllowed);
     }
 
     /**
@@ -465,8 +467,10 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
      * 
      * @return <code>true</code> if the caption text is to be rendered as HTML,
      *         <code>false</code> otherwise
+     * @deprecated as of , use {@link #isCaptionAsHtml()} instead
      */
+    @Deprecated
     public boolean isHtmlContentAllowed() {
-        return getState(false).htmlContentAllowed;
+        return isCaptionAsHtml();
     }
 }
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 735fb15fd8..9ff6dff21e 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -265,6 +265,35 @@ public abstract class AbstractComponent extends AbstractClientConnector
         getState().caption = caption;
     }
 
+    /**
+     * Sets whether the caption is rendered as HTML.
+     * <p>
+     * If set to true, the captions are rendered in the browser as HTML and the
+     * developer is responsible for ensuring no harmful HTML is used. If set to
+     * false, the caption is rendered in the browser as plain text.
+     * <p>
+     * The default is false, i.e. to render that caption as plain text.
+     * 
+     * @param captionAsHtml
+     *            true if the captions are rendered as HTML, false if rendered
+     *            as plain text
+     */
+    public void setCaptionAsHtml(boolean captionAsHtml) {
+        getState().captionAsHtml = captionAsHtml;
+    }
+
+    /**
+     * Checks whether captions are rendered as HTML
+     * <p>
+     * The default is false, i.e. to render that caption as plain text.
+     * 
+     * @return true if the captions are rendered as HTML, false if rendered as
+     *         plain text
+     */
+    public boolean isCaptionAsHtml() {
+        return getState(false).captionAsHtml;
+    }
+
     /*
      * Don't add a JavaDoc comment here, we use the default documentation from
      * implemented interface.
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index c102157bf1..677f29ba13 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -642,7 +642,7 @@ public class Button extends AbstractComponent implements
 
     /**
      * Set whether the caption text is rendered as HTML or not. You might need
-     * to retheme button to allow higher content than the original text style.
+     * to re-theme button to allow higher content than the original text style.
      * 
      * If set to true, the captions are passed to the browser as html and the
      * developer is responsible for ensuring no harmful html is used. If set to
@@ -653,7 +653,7 @@ public class Button extends AbstractComponent implements
      *            <code>false</code> otherwise
      */
     public void setHtmlContentAllowed(boolean htmlContentAllowed) {
-        getState().htmlContentAllowed = htmlContentAllowed;
+        getState().captionAsHtml = htmlContentAllowed;
     }
 
     /**
@@ -663,7 +663,7 @@ public class Button extends AbstractComponent implements
      *         <code>false</code> otherwise
      */
     public boolean isHtmlContentAllowed() {
-        return getState(false).htmlContentAllowed;
+        return getState(false).captionAsHtml;
     }
 
     /*
@@ -711,6 +711,7 @@ public class Button extends AbstractComponent implements
         result.add("icon-alternate-text");
         result.add("click-shortcut");
         result.add("html-content-allowed");
+        result.add("caption-as-html");
         return result;
     }
 
-- 
cgit v1.2.3