summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-08-09 11:02:22 +0000
committerLeif Åstrand <leif@vaadin.com>2011-08-09 11:02:22 +0000
commit5f4b96d3781a067d0e2dab5c573674bce293e6dd (patch)
tree76d504911023600dc1e91fc06b9ead3f59ee618a /src
parentd466631972402aec6425e6b0a4b7508cd37ba582 (diff)
downloadvaadin-framework-5f4b96d3781a067d0e2dab5c573674bce293e6dd.tar.gz
vaadin-framework-5f4b96d3781a067d0e2dab5c573674bce293e6dd.zip
#5402 Support html in OptionGroup items
svn changeset:20217/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VOptionGroup.java19
-rw-r--r--src/com/vaadin/ui/OptionGroup.java12
2 files changed, 29 insertions, 2 deletions
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<Object> disabledItemIds = new HashSet<Object>();
+ 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;
+ }
}