From 61ea50cec193252032fa7cb3cfa0445135ea0082 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 8 Apr 2011 15:28:28 +0000 Subject: [PATCH] #6780 AbstractSelect's setItemIconPropertyId fails silently svn changeset:18189/svn branch:6.6 --- src/com/vaadin/ui/AbstractSelect.java | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java index ef09becb00..ab17498f7f 100644 --- a/src/com/vaadin/ui/AbstractSelect.java +++ b/src/com/vaadin/ui/AbstractSelect.java @@ -1256,7 +1256,7 @@ public abstract class AbstractSelect extends AbstractField implements *

* If the property id is set to a valid value, each item is given an icon * got from the given property of the items. The type of the property must - * be assignable to Icon. + * be assignable to Resource. *

* *

@@ -1271,14 +1271,23 @@ public abstract class AbstractSelect extends AbstractField implements * . * * @param propertyId - * the Id of the property that specifies icons for items. - */ - public void setItemIconPropertyId(Object propertyId) { - if ((propertyId != null) - && Resource.class.isAssignableFrom(getType(propertyId))) { + * the id of the property that specifies icons for items or null + * @throws IllegalArgumentException + * If the propertyId is not in the container or is not of a + * valid type + */ + public void setItemIconPropertyId(Object propertyId) + throws IllegalArgumentException { + if (propertyId == null) { + itemIconPropertyId = null; + } else if (!getContainerPropertyIds().contains(propertyId)) { + throw new IllegalArgumentException( + "Property id not found in the container"); + } else if (Resource.class.isAssignableFrom(getType(propertyId))) { itemIconPropertyId = propertyId; } else { - itemIconPropertyId = null; + throw new IllegalArgumentException( + "Property id must be assignable to Resource"); } requestRepaint(); } -- 2.39.5