From f57bb5da8cb10a7dec5184fdf615424a34138447 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 2 Apr 2012 22:23:51 +0300 Subject: [PATCH] Defined RPC in a field rather than inline for clarity --- src/com/vaadin/ui/Button.java | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index fc564c3237..daa7e20ca7 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -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); } /** -- 2.39.5