You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MethodEventSource.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.itmill.toolkit.event;
  5. import java.lang.reflect.Method;
  6. /**
  7. * <p>
  8. * Interface for classes supporting registeration of methods as event receivers.
  9. * </p>
  10. *
  11. * <p>
  12. * For more information on the inheritable event mechanism see the
  13. * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
  14. * </p>
  15. *
  16. * @author IT Mill Ltd.
  17. * @version
  18. * @VERSION@
  19. * @since 3.0
  20. */
  21. public interface MethodEventSource {
  22. /**
  23. * <p>
  24. * Registers a new event listener with the specified activation method to
  25. * listen events generated by this component. If the activation method does
  26. * not have any arguments the event object will not be passed to it when
  27. * it's called.
  28. * </p>
  29. *
  30. * <p>
  31. * For more information on the inheritable event mechanism see the
  32. * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
  33. * </p>
  34. *
  35. * @param eventType
  36. * the type of the listened event. Events of this type or its
  37. * subclasses activate the listener.
  38. * @param object
  39. * the object instance who owns the activation method.
  40. * @param method
  41. * the activation method.
  42. * @throws java.lang.IllegalArgumentException
  43. * unless <code>method</code> has exactly one match in
  44. * <code>object</code>
  45. */
  46. public void addListener(Class eventType, Object object, Method method);
  47. /**
  48. * <p>
  49. * Registers a new listener with the specified activation method to listen
  50. * events generated by this component. If the activation method does not
  51. * have any arguments the event object will not be passed to it when it's
  52. * called.
  53. * </p>
  54. *
  55. * <p>
  56. * This version of <code>addListener</code> gets the name of the
  57. * activation method as a parameter. The actual method is reflected from
  58. * <code>object</code>, and unless exactly one match is found,
  59. * <code>java.lang.IllegalArgumentException</code> is thrown.
  60. * </p>
  61. *
  62. * <p>
  63. * For more information on the inheritable event mechanism see the
  64. * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
  65. * </p>
  66. *
  67. * @param eventType
  68. * the type of the listened event. Events of this type or its
  69. * subclasses activate the listener.
  70. * @param object
  71. * the object instance who owns the activation method.
  72. * @param methodName
  73. * the name of the activation method.
  74. * @throws java.lang.IllegalArgumentException
  75. * unless <code>method</code> has exactly one match in
  76. * <code>object</code>
  77. */
  78. public void addListener(Class eventType, Object object, String methodName);
  79. /**
  80. * Removes all registered listeners matching the given parameters. Since
  81. * this method receives the event type and the listener object as
  82. * parameters, it will unregister all <code>object</code>'s methods that
  83. * are registered to listen to events of type <code>eventType</code>
  84. * generated by this component.
  85. *
  86. * <p>
  87. * For more information on the inheritable event mechanism see the
  88. * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
  89. * </p>
  90. *
  91. * @param eventType
  92. * the exact event type the <code>object</code> listens to.
  93. * @param target
  94. * the target object that has registered to listen to events
  95. * of type <code>eventType</code> with one or more methods.
  96. */
  97. public void removeListener(Class eventType, Object target);
  98. /**
  99. * Removes one registered listener method. The given method owned by the
  100. * given object will no longer be called when the specified events are
  101. * generated by this component.
  102. *
  103. * <p>
  104. * For more information on the inheritable event mechanism see the
  105. * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
  106. * </p>
  107. *
  108. * @param eventType
  109. * the exact event type the <code>object</code> listens to.
  110. * @param target
  111. * the target object that has registered to listen to events
  112. * of type eventType with one or more methods.
  113. * @param method
  114. * the method owned by the target that's registered to listen
  115. * to events of type eventType.
  116. */
  117. public void removeListener(Class eventType, Object target, Method method);
  118. /**
  119. * <p>
  120. * Removes one registered listener method. The given method owned by the
  121. * given object will no longer be called when the specified events are
  122. * generated by this component.
  123. * </p>
  124. *
  125. * <p>
  126. * This version of <code>removeListener</code> gets the name of the
  127. * activation method as a parameter. The actual method is reflected from the
  128. * target, and unless exactly one match is found,
  129. * <code>java.lang.IllegalArgumentException</code> is thrown.
  130. * </p>
  131. *
  132. * <p>
  133. * For more information on the inheritable event mechanism see the
  134. * {@link com.itmill.toolkit.event com.itmill.toolkit.event package documentation}.
  135. * </p>
  136. *
  137. * @param eventType
  138. * the exact event type the <code>object</code> listens to.
  139. * @param target
  140. * the target object that has registered to listen to events
  141. * of type <code>eventType</code> with one or more methods.
  142. * @param methodName
  143. * the name of the method owned by <code>target</code>
  144. * that's registered to listen to events of type
  145. * <code>eventType</code>.
  146. */
  147. public void removeListener(Class eventType, Object target, String methodName);
  148. }