From 88b3d7f78058f9c3b5b8e32982840d7280c0efab Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 19 Apr 2011 13:20:32 +0000 Subject: #1410 getListeners method for all classes that have addListener/removeListener svn changeset:18390/svn branch:6.6 --- src/com/vaadin/data/util/AbstractContainer.java | 21 +++++++++++++++++++++ src/com/vaadin/data/util/AbstractProperty.java | 22 ++++++++++++++++++++++ src/com/vaadin/data/util/IndexedContainer.java | 13 +++++++++++++ src/com/vaadin/data/util/PropertysetItem.java | 13 +++++++++++++ 4 files changed, 69 insertions(+) (limited to 'src/com/vaadin/data') diff --git a/src/com/vaadin/data/util/AbstractContainer.java b/src/com/vaadin/data/util/AbstractContainer.java index 53b9e75ba8..eed58c578a 100644 --- a/src/com/vaadin/data/util/AbstractContainer.java +++ b/src/com/vaadin/data/util/AbstractContainer.java @@ -2,6 +2,7 @@ package com.vaadin.data.util; import java.io.Serializable; import java.util.Collection; +import java.util.Collections; import java.util.EventObject; import java.util.LinkedList; @@ -222,4 +223,24 @@ public abstract class AbstractContainer implements Container { return itemSetChangeListeners; } + public Collection getListeners(Class eventType) { + if (Container.PropertySetChangeEvent.class.isAssignableFrom(eventType)) { + if (propertySetChangeListeners == null) { + return Collections.EMPTY_LIST; + } else { + return Collections + .unmodifiableCollection(propertySetChangeListeners); + } + } else if (Container.ItemSetChangeEvent.class + .isAssignableFrom(eventType)) { + if (itemSetChangeListeners == null) { + return Collections.EMPTY_LIST; + } else { + return Collections + .unmodifiableCollection(itemSetChangeListeners); + } + } + + return Collections.EMPTY_LIST; + } } diff --git a/src/com/vaadin/data/util/AbstractProperty.java b/src/com/vaadin/data/util/AbstractProperty.java index 2b3fcf2c93..953ab664a3 100644 --- a/src/com/vaadin/data/util/AbstractProperty.java +++ b/src/com/vaadin/data/util/AbstractProperty.java @@ -1,5 +1,7 @@ package com.vaadin.data.util; +import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import com.vaadin.data.Property; @@ -191,4 +193,24 @@ public abstract class AbstractProperty implements Property, } } + public Collection getListeners(Class eventType) { + if (Property.ValueChangeEvent.class.isAssignableFrom(eventType)) { + if (valueChangeListeners == null) { + return Collections.EMPTY_LIST; + } else { + return Collections.unmodifiableCollection(valueChangeListeners); + } + } else if (Property.ReadOnlyStatusChangeEvent.class + .isAssignableFrom(eventType)) { + if (readOnlyStatusChangeListeners == null) { + return Collections.EMPTY_LIST; + } else { + return Collections + .unmodifiableCollection(readOnlyStatusChangeListeners); + } + } + + return Collections.EMPTY_LIST; + } + } diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java index 11e4c702ed..11ab3c2728 100644 --- a/src/com/vaadin/data/util/IndexedContainer.java +++ b/src/com/vaadin/data/util/IndexedContainer.java @@ -531,6 +531,19 @@ public class IndexedContainer extends } + @Override + public Collection getListeners(Class eventType) { + if (Property.ValueChangeEvent.class.isAssignableFrom(eventType)) { + if (propertyValueChangeListeners == null) { + return Collections.EMPTY_LIST; + } else { + return Collections + .unmodifiableCollection(propertyValueChangeListeners); + } + } + return super.getListeners(eventType); + } + @Override protected void fireItemAdded(int position, Object itemId, Item item) { if (position >= 0) { diff --git a/src/com/vaadin/data/util/PropertysetItem.java b/src/com/vaadin/data/util/PropertysetItem.java index 75f9114bc7..38be8561d0 100644 --- a/src/com/vaadin/data/util/PropertysetItem.java +++ b/src/com/vaadin/data/util/PropertysetItem.java @@ -220,6 +220,19 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, } } + public Collection getListeners(Class eventType) { + if (Item.PropertySetChangeEvent.class.isAssignableFrom(eventType)) { + if (propertySetChangeListeners == null) { + return Collections.EMPTY_LIST; + } else { + return Collections + .unmodifiableCollection(propertySetChangeListeners); + } + } + + return Collections.EMPTY_LIST; + } + /** * Creates and returns a copy of this object. *

-- cgit v1.2.3