From 1d538feb45ab223ac763bc3b414523697904a80f Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 18 Sep 2015 16:54:46 +0300 Subject: Add Tree.htmlContentsAllowed (#7717) Change-Id: I5c773da806b8358ee203c9c12fd2e2b6fec1970f --- server/src/com/vaadin/ui/Tree.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'server') diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index aac827e5b5..b41139275b 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -616,6 +616,10 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, target.addAttribute("dragMode", dragMode.ordinal()); } + if (isHtmlContentAllowed()) { + target.addAttribute(TreeConstants.ATTRIBUTE_HTML_ALLOWED, true); + } + } // Initialize variables @@ -1310,6 +1314,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, private DropHandler dropHandler; + private boolean htmlContentAllowed; + @Override public void addItemClickListener(ItemClickListener listener) { addListener(TreeConstants.ITEM_CLICK_EVENT_ID, ItemClickEvent.class, @@ -1896,4 +1902,34 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, return element; } + + /** + * Sets whether html is allowed in the item captions. 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 + * false, the content is passed to the browser as plain text. + * The default setting is false + * + * @since + * @param htmlContentAllowed + * true if the captions are used as html, + * false if used as plain text + */ + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + markAsDirty(); + } + + /** + * Checks whether captions are interpreted as html or plain text. + * + * @since + * @return true if the captions are displayed as html, + * false if displayed as plain text + * @see #setHtmlContentAllowed(boolean) + */ + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + } -- cgit v1.2.3