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 --- .../java/com/vaadin/ui/AbstractSplitPanel.java | 27 +++++++--------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java') diff --git a/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java b/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java index 3add13cd4a..5f481cb537 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java @@ -29,6 +29,7 @@ import com.vaadin.server.SizeWithUnit; import com.vaadin.server.Sizeable; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.Registration; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelRpc; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState; @@ -575,34 +576,20 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } - public void addSplitterClickListener(SplitterClickListener listener) { + public Registration addSplitterClickListener( + SplitterClickListener listener) { addListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class, listener, SplitterClickListener.clickMethod); + return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER, + SplitterClickEvent.class, listener); } - /** - * @deprecated As of 7.0, replaced by - * {@link #addSplitterClickListener(SplitterClickListener)} - **/ @Deprecated - public void addListener(SplitterClickListener listener) { - addSplitterClickListener(listener); - } - public void removeSplitterClickListener(SplitterClickListener listener) { removeListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class, listener); } - /** - * @deprecated As of 7.0, replaced by - * {@link #removeSplitterClickListener(SplitterClickListener)} - **/ - @Deprecated - public void removeListener(SplitterClickListener listener) { - removeSplitterClickListener(listener); - } - /** * Register a listener to handle {@link SplitPositionChangeEvent}s. * @@ -610,10 +597,11 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @param listener * {@link SplitPositionChangeListener} to be registered. */ - public void addSplitPositionChangeListener( + public Registration addSplitPositionChangeListener( SplitPositionChangeListener listener) { addListener(SplitPositionChangeEvent.class, listener, SplitPositionChangeListener.moveMethod); + return () -> removeListener(SplitPositionChangeEvent.class, listener); } /** @@ -623,6 +611,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @param listener * SplitPositionChangeListener to be removed. */ + @Deprecated public void removeSplitPositionChangeListener( SplitPositionChangeListener listener) { removeListener(SplitPositionChangeEvent.class, listener); -- cgit v1.2.3