diff options
author | John Ahlroos <john@vaadin.com> | 2012-08-20 13:45:45 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-08-20 13:45:45 +0300 |
commit | 7323ac889012ad62680abd466c77b270597256f7 (patch) | |
tree | 0bcb65e4187c9d30b190a9f8285ad0b7f94a205f | |
parent | 00d45c6036c876686eb3c1305aa07f748ebc8365 (diff) | |
download | vaadin-framework-7323ac889012ad62680abd466c77b270597256f7.tar.gz vaadin-framework-7323ac889012ad62680abd466c77b270597256f7.zip |
Added ServerConnector.removeStateChangeHandler API
-rw-r--r-- | client/src/com/vaadin/terminal/gwt/client/ServerConnector.java | 22 | ||||
-rw-r--r-- | client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java | 16 |
2 files changed, 36 insertions, 2 deletions
diff --git a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java index 8788de74bf..d6479dad86 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java @@ -86,6 +86,15 @@ public interface ServerConnector extends Connector { public HandlerRegistration addStateChangeHandler(StateChangeHandler handler); /** + * Removes a handler that is called whenever any part of the state has been + * updated by the server. + * + * @param handler + * The handler that should be removed. + */ + public void removeStateChangeHandler(StateChangeHandler handler); + + /** * Adds a handler that is called whenever the given part of the state has * been updated by the server. * @@ -101,6 +110,19 @@ public interface ServerConnector extends Connector { StateChangeHandler handler); /** + * Removes a handler that is called whenever any part of the state has been + * updated by the server. + * + * @param propertyName + * the name of the property for which the handler should be + * called + * @param handler + * The handler that should be removed. + */ + public void removeStateChangeHandler(String propertyName, + StateChangeHandler handler); + + /** * Sends the given event to all registered handlers. * * @param event diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index 435fff8a5b..0148f7816c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -42,7 +42,7 @@ import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChange * */ public abstract class AbstractConnector implements ServerConnector, - StateChangeHandler { +StateChangeHandler { private ApplicationConnection connection; private String id; @@ -197,12 +197,24 @@ public abstract class AbstractConnector implements ServerConnector, } @Override + public void removeStateChangeHandler(StateChangeHandler handler) { + ensureHandlerManager().removeHandler(StateChangeEvent.TYPE, handler); + } + + @Override public HandlerRegistration addStateChangeHandler(String propertyName, StateChangeHandler handler) { return ensureHandlerManager(propertyName).addHandler( StateChangeEvent.TYPE, handler); } + @Override + public void removeStateChangeHandler(String propertyName, + StateChangeHandler handler) { + ensureHandlerManager(propertyName).removeHandler(StateChangeEvent.TYPE, + handler); + } + private HandlerManager ensureHandlerManager(String propertyName) { if (statePropertyHandlerManagers == null) { statePropertyHandlerManagers = new HashMap<String, HandlerManager>(); |