コード例 #1
0
 /**
  * Removes all registered listeners matching the given parameters. Since this method receives the
  * event type and the listener object as parameters, it will unregister all <code>object</code>'s
  * methods that are registered to listen to events of type <code>eventType</code> generated by
  * this component.
  *
  * <p>This method additionally informs the event-api to stop routing events with the given
  * eventIdentifier to the components handleEvent function call.
  *
  * <p>For more information on the inheritable event mechanism see the {@link com.vaadin.event
  * com.vaadin.event package documentation}.
  *
  * @param eventIdentifier the identifier of the event to stop listening for
  * @param eventType the exact event type the <code>object</code> listens to.
  * @param target the target object that has registered to listen to events of type <code>eventType
  *     </code> with one or more methods.
  * @since 6.2
  */
 protected void removeListener(String eventIdentifier, Class<?> eventType, Object target) {
   if (eventRouter != null) {
     eventRouter.removeListener(eventType, target);
     if (!eventRouter.hasListeners(eventType)) {
       ComponentStateUtil.removeRegisteredEventListener(getState(), eventIdentifier);
     }
   }
 }
コード例 #2
0
  /**
   * Registers a new listener with the specified activation method to listen events generated by
   * this component. If the activation method does not have any arguments the event object will not
   * be passed to it when it's called.
   *
   * <p>This method additionally informs the event-api to route events with the given
   * eventIdentifier to the components handleEvent function call.
   *
   * <p>For more information on the inheritable event mechanism see the {@link com.vaadin.event
   * com.vaadin.event package documentation}.
   *
   * @param eventIdentifier the identifier of the event to listen for
   * @param eventType the type of the listened event. Events of this type or its subclasses activate
   *     the listener.
   * @param target the object instance who owns the activation method.
   * @param method the activation method.
   * @since 6.2
   */
  protected void addListener(
      String eventIdentifier, Class<?> eventType, Object target, Method method) {
    if (eventRouter == null) {
      eventRouter = new EventRouter();
    }
    boolean needRepaint = !eventRouter.hasListeners(eventType);
    eventRouter.addListener(eventType, target, method);

    if (needRepaint) {
      ComponentStateUtil.addRegisteredEventListener(getState(), eventIdentifier);
    }
  }
コード例 #3
0
  /**
   * 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 (eventRouter == null) {
      return Collections.EMPTY_LIST;
    }

    return eventRouter.getListeners(eventType);
  }
コード例 #4
0
 /**
  * Removes one registered listener method. The given method owned by the given object will no
  * longer be called when the specified events are generated by this component.
  *
  * <p>This version of <code>removeListener</code> gets the name of the activation method as a
  * parameter. The actual method is reflected from <code>target</code>, and unless exactly one
  * match is found, <code>java.lang.IllegalArgumentException</code> is thrown.
  *
  * <p>For more information on the inheritable event mechanism see the {@link com.vaadin.event
  * com.vaadin.event package documentation}.
  *
  * @param eventType the exact event type the <code>object</code> listens to.
  * @param target the target object that has registered to listen to events of type <code>eventType
  *     </code> with one or more methods.
  * @param methodName the name of the method owned by <code>target</code> that's registered to
  *     listen to events of type <code>eventType</code>.
  * @deprecated As of 7.0. This method should be avoided. Use {@link #removeListener(Class, Object,
  *     Method)} instead.
  */
 @Deprecated
 @Override
 public void removeListener(Class<?> eventType, Object target, String methodName) {
   if (eventRouter != null) {
     eventRouter.removeListener(eventType, target, methodName);
   }
 }
コード例 #5
0
 /**
  * Registers a new listener with the specified activation method to listen events generated by
  * this component. If the activation method does not have any arguments the event object will not
  * be passed to it when it's called.
  *
  * <p>For more information on the inheritable event mechanism see the {@link com.vaadin.event
  * com.vaadin.event package documentation}.
  *
  * @param eventType the type of the listened event. Events of this type or its subclasses activate
  *     the listener.
  * @param target the object instance who owns the activation method.
  * @param method the activation method.
  */
 @Override
 public void addListener(Class<?> eventType, Object target, Method method) {
   if (eventRouter == null) {
     eventRouter = new EventRouter();
   }
   eventRouter.addListener(eventType, target, method);
 }
