From: Artur Signell Date: Tue, 6 Nov 2012 15:36:39 +0000 (+0200) Subject: Moved EventRouter from AbstractComponent to AbstractClientConnector (#9342) X-Git-Tag: 7.0.0.beta9~44 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a7624344b46509afdcdf2424c3dbade627c03c64;p=vaadin-framework.git Moved EventRouter from AbstractComponent to AbstractClientConnector (#9342) Change-Id: I33981f0c80ab367d74bbbeebb48abbc81d4f182c --- diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java index 0e81224ccc..490f23e186 100644 --- a/server/src/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/com/vaadin/server/AbstractClientConnector.java @@ -24,6 +24,7 @@ import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.EventObject; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -34,9 +35,13 @@ import java.util.logging.Logger; import org.json.JSONException; import org.json.JSONObject; +import com.vaadin.event.EventRouter; +import com.vaadin.event.MethodEventSource; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.SharedState; +import com.vaadin.shared.ui.ComponentStateUtil; +import com.vaadin.ui.Component.Event; import com.vaadin.ui.HasComponents; import com.vaadin.ui.UI; @@ -47,7 +52,8 @@ import com.vaadin.ui.UI; * @author Vaadin Ltd * @since 7.0.0 */ -public abstract class AbstractClientConnector implements ClientConnector { +public abstract class AbstractClientConnector implements ClientConnector, + MethodEventSource { /** * A map from client to server RPC interface class to the RPC call manager * that handles incoming RPC calls for that interface. @@ -79,6 +85,15 @@ public abstract class AbstractClientConnector implements ClientConnector { private ClientConnector parent; + /** + * The EventRouter used for the event model. + * + * @deprecated The EventRouter will be replaced by an EventRouter which does + * not use reflection in Vaadin 7.0.0. See #8640. + */ + @Deprecated + private EventRouter eventRouter = null; + /** * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead */ @@ -628,4 +643,302 @@ public abstract class AbstractClientConnector implements ClientConnector { getState().resources.put(key, resourceReference); } } + + /* Listener code starts. Should be refactored. */ + + /** + *

+ * 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. + *

+ * + *

+ * This method additionally informs the event-api to route events with the + * given eventIdentifier to the components handleEvent function call. + *

+ * + *

+ * 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 + * @deprecated The EventRouter will be replaced by an EventRouter which does + * not use reflection in Vaadin 7.0.0. See #8640. + */ + @Deprecated + 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); + } + } + + /** + * 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); + } + + /** + * 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 object's methods that are + * registered to listen to events of type eventType generated + * by this component. + * + *

+ * This method additionally informs the event-api to stop routing events + * with the given eventIdentifier to the components handleEvent function + * call. + *

+ * + *

+ * 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 object listens to. + * @param target + * the target object that has registered to listen to events of + * type eventType 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); + } + } + } + + /** + *

+ * 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. + *

+ * + *

+ * 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. + * + * @deprecated The EventRouter will be replaced by an EventRouter which does + * not use reflection in Vaadin 7.0.0. See #8640. + */ + @Override + @Deprecated + public void addListener(Class eventType, Object target, Method method) { + if (eventRouter == null) { + eventRouter = new EventRouter(); + } + eventRouter.addListener(eventType, target, method); + } + + /** + *

+ * 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. + *

+ * + *

+ * This version of addListener gets the name of the activation + * method as a parameter. The actual method is reflected from + * object, and unless exactly one match is found, + * java.lang.IllegalArgumentException is thrown. + *

+ * + *

+ * For more information on the inheritable event mechanism see the + * {@link com.vaadin.event com.vaadin.event package documentation}. + *

+ * + *

+ * 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 The EventRouter will be replaced by an EventRouter which does + * not use reflection in Vaadin 7.0.0. See #8640. + */ + @Override + @Deprecated + public void addListener(Class eventType, Object target, String methodName) { + if (eventRouter == null) { + eventRouter = new EventRouter(); + } + eventRouter.addListener(eventType, target, methodName); + } + + /** + * 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 object's methods that are + * registered to listen to events of type eventType generated + * by this component. + * + *

+ * 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 object listens to. + * @param target + * the target object that has registered to listen to events of + * type eventType with one or more methods. + */ + @Override + public void removeListener(Class eventType, Object target) { + if (eventRouter != null) { + eventRouter.removeListener(eventType, target); + } + } + + /** + * 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. + * + *

+ * 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 object listens to. + * @param target + * target object that has registered to listen to events of type + * eventType with one or more methods. + * @param method + * the method owned by target that's registered to + * listen to events of type eventType. + * @deprecated The EventRouter will be replaced by an EventRouter which does + * not use reflection in Vaadin 7.0.0. See #8640. + */ + @Override + @Deprecated + public void removeListener(Class eventType, Object target, Method method) { + if (eventRouter != null) { + eventRouter.removeListener(eventType, target, method); + } + } + + /** + *

+ * 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. + *

+ * + *

+ * This version of removeListener gets the name of the + * activation method as a parameter. The actual method is reflected from + * target, and unless exactly one match is found, + * java.lang.IllegalArgumentException is thrown. + *

+ * + *

+ * 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 object listens to. + * @param target + * the target object that has registered to listen to events of + * type eventType with one or more methods. + * @param methodName + * the name of the method owned by target that's + * registered to listen to events of type eventType. + */ + @Override + public void removeListener(Class eventType, Object target, + String methodName) { + if (eventRouter != null) { + eventRouter.removeListener(eventType, target, methodName); + } + } + + /** + * 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); + } + + /** + * 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); + } + + } + } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index fb550fa944..5589223ac5 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -19,8 +19,6 @@ package com.vaadin.ui; import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -28,8 +26,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.vaadin.event.ActionManager; -import com.vaadin.event.EventRouter; -import com.vaadin.event.MethodEventSource; import com.vaadin.event.ShortcutListener; import com.vaadin.server.AbstractClientConnector; import com.vaadin.server.ClientConnector; @@ -54,7 +50,7 @@ import com.vaadin.util.ReflectTools; */ @SuppressWarnings("serial") public abstract class AbstractComponent extends AbstractClientConnector - implements Component, MethodEventSource { + implements Component { /* Private members */ @@ -64,15 +60,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ private Object applicationData; - /** - * The EventRouter used for the event model. - * - * @deprecated The EventRouter will be replaced by an EventRouter which does - * not use reflection in Vaadin 7.0.0. See #8640. - */ - @Deprecated - private EventRouter eventRouter = null; - /** * The internal error message of the component. */ @@ -669,301 +656,6 @@ public abstract class AbstractComponent extends AbstractClientConnector .findMethod(Component.Listener.class, "componentEvent", Component.Event.class); - /** - *

- * 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. - *

- * - *

- * This method additionally informs the event-api to route events with the - * given eventIdentifier to the components handleEvent function call. - *

- * - *

- * 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 - * @deprecated The EventRouter will be replaced by an EventRouter which does - * not use reflection in Vaadin 7.0.0. See #8640. - */ - @Deprecated - 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); - } - } - - /** - * 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); - } - - /** - * 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 object's methods that are - * registered to listen to events of type eventType generated - * by this component. - * - *

- * This method additionally informs the event-api to stop routing events - * with the given eventIdentifier to the components handleEvent function - * call. - *

- * - *

- * 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 object listens to. - * @param target - * the target object that has registered to listen to events of - * type eventType 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); - } - } - } - - /** - *

- * 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. - *

- * - *

- * 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. - * - * @deprecated The EventRouter will be replaced by an EventRouter which does - * not use reflection in Vaadin 7.0.0. See #8640. - */ - @Override - @Deprecated - public void addListener(Class eventType, Object target, Method method) { - if (eventRouter == null) { - eventRouter = new EventRouter(); - } - eventRouter.addListener(eventType, target, method); - } - - /** - *

- * 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. - *

- * - *

- * This version of addListener gets the name of the activation - * method as a parameter. The actual method is reflected from - * object, and unless exactly one match is found, - * java.lang.IllegalArgumentException is thrown. - *

- * - *

- * For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package documentation}. - *

- * - *

- * 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 The EventRouter will be replaced by an EventRouter which does - * not use reflection in Vaadin 7.0.0. See #8640. - */ - @Override - @Deprecated - public void addListener(Class eventType, Object target, String methodName) { - if (eventRouter == null) { - eventRouter = new EventRouter(); - } - eventRouter.addListener(eventType, target, methodName); - } - - /** - * 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 object's methods that are - * registered to listen to events of type eventType generated - * by this component. - * - *

- * 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 object listens to. - * @param target - * the target object that has registered to listen to events of - * type eventType with one or more methods. - */ - @Override - public void removeListener(Class eventType, Object target) { - if (eventRouter != null) { - eventRouter.removeListener(eventType, target); - } - } - - /** - * 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. - * - *

- * 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 object listens to. - * @param target - * target object that has registered to listen to events of type - * eventType with one or more methods. - * @param method - * the method owned by target that's registered to - * listen to events of type eventType. - * @deprecated The EventRouter will be replaced by an EventRouter which does - * not use reflection in Vaadin 7.0.0. See #8640. - */ - @Override - @Deprecated - public void removeListener(Class eventType, Object target, Method method) { - if (eventRouter != null) { - eventRouter.removeListener(eventType, target, method); - } - } - - /** - *

- * 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. - *

- * - *

- * This version of removeListener gets the name of the - * activation method as a parameter. The actual method is reflected from - * target, and unless exactly one match is found, - * java.lang.IllegalArgumentException is thrown. - *

- * - *

- * 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 object listens to. - * @param target - * the target object that has registered to listen to events of - * type eventType with one or more methods. - * @param methodName - * the name of the method owned by target that's - * registered to listen to events of type eventType. - */ - @Override - public void removeListener(Class eventType, Object target, - String methodName) { - if (eventRouter != null) { - eventRouter.removeListener(eventType, target, methodName); - } - } - - /** - * 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); - } - - /** - * Sends the event to all listeners. - * - * @param event - * the Event to be sent to all listeners. - */ - protected void fireEvent(Component.Event event) { - if (eventRouter != null) { - eventRouter.fireEvent(event); - } - - } - /* Component event framework */ /* diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 36868c41e9..187d5b8590 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -753,8 +753,9 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * @return the source component of the event */ public Component getComponent() { - return (Component) getSource(); + return getSource(); } + } /** diff --git a/shared/src/com/vaadin/shared/ComponentState.java b/shared/src/com/vaadin/shared/ComponentState.java index 2ecf09b422..d8b5fec587 100644 --- a/shared/src/com/vaadin/shared/ComponentState.java +++ b/shared/src/com/vaadin/shared/ComponentState.java @@ -17,7 +17,6 @@ package com.vaadin.shared; import java.util.List; -import java.util.Set; import com.vaadin.shared.communication.SharedState; @@ -40,10 +39,6 @@ public class ComponentState extends SharedState { public List styles = null; public String id = null; public String primaryStyleName = null; - /** - * A set of event identifiers with registered listeners. - */ - public Set registeredEventListeners = null; // HTML formatted error message for the component // TODO this could be an object with more information, but currently the UI diff --git a/shared/src/com/vaadin/shared/communication/SharedState.java b/shared/src/com/vaadin/shared/communication/SharedState.java index 4473eba7a0..45cfd8644a 100644 --- a/shared/src/com/vaadin/shared/communication/SharedState.java +++ b/shared/src/com/vaadin/shared/communication/SharedState.java @@ -19,6 +19,7 @@ package com.vaadin.shared.communication; import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Set; import com.vaadin.shared.Connector; @@ -60,4 +61,9 @@ public class SharedState implements Serializable { public Map resources = new HashMap(); public boolean enabled = true; + /** + * A set of event identifiers with registered listeners. + */ + public Set registeredEventListeners = null; + } diff --git a/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java b/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java index 5e6700b425..33f841fa09 100644 --- a/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java +++ b/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java @@ -3,6 +3,7 @@ package com.vaadin.shared.ui; import java.util.HashSet; import com.vaadin.shared.ComponentState; +import com.vaadin.shared.communication.SharedState; public final class ComponentStateUtil { @@ -40,8 +41,8 @@ public final class ComponentStateUtil { * @param eventListenerId * The event identifier to remove */ - public static final void removeRegisteredEventListener( - ComponentState state, String eventIdentifier) { + public static final void removeRegisteredEventListener(SharedState state, + String eventIdentifier) { if (state.registeredEventListeners == null) { return; } @@ -57,7 +58,7 @@ public final class ComponentStateUtil { * @param eventListenerId * The event identifier to add */ - public static final void addRegisteredEventListener(ComponentState state, + public static final void addRegisteredEventListener(SharedState state, String eventListenerId) { if (state.registeredEventListeners == null) { state.registeredEventListeners = new HashSet(); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java index 408b04b3b4..62ce727531 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java @@ -1,27 +1,39 @@ package com.vaadin.tests.minitutorials.v7a3; -import java.util.ArrayList; -import java.util.List; +import java.lang.reflect.Method; +import java.util.EventObject; import com.vaadin.server.AbstractExtension; import com.vaadin.tests.widgetset.client.minitutorials.v7a3.RefresherRpc; import com.vaadin.tests.widgetset.client.minitutorials.v7a3.RefresherState; import com.vaadin.ui.UI; +import com.vaadin.util.ReflectTools; public class Refresher extends AbstractExtension { public interface RefreshListener { - public void refresh(Refresher source); + static Method METHOD = ReflectTools.findMethod(RefreshListener.class, + "refresh", RefreshEvent.class); + + public void refresh(RefreshEvent refreshEvent); } - private List listeners = new ArrayList(); + public class RefreshEvent extends EventObject { + + public RefreshEvent(Refresher refresher) { + super(refresher); + } + + public Refresher getRefresher() { + return (Refresher) getSource(); + } + + } public Refresher() { registerRpc(new RefresherRpc() { @Override public void refresh() { - for (RefreshListener listener : listeners) { - listener.refresh(Refresher.this); - } + fireEvent(new RefreshEvent(Refresher.this)); } }); } @@ -47,12 +59,13 @@ public class Refresher extends AbstractExtension { return getState().enabled; } - public void addListener(RefreshListener listener) { - listeners.add(listener); + public void addRefreshListener(RefreshListener listener) { + super.addListener(RefreshEvent.class, listener, RefreshListener.METHOD); } - public void removeListener(RefreshListener listener) { - listeners.remove(listener); + public void removeRefreshListener(RefreshListener listener) { + super.removeListener(RefreshEvent.class, listener, + RefreshListener.METHOD); } public void extend(UI target) { diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java index c849cdce36..0b2fad21aa 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java @@ -19,6 +19,7 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.minitutorials.v7a3.Refresher.RefreshEvent; import com.vaadin.tests.minitutorials.v7a3.Refresher.RefreshListener; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.ui.Button; @@ -32,9 +33,9 @@ public class RefresherTestUI extends AbstractTestUI { final Refresher refresher = new Refresher(); refresher.extend(this); refresher.setInterval(1000); - refresher.addListener(new RefreshListener() { + refresher.addRefreshListener(new RefreshListener() { @Override - public void refresh(Refresher source) { + public void refresh(RefreshEvent event) { System.out.println("Got refresh"); } });