From 5f4b96d3781a067d0e2dab5c573674bce293e6dd Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 9 Aug 2011 11:02:22 +0000 Subject: #5402 Support html in OptionGroup items svn changeset:20217/svn branch:6.7 --- .../vaadin/terminal/gwt/client/ui/VOptionGroup.java | 19 +++++++++++++++++-- src/com/vaadin/ui/OptionGroup.java | 12 ++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java index 51702cdf8a..eb3da57183 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java @@ -31,6 +31,8 @@ import com.vaadin.terminal.gwt.client.UIDL; public class VOptionGroup extends VOptionGroupBase implements FocusHandler, BlurHandler { + public static final String HTML_CONTENT_ALLOWED = "htmlcontentallowed"; + public static final String CLASSNAME = "v-select-optiongroup"; private final Panel panel; @@ -51,6 +53,8 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, */ private boolean blurOccured = false; + private boolean htmlItems = false; + public VOptionGroup() { super(CLASSNAME); panel = (Panel) optionsContainer; @@ -59,6 +63,12 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + if (uidl.hasAttribute(HTML_CONTENT_ALLOWED) + && uidl.getBooleanAttribute(HTML_CONTENT_ALLOWED)) { + htmlItems = true; + } else { + htmlItems = false; + } super.updateFromUIDL(uidl, client); sendFocusEvents = client.hasEventListeners(this, EventId.FOCUS); @@ -101,11 +111,16 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { final UIDL opUidl = (UIDL) it.next(); CheckBox op; + String caption = opUidl.getStringAttribute("caption"); if (isMultiselect()) { op = new VCheckBox(); - op.setText(opUidl.getStringAttribute("caption")); + if (htmlItems) { + op.setHTML(caption); + } else { + op.setText(caption); + } } else { - op = new RadioButton(id, opUidl.getStringAttribute("caption")); + op = new RadioButton(id, caption, htmlItems); op.setStyleName("v-radiobutton"); } op.addStyleName(CLASSNAME_OPTION); diff --git a/src/com/vaadin/ui/OptionGroup.java b/src/com/vaadin/ui/OptionGroup.java index c1b52c4a82..ba300131bb 100644 --- a/src/com/vaadin/ui/OptionGroup.java +++ b/src/com/vaadin/ui/OptionGroup.java @@ -28,6 +28,7 @@ public class OptionGroup extends AbstractSelect implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { private Set disabledItemIds = new HashSet(); + private boolean htmlContentAllowed = false; public OptionGroup() { super(); @@ -48,6 +49,8 @@ public class OptionGroup extends AbstractSelect implements @Override public void paintContent(PaintTarget target) throws PaintException { target.addAttribute("type", "optiongroup"); + target.addAttribute(VOptionGroup.HTML_CONTENT_ALLOWED, + htmlContentAllowed); super.paintContent(target); } @@ -167,4 +170,13 @@ public class OptionGroup extends AbstractSelect implements } return true; } + + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + requestRepaint(); + } + + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } } -- cgit v1.2.3