コード例 #6
0
 /**
  * Registers a new listener with the specified activation method to listen events generated by
  * this component. If the activation method does not have any arguments the event object will not
  * be passed to it when it's called.
  *
  * @param eventType the type of the listened event. Events of this type or its subclasses activate
  *     the listener.
  * @param listener the object instance who owns the activation method.
  * @param method the activation method.
  * @return a registration for the listener
  */
 protected Registration addListener(
     Class<?> eventType, DataProviderListener listener, Method method) {
   if (eventRouter == null) {
     eventRouter = new EventRouter();
   }
   return eventRouter.addListener(eventType, listener, method);
 }
コード例 #7
0
 /**
  * Convenience method for registering a new listener with the specified activation method to
  * listen events generated by this component. If the activation method does not have any arguments
  * the event object will not be passed to it when it's called.
  *
  * <p>This version of <code>addListener</code> gets the name of the activation method as a
  * parameter. The actual method is reflected from <code>object</code>, and unless exactly one
  * match is found, <code>java.lang.IllegalArgumentException</code> is thrown.
  *
  * <p>For more information on the inheritable event mechanism see the {@link com.vaadin.event
  * com.vaadin.event package documentation}.
  *
  * <p>Note: Using this method is discouraged because it cannot be checked during compilation. Use
  * {@link #addListener(Class, Object, Method)} or {@link
  * #addListener(com.vaadin.ui.Component.Listener)} instead.
  *
  * @param eventType the type of the listened event. Events of this type or its subclasses activate
  *     the listener.
  * @param target the object instance who owns the activation method.
  * @param methodName the name of the activation method.
  * @deprecated As of 7.0. This method should be avoided. Use {@link #addListener(Class, Object,
  *     Method)} or {@link #addListener(String, Class, Object, Method)} instead.
  */
 @Override
 @Deprecated
 public void addListener(Class<?> eventType, Object target, String methodName) {
   if (eventRouter == null) {
     eventRouter = new EventRouter();
   }
   eventRouter.addListener(eventType, target, methodName);
 }
コード例 #8
0
 /**
  * Sends the event to all listeners.
  *
  * @param event the Event to be sent to all listeners.
  */
 protected void fireEvent(EventObject event) {
   if (eventRouter != null) {
     eventRouter.fireEvent(event);
   }
 }
コード例 #9
0
 /**
  * Removes one registered listener method. The given method owned by the given object will no
  * longer be called when the specified events are generated by this component.
  *
  * <p>For more information on the inheritable event mechanism see the {@link com.vaadin.event
  * com.vaadin.event package documentation}.
  *
  * @param eventType the exact event type the <code>object</code> listens to.
  * @param target target object that has registered to listen to events of type <code>eventType
  *     </code> with one or more methods.
  * @param method the method owned by <code>target</code> that's registered to listen to events of
  *     type <code>eventType</code>.
  */
 @Override
 public void removeListener(Class<?> eventType, Object target, Method method) {
   if (eventRouter != null) {
     eventRouter.removeListener(eventType, target, method);
   }
 }
コード例 #10
0
 /**
  * Checks if the given {@link Event} type is listened for this component.
  *
  * @param eventType the event type to be checked
  * @return true if a listener is registered for the given event type
  */
 protected boolean hasListeners(Class<?> eventType) {
   return eventRouter != null && eventRouter.hasListeners(eventType);
 }
コード例 #11
0
 /**
  * Removes all registered listeners matching the given parameters. Since this method receives the
  * event type and the listener object as parameters, it will unregister all <code>object</code>'s
  * methods that are registered to listen to events of type <code>eventType</code> generated by
  * this component.
  *
  * @param eventType the exact event type the <code>object</code> listens to.
  * @param listener the target object that has registered to listen to events of type <code>
  *     eventType</code> with one or more methods.
  */
 protected void removeListener(Class<?> eventType, DataProviderListener listener) {
   if (eventRouter != null) {
     eventRouter.removeListener(eventType, listener);
   }
 }