diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-06-15 07:09:03 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-06-15 07:09:03 +0000 |
commit | 3c468800e265a1897d74986f0f2c0092720769a0 (patch) | |
tree | f4e094b36dfaa4f472f624db74728bb4e88e5d51 /src/com/vaadin/ui/AbstractSelect.java | |
parent | 2497bb21873ce07fccc595faa2a7538215f5ec2c (diff) | |
download | vaadin-framework-3c468800e265a1897d74986f0f2c0092720769a0.tar.gz vaadin-framework-3c468800e265a1897d74986f0f2c0092720769a0.zip |
Merged fix, sample and tests for "#3720 - Disable Items for OptionGroup" from /branches/6.4-minor-features
svn changeset:13659/svn branch:6.4
Diffstat (limited to 'src/com/vaadin/ui/AbstractSelect.java')
-rw-r--r-- | src/com/vaadin/ui/AbstractSelect.java | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index e8ebdc6724..60dfea0da2 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -316,22 +316,12 @@ public abstract class AbstractSelect extends AbstractField implements final Collection ids = getItemIds(); if (isNullSelectionAllowed() && getNullSelectionItemId() != null && !ids.contains(getNullSelectionItemId())) { - // Gets the option attribute values final Object id = getNullSelectionItemId(); - final String key = itemIdMapper.key(id); - final String caption = getItemCaption(id); - final Resource icon = getItemIcon(id); // Paints option target.startTag("so"); - if (icon != null) { - target.addAttribute("icon", icon); - } - target.addAttribute("caption", caption); - target.addAttribute("nullselection", true); - target.addAttribute("key", key); + paintItem(target, id); if (isSelected(id)) { - target.addAttribute("selected", true); - selectedKeys[keyIndex++] = key; + selectedKeys[keyIndex++] = itemIdMapper.key(id); } target.endTag("so"); } @@ -348,21 +338,11 @@ public abstract class AbstractSelect extends AbstractField implements continue; } final String key = itemIdMapper.key(id); - final String caption = getItemCaption(id); // add listener for each item, to cause repaint if an item changes getCaptionChangeListener().addNotifierForItem(id); - final Resource icon = getItemIcon(id); // Paints the option target.startTag("so"); - if (icon != null) { - target.addAttribute("icon", icon); - } - target.addAttribute("caption", caption); - if (id != null && id.equals(getNullSelectionItemId())) { - target.addAttribute("nullselection", true); - } - target.addAttribute("key", key); + paintItem(target, id); if (isSelected(id) && keyIndex < selectedKeys.length) { - target.addAttribute("selected", true); selectedKeys[keyIndex++] = key; } target.endTag("so"); @@ -378,6 +358,24 @@ public abstract class AbstractSelect extends AbstractField implements } + protected void paintItem(PaintTarget target, Object itemId) + throws PaintException { + final String key = itemIdMapper.key(itemId); + final String caption = getItemCaption(itemId); + final Resource icon = getItemIcon(itemId); + if (icon != null) { + target.addAttribute("icon", icon); + } + target.addAttribute("caption", caption); + if (itemId != null && itemId.equals(getNullSelectionItemId())) { + target.addAttribute("nullselection", true); + } + target.addAttribute("key", key); + if (isSelected(itemId)) { + target.addAttribute("selected", true); + } + } + /** * Invoked when the value of a variable has changed. * |