diff options
author | michaelvogt <michael@vaadin.com> | 2013-04-22 10:56:44 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-23 06:47:12 +0000 |
commit | 0584f4a9a5ec602e421f969dc91029891605dea5 (patch) | |
tree | 741508ccb19758e9dab9ed245fcffc0f11d16b00 /server/src/com/vaadin/ui/Tree.java | |
parent | 8fec88fe776abbde4250719c46d025392bce39c8 (diff) | |
download | vaadin-framework-0584f4a9a5ec602e421f969dc91029891605dea5.tar.gz vaadin-framework-0584f4a9a5ec602e421f969dc91029891605dea5.zip |
Simplify and clarify WAI-ARIA API (#11659)
Change-Id: I8daf3f377d4d9f2c2f774781e0c68f550d5c86e0
Diffstat (limited to 'server/src/com/vaadin/ui/Tree.java')
-rw-r--r-- | server/src/com/vaadin/ui/Tree.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index 64854ebcdf..a5c3819edd 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -72,6 +72,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, /* Private members */ + private static final String NULL_ALT_EXCEPTION_MESSAGE = "Parameter 'altText' needs to be non null"; + /** * Item icons alt texts. */ @@ -182,7 +184,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * the icon to use or null. * * @param altText - * String with the alternative text for the icon + * the alternative text for the icon */ public void setItemIcon(Object itemId, Resource icon, String altText) { if (itemId != null) { @@ -191,8 +193,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (icon == null) { itemIconAlts.remove(itemId); } else if (altText == null) { - throw new IllegalArgumentException( - "Parameter 'altText' needs to be non null"); + throw new IllegalArgumentException(NULL_ALT_EXCEPTION_MESSAGE); } else { itemIconAlts.put(itemId, altText); } @@ -201,6 +202,26 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } /** + * Set the alternate text for an item. + * + * Used when the item has an icon. + * + * @param itemId + * the id of the item to be assigned an icon. + * @param altText + * the alternative text for the icon + */ + public void setItemIconAlternateText(Object itemId, String altText) { + if (itemId != null) { + if (altText == null) { + throw new IllegalArgumentException(NULL_ALT_EXCEPTION_MESSAGE); + } else { + itemIconAlts.put(itemId, altText); + } + } + } + + /** * Return the alternate text of an icon in a tree item. * * @param itemId |