]> source.dussan.org Git - vaadin-framework.git/commitdiff
Defined RPC in a field rather than inline for clarity
authorArtur Signell <artur@vaadin.com>
Mon, 2 Apr 2012 19:23:51 +0000 (22:23 +0300)
committerArtur Signell <artur@vaadin.com>
Wed, 4 Apr 2012 21:08:13 +0000 (00:08 +0300)
src/com/vaadin/ui/Button.java

index fc564c3237278ae1217edc3478ec0effdc67dd67..daa7e20ca73a8e05e60b59f57fc01e265c183598 100644 (file)
@@ -38,22 +38,23 @@ public class Button extends AbstractComponent implements
         FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Focusable,
         Action.ShortcutNotifier {
 
+    private ButtonServerRpc rpc = new ButtonServerRpc() {
+        public void click(MouseEventDetails mouseEventDetails) {
+            fireClick(mouseEventDetails);
+        }
+
+        public void disableOnClick() {
+            // Could be optimized so the button is not repainted because of
+            // this (client side has already disabled the button)
+            setEnabled(false);
+        }
+    };
+
     /**
      * Creates a new push button.
      */
     public Button() {
-        // TODO take the implementation out of an anonymous class?
-        registerRpcImplementation(new ButtonServerRpc() {
-            public void click(MouseEventDetails mouseEventDetails) {
-                fireClick(mouseEventDetails);
-            }
-
-            public void disableOnClick() {
-                // Could be optimized so the button is not repainted because of
-                // this (client side has already disabled the button)
-                setEnabled(false);
-            }
-        }, ButtonServerRpc.class);
+        registerRpcImplementation(rpc, ButtonServerRpc.class);
     }
 
     /**