]> source.dussan.org Git - vaadin-framework.git/commitdiff
Renamed communication event related classes (#10243) 94/294/2
authorArtur Signell <artur@vaadin.com>
Tue, 20 Nov 2012 06:35:46 +0000 (08:35 +0200)
committerVaadin Code Review <review@vaadin.com>
Wed, 21 Nov 2012 11:54:50 +0000 (11:54 +0000)
Change-Id: Ia4ddb8e6937f5902b50b8c88c93f7955a653c025

client/src/com/vaadin/client/ApplicationConnection.java

index 8bfd7ee74776a8742f6c6b456e7d09717e5e3bdb..ede16b8125d42e743bf7960efa58b26fbc3f84a5 100644 (file)
@@ -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<CommunicationHandler> {
+    public static class RequestStartingEvent extends ApplicationConnectionEvent {
+
         public static Type<CommunicationHandler> TYPE = new Type<CommunicationHandler>();
 
+        public RequestStartingEvent(ApplicationConnection connection) {
+            super(connection);
+        }
+
         @Override
         public com.google.gwt.event.shared.GwtEvent.Type<CommunicationHandler> 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<CommunicationHandler> {
+    public static class ResponseHandlingEndedEvent extends
+            ApplicationConnectionEvent {
+
         public static Type<CommunicationHandler> TYPE = new Type<CommunicationHandler>();
 
+        public ResponseHandlingEndedEvent(ApplicationConnection connection) {
+            super(connection);
+        }
+
         @Override
         public com.google.gwt.event.shared.GwtEvent.Type<CommunicationHandler> 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<CommunicationHandler> {
+
+        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<CommunicationHandler> TYPE = new Type<CommunicationHandler>();
 
         @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
          * <code>true</code> 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;
     }