diff options
author | Artur Signell <artur@vaadin.com> | 2012-11-06 17:36:39 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-07 13:59:29 +0000 |
commit | a7624344b46509afdcdf2424c3dbade627c03c64 (patch) | |
tree | 0c978795ca6387be3fdacc35d49c87cf13bd62bf /uitest | |
parent | db35e488161a33097eb9876c5adc2dbb793fd59e (diff) | |
download | vaadin-framework-a7624344b46509afdcdf2424c3dbade627c03c64.tar.gz vaadin-framework-a7624344b46509afdcdf2424c3dbade627c03c64.zip |
Moved EventRouter from AbstractComponent to AbstractClientConnector (#9342)
Change-Id: I33981f0c80ab367d74bbbeebb48abbc81d4f182c
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/minitutorials/v7a3/Refresher.java | 35 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/minitutorials/v7a3/RefresherTestUI.java | 5 |
2 files changed, 27 insertions, 13 deletions
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<RefreshListener> listeners = new ArrayList<RefreshListener>(); + 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"); } }); |