From 2bee988272657df4d886ea79b04be9fbc54d3928 Mon Sep 17 00:00:00 2001 From: Aleksi Hietanen Date: Fri, 23 Sep 2016 13:14:52 +0300 Subject: Unify listeners on the server side This patch updates server side add*Listener methods to return a registration object and deprecates their corresponding remove*Listener methods. Additionally this patch removes add/removeListener methods which were deprecated in 7.0. Change-Id: I26ac5f11882512288fbbf601c7cb2aaff653ec76 --- server/src/main/java/com/vaadin/ui/GridLayout.java | 26 +++++----------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'server/src/main/java/com/vaadin/ui/GridLayout.java') diff --git a/server/src/main/java/com/vaadin/ui/GridLayout.java b/server/src/main/java/com/vaadin/ui/GridLayout.java index 6e74071f65..40b8575c36 100644 --- a/server/src/main/java/com/vaadin/ui/GridLayout.java +++ b/server/src/main/java/com/vaadin/ui/GridLayout.java @@ -27,6 +27,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import org.jsoup.nodes.Attributes; @@ -39,6 +40,7 @@ import com.vaadin.event.LayoutEvents.LayoutClickNotifier; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.Registration; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.gridlayout.GridLayoutServerRpc; import com.vaadin.shared.ui.gridlayout.GridLayoutState; @@ -445,6 +447,7 @@ public class GridLayout extends AbstractLayout return components.size(); } + @Override public void beforeClientResponse(boolean initial) { super.beforeClientResponse(initial); @@ -1163,38 +1166,21 @@ public class GridLayout extends AbstractLayout } @Override - public void addLayoutClickListener(LayoutClickListener listener) { + public Registration addLayoutClickListener(LayoutClickListener listener) { addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener, LayoutClickListener.clickMethod); + return () -> removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, + LayoutClickEvent.class, listener); } - /** - * @deprecated As of 7.0, replaced by - * {@link #addLayoutClickListener(LayoutClickListener)} - **/ @Override @Deprecated - public void addListener(LayoutClickListener listener) { - addLayoutClickListener(listener); - } - - @Override public void removeLayoutClickListener(LayoutClickListener listener) { removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER, LayoutClickEvent.class, listener); } - /** - * @deprecated As of 7.0, replaced by - * {@link #removeLayoutClickListener(LayoutClickListener)} - **/ - @Override - @Deprecated - public void removeListener(LayoutClickListener listener) { - removeLayoutClickListener(listener); - } - /* * (non-Javadoc) * -- cgit v1.2.3