summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui/AbstractComponent.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/ui/AbstractComponent.java')
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index f0938780fe..784ecb262b 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -8,6 +8,7 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -1144,6 +1145,32 @@ public abstract class AbstractComponent implements Component, MethodEventSource
}
/**
+ * Returns all listeners that are registered for the given event type or one
+ * of its subclasses.
+ *
+ * @param eventType
+ * The type of event to return listeners for.
+ * @return A collection with all registered listeners. Empty if no listeners
+ * are found.
+ */
+ public Collection<?> getListeners(Class<?> eventType) {
+ if (eventType.isAssignableFrom(RepaintRequestEvent.class)) {
+ // RepaintRequestListeners are not stored in eventRouter
+ if (repaintRequestListeners == null) {
+ return Collections.EMPTY_LIST;
+ } else {
+ return Collections
+ .unmodifiableCollection(repaintRequestListeners);
+ }
+ }
+ if (eventRouter == null) {
+ return Collections.EMPTY_LIST;
+ }
+
+ return eventRouter.getListeners(eventType);
+ }
+
+ /**
* Sends the event to all listeners.
*
* @param event