From 416b8a6d6b9eb580454f006b38a72ffe7f484638 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 20 Nov 2012 08:35:46 +0200 Subject: [PATCH] Renamed communication event related classes (#10243) Change-Id: Ia4ddb8e6937f5902b50b8c88c93f7955a653c025 --- .../vaadin/client/ApplicationConnection.java | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 8bfd7ee747..ede16b8125 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -266,17 +266,21 @@ public class ApplicationConnection { * track of different aspects of the communication. */ public interface CommunicationHandler extends EventHandler { - void onRequestStarted(RequestStartedEvent e); + void onRequestStarting(RequestStartingEvent e); - void onRequestEnded(RequestEndedEvent e); + void onResponseHandlingStarted(ResponseHandlingStartedEvent e); - void onResponseReceived(ResponseReceivedEvent e); + void onResponseHandlingEnded(ResponseHandlingEndedEvent e); } - public static class RequestStartedEvent extends - GwtEvent { + public static class RequestStartingEvent extends ApplicationConnectionEvent { + public static Type TYPE = new Type(); + public RequestStartingEvent(ApplicationConnection connection) { + super(connection); + } + @Override public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { return TYPE; @@ -284,14 +288,19 @@ public class ApplicationConnection { @Override protected void dispatch(CommunicationHandler handler) { - handler.onRequestStarted(this); + handler.onRequestStarting(this); } } - public static class RequestEndedEvent extends - GwtEvent { + public static class ResponseHandlingEndedEvent extends + ApplicationConnectionEvent { + public static Type TYPE = new Type(); + public ResponseHandlingEndedEvent(ApplicationConnection connection) { + super(connection); + } + @Override public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { return TYPE; @@ -299,12 +308,32 @@ public class ApplicationConnection { @Override protected void dispatch(CommunicationHandler handler) { - handler.onRequestEnded(this); + handler.onResponseHandlingEnded(this); } } - public static class ResponseReceivedEvent extends + public static abstract class ApplicationConnectionEvent extends GwtEvent { + + private ApplicationConnection connection; + + protected ApplicationConnectionEvent(ApplicationConnection connection) { + this.connection = connection; + } + + public ApplicationConnection getConnection() { + return connection; + } + + } + + public static class ResponseHandlingStartedEvent extends + ApplicationConnectionEvent { + + public ResponseHandlingStartedEvent(ApplicationConnection connection) { + super(connection); + } + public static Type TYPE = new Type(); @Override @@ -314,14 +343,14 @@ public class ApplicationConnection { @Override protected void dispatch(CommunicationHandler handler) { - handler.onResponseReceived(this); + handler.onResponseHandlingStarted(this); } } /** * Allows custom handling of communication errors. */ - public interface CommunicationErrorDelegate { + public interface CommunicationErrorHandler { /** * Called when a communication error has occurred. Returning * true from this method suppresses error handling. @@ -336,7 +365,7 @@ public class ApplicationConnection { public boolean onError(String details, int statusCode); } - private CommunicationErrorDelegate communicationErrorDelegate = null; + private CommunicationErrorHandler communicationErrorDelegate = null; public static class MultiStepDuration extends Duration { private int previousStep = elapsedMillis(); @@ -1063,7 +1092,7 @@ public class ApplicationConnection { // First one kicks in at 300ms } loadTimer.schedule(300); - eventBus.fireEvent(new RequestStartedEvent()); + eventBus.fireEvent(new RequestStartingEvent(this)); } protected void endRequest() { @@ -1100,7 +1129,7 @@ public class ApplicationConnection { } } }); - eventBus.fireEvent(new RequestEndedEvent()); + eventBus.fireEvent(new ResponseHandlingEndedEvent(this)); } /** @@ -1254,7 +1283,7 @@ public class ApplicationConnection { } VConsole.log("Handling message from server"); - eventBus.fireEvent(new ResponseReceivedEvent()); + eventBus.fireEvent(new ResponseHandlingStartedEvent(this)); // Handle redirect if (json.containsKey("redirect")) { @@ -3140,8 +3169,7 @@ public class ApplicationConnection { * @param delegate * the delegate. */ - public void setCommunicationErrorDelegate( - CommunicationErrorDelegate delegate) { + public void setCommunicationErrorDelegate(CommunicationErrorHandler delegate) { communicationErrorDelegate = delegate; } -- 2.39.5