aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/data/Binder.java4
-rw-r--r--server/src/main/java/com/vaadin/event/EventRouter.java16
-rw-r--r--server/src/main/java/com/vaadin/event/MethodEventSource.java9
-rw-r--r--server/src/main/java/com/vaadin/server/AbstractClientConnector.java45
-rw-r--r--server/src/main/java/com/vaadin/server/Page.java17
-rw-r--r--server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java9
-rw-r--r--server/src/main/java/com/vaadin/ui/AbsoluteLayout.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponent.java13
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractDateField.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractField.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractFocusable.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java9
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java13
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractTextField.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/Button.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/CheckBox.java35
-rw-r--r--server/src/main/java/com/vaadin/ui/CheckBoxGroup.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/CssLayout.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/Embedded.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java13
-rw-r--r--server/src/main/java/com/vaadin/ui/GridLayout.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/Image.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/LoginForm.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/NativeSelect.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/Panel.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/PopupView.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/RadioButtonGroup.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/TabSheet.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/UI.java9
-rw-r--r--server/src/main/java/com/vaadin/ui/Upload.java18
-rw-r--r--server/src/main/java/com/vaadin/ui/Window.java30
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java12
40 files changed, 171 insertions, 260 deletions
diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java
index 7c0dba107c..771726ea3c 100644
--- a/server/src/main/java/com/vaadin/data/Binder.java
+++ b/server/src/main/java/com/vaadin/data/Binder.java
@@ -1415,10 +1415,8 @@ public class Binder<BEAN> implements Serializable {
* @return a registration for the listener
*/
public Registration addStatusChangeListener(StatusChangeListener listener) {
- getEventRouter().addListener(StatusChangeEvent.class, listener,
+ return getEventRouter().addListener(StatusChangeEvent.class, listener,
StatusChangeListener.class.getDeclaredMethods()[0]);
- return () -> getEventRouter().removeListener(StatusChangeEvent.class,
- listener);
}
/**
diff --git a/server/src/main/java/com/vaadin/event/EventRouter.java b/server/src/main/java/com/vaadin/event/EventRouter.java
index c5237d9aca..b07efb6c53 100644
--- a/server/src/main/java/com/vaadin/event/EventRouter.java
+++ b/server/src/main/java/com/vaadin/event/EventRouter.java
@@ -28,6 +28,7 @@ import java.util.logging.Logger;
import com.vaadin.server.ErrorEvent;
import com.vaadin.server.ErrorHandler;
+import com.vaadin.shared.Registration;
/**
* <code>EventRouter</code> class implementing the inheritable event listening
@@ -51,12 +52,16 @@ public class EventRouter implements MethodEventSource {
* use the default documentation from implemented interface.
*/
@Override
- public void addListener(Class<?> eventType, Object object, Method method) {
+ public Registration addListener(Class<?> eventType, Object object,
+ Method method) {
Objects.requireNonNull(object, "Listener must not be null.");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
- listenerList.add(new ListenerMethod(eventType, object, method));
+ ListenerMethod listenerMethod = new ListenerMethod(eventType, object,
+ method);
+ listenerList.add(listenerMethod);
+ return () -> listenerList.remove(listenerMethod);
}
/*
@@ -65,13 +70,16 @@ public class EventRouter implements MethodEventSource {
* here, we use the default documentation from implemented interface.
*/
@Override
- public void addListener(Class<?> eventType, Object object,
+ public Registration addListener(Class<?> eventType, Object object,
String methodName) {
Objects.requireNonNull(object, "Listener must not be null.");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
- listenerList.add(new ListenerMethod(eventType, object, methodName));
+ ListenerMethod listenerMethod = new ListenerMethod(eventType, object,
+ methodName);
+ listenerList.add(listenerMethod);
+ return () -> listenerList.remove(listenerMethod);
}
/*
diff --git a/server/src/main/java/com/vaadin/event/MethodEventSource.java b/server/src/main/java/com/vaadin/event/MethodEventSource.java
index 42f4902122..2ba5586eb1 100644
--- a/server/src/main/java/com/vaadin/event/MethodEventSource.java
+++ b/server/src/main/java/com/vaadin/event/MethodEventSource.java
@@ -19,6 +19,8 @@ package com.vaadin.event;
import java.io.Serializable;
import java.lang.reflect.Method;
+import com.vaadin.shared.Registration;
+
/**
* <p>
* Interface for classes supporting registration of methods as event receivers.
@@ -54,13 +56,15 @@ public interface MethodEventSource extends Serializable {
* the object instance who owns the activation method.
* @param method
* the activation method.
+ * @return a registration object for removing the listener
* @throws java.lang.IllegalArgumentException
* unless <code>method</code> has exactly one match in
* <code>object</code>
* @throws NullPointerException
* if {@code object} is {@code null}
*/
- public void addListener(Class<?> eventType, Object object, Method method);
+ public Registration addListener(Class<?> eventType, Object object,
+ Method method);
/**
* <p>
@@ -89,13 +93,14 @@ public interface MethodEventSource extends Serializable {
* the object instance who owns the activation method.
* @param methodName
* the name of the activation method.
+ * @return a registration object for removing the listener
* @throws java.lang.IllegalArgumentException
* unless <code>method</code> has exactly one match in
* <code>object</code>
* @throws NullPointerException
* if {@code object} is {@code null}
*/
- public void addListener(Class<?> eventType, Object object,
+ public Registration addListener(Class<?> eventType, Object object,
String methodName);
/**
diff --git a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
index 01222a07dd..9f5416968c 100644
--- a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
@@ -97,10 +97,8 @@ public abstract class AbstractClientConnector
@Override
public Registration addAttachListener(AttachListener listener) {
- addListener(AttachEvent.ATTACH_EVENT_IDENTIFIER, AttachEvent.class,
- listener, AttachListener.attachMethod);
- return () -> removeListener(AttachEvent.ATTACH_EVENT_IDENTIFIER,
- AttachEvent.class, listener);
+ return addListener(AttachEvent.ATTACH_EVENT_IDENTIFIER,
+ AttachEvent.class, listener, AttachListener.attachMethod);
}
@Override
@@ -111,10 +109,8 @@ public abstract class AbstractClientConnector
@Override
public Registration addDetachListener(DetachListener listener) {
- addListener(DetachEvent.DETACH_EVENT_IDENTIFIER, DetachEvent.class,
- listener, DetachListener.detachMethod);
- return () -> removeListener(DetachEvent.DETACH_EVENT_IDENTIFIER,
- DetachEvent.class, listener);
+ return addListener(DetachEvent.DETACH_EVENT_IDENTIFIER,
+ DetachEvent.class, listener, DetachListener.detachMethod);
}
@Override
@@ -537,13 +533,13 @@ public abstract class AbstractClientConnector
.iterator();
final Iterator<Extension> extensionsIterator = extensions.iterator();
Iterable<? extends ClientConnector> combinedIterable = () -> new Iterator<ClientConnector>() {
-
+
@Override
public boolean hasNext() {
return componentsIterator.hasNext()
- || extensionsIterator.hasNext();
+ || extensionsIterator.hasNext();
}
-
+
@Override
public ClientConnector next() {
if (componentsIterator.hasNext()) {
@@ -554,12 +550,12 @@ public abstract class AbstractClientConnector
}
throw new NoSuchElementException();
}
-
+
@Override
public void remove() {
throw new UnsupportedOperationException();
}
-
+
};
return combinedIterable;
}
@@ -751,21 +747,24 @@ public abstract class AbstractClientConnector
* the object instance who owns the activation method.
* @param method
* the activation method.
- *
+ * @return a registration object for removing the listener
* @since 6.2
*/
- protected void addListener(String eventIdentifier, Class<?> eventType,
- Object target, Method method) {
+ protected Registration addListener(String eventIdentifier,
+ Class<?> eventType, Object target, Method method) {
if (eventRouter == null) {
eventRouter = new EventRouter();
}
boolean needRepaint = !eventRouter.hasListeners(eventType);
- eventRouter.addListener(eventType, target, method);
+ Registration registration = eventRouter.addListener(eventType, target,
+ method);
if (needRepaint) {
ComponentStateUtil.addRegisteredEventListener(getState(),
eventIdentifier);
}
+
+ return registration;
}
/**
@@ -838,14 +837,15 @@ public abstract class AbstractClientConnector
* the object instance who owns the activation method.
* @param method
* the activation method.
- *
+ * @return a registration object for removing the listener
*/
@Override
- public void addListener(Class<?> eventType, Object target, Method method) {
+ public Registration addListener(Class<?> eventType, Object target,
+ Method method) {
if (eventRouter == null) {
eventRouter = new EventRouter();
}
- eventRouter.addListener(eventType, target, method);
+ return eventRouter.addListener(eventType, target, method);
}
/**
@@ -881,18 +881,19 @@ public abstract class AbstractClientConnector
* the object instance who owns the activation method.
* @param methodName
* the name of the activation method.
+ * @return a registration object for removing the listener
* @deprecated As of 7.0. This method should be avoided. Use
* {@link #addListener(Class, Object, Method)} or
* {@link #addListener(String, Class, Object, Method)} instead.
*/
@Override
@Deprecated
- public void addListener(Class<?> eventType, Object target,
+ public Registration addListener(Class<?> eventType, Object target,
String methodName) {
if (eventRouter == null) {
eventRouter = new EventRouter();
}
- eventRouter.addListener(eventType, target, methodName);
+ return eventRouter.addListener(eventType, target, methodName);
}
/**
diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java
index d067ffc7dc..faf64e3a3d 100644
--- a/server/src/main/java/com/vaadin/server/Page.java
+++ b/server/src/main/java/com/vaadin/server/Page.java
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.EventObject;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
@@ -486,11 +485,12 @@ public class Page implements Serializable {
this.state = state;
}
- private void addListener(Class<?> eventType, Object target, Method method) {
+ private Registration addListener(Class<?> eventType, Object target,
+ Method method) {
if (!hasEventRouter()) {
eventRouter = new EventRouter();
}
- eventRouter.addListener(eventType, target, method);
+ return eventRouter.addListener(eventType, target, method);
}
private void removeListener(Class<?> eventType, Object target,
@@ -516,9 +516,7 @@ public class Page implements Serializable {
*/
public Registration addUriFragmentChangedListener(
Page.UriFragmentChangedListener listener) {
- addListener(UriFragmentChangedEvent.class, listener,
- URI_FRAGMENT_CHANGED_METHOD);
- return () -> removeListener(UriFragmentChangedEvent.class, listener,
+ return addListener(UriFragmentChangedEvent.class, listener,
URI_FRAGMENT_CHANGED_METHOD);
}
@@ -745,12 +743,11 @@ public class Page implements Serializable {
*/
public Registration addBrowserWindowResizeListener(
BrowserWindowResizeListener resizeListener) {
- addListener(BrowserWindowResizeEvent.class, resizeListener,
- BROWSER_RESIZE_METHOD);
+ Registration registration = addListener(BrowserWindowResizeEvent.class,
+ resizeListener, BROWSER_RESIZE_METHOD);
getState(true).hasResizeListeners = true;
return () -> {
- removeListener(BrowserWindowResizeEvent.class, resizeListener,
- BROWSER_RESIZE_METHOD);
+ registration.remove();
getState(true).hasResizeListeners = hasEventRouter()
&& eventRouter.hasListeners(BrowserWindowResizeEvent.class);
};
diff --git a/server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java b/server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java
index adb1bed36d..c7aedfd10a 100644
--- a/server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java
+++ b/server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java
@@ -40,9 +40,8 @@ public abstract class AbstractDataProvider<T, F> implements DataProvider<T, F> {
@Override
public Registration addDataProviderListener(DataProviderListener listener) {
- addListener(DataChangeEvent.class, listener,
+ return addListener(DataChangeEvent.class, listener,
DataProviderListener.class.getMethods()[0]);
- return () -> removeListener(DataChangeEvent.class, listener);
}
@Override
@@ -63,14 +62,14 @@ public abstract class AbstractDataProvider<T, F> implements DataProvider<T, F> {
* the object instance who owns the activation method.
* @param method
* the activation method.
- *
+ * @return a registration for the listener
*/
- protected void addListener(Class<?> eventType,
+ protected Registration addListener(Class<?> eventType,
DataProviderListener listener, Method method) {
if (eventRouter == null) {
eventRouter = new EventRouter();
}
- eventRouter.addListener(eventType, listener, method);
+ return eventRouter.addListener(eventType, listener, method);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
index 49d020d32f..b15db199a0 100644
--- a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
@@ -640,11 +640,9 @@ public class AbsoluteLayout extends AbstractLayout
@Override
public Registration addLayoutClickListener(LayoutClickListener listener) {
- addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
+ return addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
LayoutClickEvent.class, listener,
LayoutClickListener.clickMethod);
- return () -> removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
- LayoutClickEvent.class, listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
index f827e3c6f4..5d3412f454 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
@@ -730,8 +730,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public Registration addListener(Component.Listener listener) {
- addListener(Component.Event.class, listener, COMPONENT_EVENT_METHOD);
- return () -> removeListener(Component.Event.class, listener,
+ return addListener(Component.Event.class, listener,
COMPONENT_EVENT_METHOD);
}
@@ -1375,15 +1374,13 @@ public abstract class AbstractComponent extends AbstractClientConnector
// connector can override this and use a different RPC channel.
if (getRpcManager(ContextClickRpc.class.getName()) == null) {
registerRpc((ContextClickRpc) (MouseEventDetails details) -> {
- fireEvent(new ContextClickEvent(AbstractComponent.this,
- details));
+ fireEvent(
+ new ContextClickEvent(AbstractComponent.this, details));
});
}
- addListener(EventId.CONTEXT_CLICK, ContextClickEvent.class, listener,
- ContextClickEvent.CONTEXT_CLICK_METHOD);
- return () -> removeListener(EventId.CONTEXT_CLICK,
- ContextClickEvent.class, listener);
+ return addListener(EventId.CONTEXT_CLICK, ContextClickEvent.class,
+ listener, ContextClickEvent.CONTEXT_CLICK_METHOD);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
index 9740dff68a..f3cfd72931 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
@@ -100,9 +100,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
@Override
public Registration addComponentAttachListener(
ComponentAttachListener listener) {
- addListener(ComponentAttachEvent.class, listener,
- ComponentAttachListener.attachMethod);
- return () -> removeListener(ComponentAttachEvent.class, listener,
+ return addListener(ComponentAttachEvent.class, listener,
ComponentAttachListener.attachMethod);
}
@@ -119,9 +117,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
@Override
public Registration addComponentDetachListener(
ComponentDetachListener listener) {
- addListener(ComponentDetachEvent.class, listener,
- ComponentDetachListener.detachMethod);
- return () -> removeListener(ComponentDetachEvent.class, listener,
+ return addListener(ComponentDetachEvent.class, listener,
ComponentDetachListener.detachMethod);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractDateField.java b/server/src/main/java/com/vaadin/ui/AbstractDateField.java
index 6e59d9bbe0..1d3f1ee7b2 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractDateField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractDateField.java
@@ -569,10 +569,8 @@ public abstract class AbstractDateField extends AbstractField<LocalDate>
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
@@ -583,10 +581,8 @@ public abstract class AbstractDateField extends AbstractField<LocalDate>
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractField.java b/server/src/main/java/com/vaadin/ui/AbstractField.java
index 45f7b4fa0b..331f8d28e1 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractField.java
@@ -89,8 +89,8 @@ public abstract class AbstractField<T> extends AbstractComponent
@Override
public Registration addValueChangeListener(
ValueChangeListener<T> listener) {
- addListener(ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD);
- return () -> removeListener(ValueChangeEvent.class, listener);
+ return addListener(ValueChangeEvent.class, listener,
+ VALUE_CHANGE_METHOD);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractFocusable.java b/server/src/main/java/com/vaadin/ui/AbstractFocusable.java
index 3684d87dcd..959a18fc80 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractFocusable.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractFocusable.java
@@ -42,10 +42,8 @@ public abstract class AbstractFocusable extends AbstractComponent
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
@@ -56,10 +54,8 @@ public abstract class AbstractFocusable extends AbstractComponent
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
index 25173d4646..3c85496e41 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
@@ -159,9 +159,8 @@ public abstract class AbstractMultiSelect<T> extends AbstractListing<T>
@Override
public Registration addSelectionListener(
MultiSelectionListener<T> listener) {
- addListener(MultiSelectionEvent.class, listener,
+ return addListener(MultiSelectionEvent.class, listener,
SELECTION_CHANGE_METHOD);
- return () -> removeListener(MultiSelectionEvent.class, listener);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
index 6858a18999..75cea826c0 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
@@ -362,11 +362,9 @@ public abstract class AbstractOrderedLayout extends AbstractLayout
@Override
public Registration addLayoutClickListener(LayoutClickListener listener) {
- addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
+ return addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
LayoutClickEvent.class, listener,
LayoutClickListener.clickMethod);
- return () -> removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
- LayoutClickEvent.class, listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java b/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
index dc92ece1e9..fbb937e148 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
@@ -60,9 +60,7 @@ public abstract class AbstractSingleComponentContainer extends AbstractComponent
@Override
public Registration addComponentAttachListener(
ComponentAttachListener listener) {
- addListener(ComponentAttachEvent.class, listener,
- ComponentAttachListener.attachMethod);
- return () -> removeListener(ComponentAttachEvent.class, listener,
+ return addListener(ComponentAttachEvent.class, listener,
ComponentAttachListener.attachMethod);
}
@@ -79,9 +77,7 @@ public abstract class AbstractSingleComponentContainer extends AbstractComponent
@Override
public Registration addComponentDetachListener(
ComponentDetachListener listener) {
- addListener(ComponentDetachEvent.class, listener,
- ComponentDetachListener.detachMethod);
- return () -> removeListener(ComponentDetachEvent.class, listener,
+ return addListener(ComponentDetachEvent.class, listener,
ComponentDetachListener.detachMethod);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
index e04e871cb4..cdd91424e0 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
@@ -94,9 +94,8 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
*/
public Registration addSelectionChangeListener(
SingleSelectionListener<T> listener) {
- addListener(SingleSelectionEvent.class, listener,
+ return addListener(SingleSelectionEvent.class, listener,
SELECTION_CHANGE_METHOD);
- return () -> removeListener(SingleSelectionEvent.class, listener);
}
/**
@@ -233,8 +232,7 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
}
doSetSelectedKey(key);
- fireEvent(new SingleSelectionEvent<>(AbstractSingleSelect.this,
- true));
+ fireEvent(new SingleSelectionEvent<>(AbstractSingleSelect.this, true));
}
/**
@@ -254,8 +252,7 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
}
doSetSelectedKey(key);
- fireEvent(new SingleSelectionEvent<>(AbstractSingleSelect.this,
- false));
+ fireEvent(new SingleSelectionEvent<>(AbstractSingleSelect.this, false));
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java b/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
index e7a66cebe5..8fe762f2a9 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
@@ -578,10 +578,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
public Registration addSplitterClickListener(
SplitterClickListener listener) {
- addListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class,
- listener, SplitterClickListener.clickMethod);
- return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
- SplitterClickEvent.class, listener);
+ return addListener(EventId.CLICK_EVENT_IDENTIFIER,
+ SplitterClickEvent.class, listener,
+ SplitterClickListener.clickMethod);
}
@Deprecated
@@ -599,9 +598,8 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
*/
public Registration addSplitPositionChangeListener(
SplitPositionChangeListener listener) {
- addListener(SplitPositionChangeEvent.class, listener,
+ return addListener(SplitPositionChangeEvent.class, listener,
SplitPositionChangeListener.moveMethod);
- return () -> removeListener(SplitPositionChangeEvent.class, listener);
}
/**
@@ -707,8 +705,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
super.writeDesign(design, designContext);
// handle custom attributes (write only if a value is not the
// default value)
- AbstractSplitPanel def = designContext
- .getDefaultInstance(this);
+ AbstractSplitPanel def = designContext.getDefaultInstance(this);
if (getSplitPosition() != def.getSplitPosition()
|| !def.getSplitPositionUnit().equals(getSplitPositionUnit())) {
String splitPositionString = asString(getSplitPosition())
diff --git a/server/src/main/java/com/vaadin/ui/AbstractTextField.java b/server/src/main/java/com/vaadin/ui/AbstractTextField.java
index 3b2c0e9914..831b0ba6c6 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractTextField.java
@@ -199,10 +199,8 @@ public abstract class AbstractTextField extends AbstractField<String>
* @see Registration
*/
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
/**
@@ -216,10 +214,8 @@ public abstract class AbstractTextField extends AbstractField<String>
* @see Registration
*/
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
@@ -281,8 +277,7 @@ public abstract class AbstractTextField extends AbstractField<String>
@Override
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
- AbstractTextField def = designContext
- .getDefaultInstance(this);
+ AbstractTextField def = designContext.getDefaultInstance(this);
Attributes attr = design.attributes();
DesignAttributeHandler.writeAttribute("maxlength", attr, getMaxLength(),
def.getMaxLength(), Integer.class, designContext);
diff --git a/server/src/main/java/com/vaadin/ui/Button.java b/server/src/main/java/com/vaadin/ui/Button.java
index cbd45ba454..f18ad276d9 100644
--- a/server/src/main/java/com/vaadin/ui/Button.java
+++ b/server/src/main/java/com/vaadin/ui/Button.java
@@ -314,9 +314,7 @@ public class Button extends AbstractFocusable
* @return a registration object for removing the listener
*/
public Registration addClickListener(ClickListener listener) {
- addListener(ClickEvent.class, listener,
- ClickListener.BUTTON_CLICK_METHOD);
- return () -> removeListener(ClickEvent.class, listener,
+ return addListener(ClickEvent.class, listener,
ClickListener.BUTTON_CLICK_METHOD);
}
diff --git a/server/src/main/java/com/vaadin/ui/CheckBox.java b/server/src/main/java/com/vaadin/ui/CheckBox.java
index 8048bcd899..aa7cc565eb 100644
--- a/server/src/main/java/com/vaadin/ui/CheckBox.java
+++ b/server/src/main/java/com/vaadin/ui/CheckBox.java
@@ -38,25 +38,26 @@ import com.vaadin.ui.declarative.DesignContext;
public class CheckBox extends AbstractField<Boolean>
implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
- private CheckBoxServerRpc rpc = (boolean checked, MouseEventDetails mouseEventDetails) -> {
+ private CheckBoxServerRpc rpc = (boolean checked,
+ MouseEventDetails mouseEventDetails) -> {
if (isReadOnly()) {
return;
}
-
+
/*
- * Client side updates the state before sending the event so we need
- * to make sure the cached state is updated to match the client. If
- * we do not do this, a reverting setValue() call in a listener will
- * not cause the new state to be sent to the client.
- *
- * See #11028, #10030.
- */
- getUI().getConnectorTracker().getDiffState(CheckBox.this)
- .put("checked", checked);
-
+ * Client side updates the state before sending the event so we need to
+ * make sure the cached state is updated to match the client. If we do
+ * not do this, a reverting setValue() call in a listener will not cause
+ * the new state to be sent to the client.
+ *
+ * See #11028, #10030.
+ */
+ getUI().getConnectorTracker().getDiffState(CheckBox.this).put("checked",
+ checked);
+
final Boolean oldValue = getValue();
final Boolean newValue = checked;
-
+
if (!newValue.equals(oldValue)) {
// The event is only sent if the switch state is changed
setValue(newValue);
@@ -139,10 +140,8 @@ public class CheckBox extends AbstractField<Boolean>
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
@@ -153,10 +152,8 @@ public class CheckBox extends AbstractField<Boolean>
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
index eb61d2242d..d5df147f57 100644
--- a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
+++ b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
@@ -150,10 +150,8 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T>
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
@@ -164,10 +162,8 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T>
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index 2270c1a181..905d180a7f 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -261,10 +261,8 @@ public class ComboBox<T> extends AbstractSingleSelect<T> implements HasValue<T>,
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
@@ -275,10 +273,8 @@ public class ComboBox<T> extends AbstractSingleSelect<T> implements HasValue<T>,
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/CssLayout.java b/server/src/main/java/com/vaadin/ui/CssLayout.java
index 2c2c838cb2..5295f34aa0 100644
--- a/server/src/main/java/com/vaadin/ui/CssLayout.java
+++ b/server/src/main/java/com/vaadin/ui/CssLayout.java
@@ -17,7 +17,6 @@ package com.vaadin.ui;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.Objects;
import org.jsoup.nodes.Element;
@@ -75,9 +74,10 @@ import com.vaadin.ui.declarative.DesignContext;
*/
public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
- private CssLayoutServerRpc rpc = (MouseEventDetails mouseDetails, Connector clickedConnector) -> {
+ private CssLayoutServerRpc rpc = (MouseEventDetails mouseDetails,
+ Connector clickedConnector) -> {
fireEvent(LayoutClickEvent.createEvent(CssLayout.this, mouseDetails,
- clickedConnector));
+ clickedConnector));
};
/**
* Custom layout slots containing the components.
@@ -298,11 +298,9 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
@Override
public Registration addLayoutClickListener(LayoutClickListener listener) {
- addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
+ return addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
LayoutClickEvent.class, listener,
LayoutClickListener.clickMethod);
- return () -> removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
- LayoutClickEvent.class, listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/Embedded.java b/server/src/main/java/com/vaadin/ui/Embedded.java
index 6c5d5e26dc..5933530130 100644
--- a/server/src/main/java/com/vaadin/ui/Embedded.java
+++ b/server/src/main/java/com/vaadin/ui/Embedded.java
@@ -529,10 +529,8 @@ public class Embedded extends AbstractComponent implements LegacyComponent {
* @return a registration object for removing the listener
*/
public Registration addClickListener(ClickListener listener) {
- addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
- ClickListener.clickMethod);
- return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
- ClickEvent.class, listener);
+ return addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
+ listener, ClickListener.clickMethod);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 29c97af24a..a019476aeb 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -2461,8 +2461,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents {
*/
public Registration addColumnReorderListener(
ColumnReorderListener listener) {
- addListener(ColumnReorderEvent.class, listener, COLUMN_REORDER_METHOD);
- return () -> removeListener(ColumnReorderEvent.class, listener,
+ return addListener(ColumnReorderEvent.class, listener,
COLUMN_REORDER_METHOD);
}
@@ -2474,8 +2473,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents {
* @return a registration for the listener
*/
public Registration addColumnResizeListener(ColumnResizeListener listener) {
- addListener(ColumnResizeEvent.class, listener, COLUMN_RESIZE_METHOD);
- return () -> removeListener(ColumnResizeEvent.class, listener,
+ return addListener(ColumnResizeEvent.class, listener,
COLUMN_RESIZE_METHOD);
}
@@ -2489,9 +2487,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents {
*/
public Registration addItemClickListener(
ItemClickListener<? super T> listener) {
- addListener(GridConstants.ITEM_CLICK_EVENT_ID, ItemClick.class,
+ return addListener(GridConstants.ITEM_CLICK_EVENT_ID, ItemClick.class,
listener, ITEM_CLICK_METHOD);
- return () -> removeListener(ItemClick.class, listener);
}
/**
@@ -2503,9 +2500,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents {
*/
public Registration addColumnVisibilityChangeListener(
ColumnVisibilityChangeListener listener) {
- addListener(ColumnVisibilityChangeEvent.class, listener,
- COLUMN_VISIBILITY_METHOD);
- return () -> removeListener(ColumnVisibilityChangeEvent.class, listener,
+ return addListener(ColumnVisibilityChangeEvent.class, listener,
COLUMN_VISIBILITY_METHOD);
}
diff --git a/server/src/main/java/com/vaadin/ui/GridLayout.java b/server/src/main/java/com/vaadin/ui/GridLayout.java
index afcc780e84..70c9c85f94 100644
--- a/server/src/main/java/com/vaadin/ui/GridLayout.java
+++ b/server/src/main/java/com/vaadin/ui/GridLayout.java
@@ -76,9 +76,10 @@ public class GridLayout extends AbstractLayout
implements Layout.AlignmentHandler, Layout.SpacingHandler,
Layout.MarginHandler, LayoutClickNotifier {
- private GridLayoutServerRpc rpc = (MouseEventDetails mouseDetails, Connector clickedConnector) -> {
- fireEvent(LayoutClickEvent.createEvent(GridLayout.this,
- mouseDetails, clickedConnector));
+ private GridLayoutServerRpc rpc = (MouseEventDetails mouseDetails,
+ Connector clickedConnector) -> {
+ fireEvent(LayoutClickEvent.createEvent(GridLayout.this, mouseDetails,
+ clickedConnector));
};
/**
* Cursor X position: this is where the next component with unspecified x,y
@@ -1157,11 +1158,9 @@ public class GridLayout extends AbstractLayout
@Override
public Registration addLayoutClickListener(LayoutClickListener listener) {
- addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
+ return addListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
LayoutClickEvent.class, listener,
LayoutClickListener.clickMethod);
- return () -> removeListener(EventId.LAYOUT_CLICK_EVENT_IDENTIFIER,
- LayoutClickEvent.class, listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/Image.java b/server/src/main/java/com/vaadin/ui/Image.java
index 5b7ce9ce6b..504ab85426 100644
--- a/server/src/main/java/com/vaadin/ui/Image.java
+++ b/server/src/main/java/com/vaadin/ui/Image.java
@@ -85,10 +85,8 @@ public class Image extends AbstractEmbedded {
* @return a registration object for removing the listener
*/
public Registration addClickListener(ClickListener listener) {
- addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
- ClickListener.clickMethod);
- return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
- ClickEvent.class, listener);
+ return addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
+ listener, ClickListener.clickMethod);
}
/**
@@ -97,7 +95,7 @@ public class Image extends AbstractEmbedded {
*
* @param listener
* The listener to remove
- *
+ *
* @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
* registration object returned from
* {@link #addClickListener(ClickListener)}.
diff --git a/server/src/main/java/com/vaadin/ui/LoginForm.java b/server/src/main/java/com/vaadin/ui/LoginForm.java
index 9acd0735b1..6b6bfec5bc 100644
--- a/server/src/main/java/com/vaadin/ui/LoginForm.java
+++ b/server/src/main/java/com/vaadin/ui/LoginForm.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import com.vaadin.server.StreamResource;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.loginform.LoginFormConstants;
import com.vaadin.shared.ui.loginform.LoginFormRpc;
import com.vaadin.shared.ui.loginform.LoginFormState;
@@ -362,9 +363,10 @@ public class LoginForm extends AbstractSingleComponentContainer {
*
* @param listener
* the listener to add
+ * @return a registration object for removing the listener
*/
- public void addLoginListener(LoginListener listener) {
- addListener(LoginEvent.class, listener, ON_LOGIN_METHOD);
+ public Registration addLoginListener(LoginListener listener) {
+ return addListener(LoginEvent.class, listener, ON_LOGIN_METHOD);
}
/**
@@ -372,7 +374,11 @@ public class LoginForm extends AbstractSingleComponentContainer {
*
* @param listener
* the listener to remove
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addLoginListener(LoginListener)}.
*/
+ @Deprecated
public void removeLoginListener(LoginListener listener) {
removeListener(LoginEvent.class, listener, ON_LOGIN_METHOD);
}
diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java
index 46e72b02c6..b68ea6c14d 100644
--- a/server/src/main/java/com/vaadin/ui/NativeSelect.java
+++ b/server/src/main/java/com/vaadin/ui/NativeSelect.java
@@ -95,10 +95,8 @@ public class NativeSelect<T> extends AbstractSingleSelect<T>
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
@@ -109,10 +107,8 @@ public class NativeSelect<T> extends AbstractSingleSelect<T>
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/Panel.java b/server/src/main/java/com/vaadin/ui/Panel.java
index c179df9be2..55ca2c643e 100644
--- a/server/src/main/java/com/vaadin/ui/Panel.java
+++ b/server/src/main/java/com/vaadin/ui/Panel.java
@@ -273,10 +273,8 @@ public class Panel extends AbstractSingleComponentContainer
* @return a registration object for removing the listener
*/
public Registration addClickListener(ClickListener listener) {
- addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
- ClickListener.clickMethod);
- return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
- ClickEvent.class, listener);
+ return addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
+ listener, ClickListener.clickMethod);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/PopupView.java b/server/src/main/java/com/vaadin/ui/PopupView.java
index ba47023425..0b7cd59c61 100644
--- a/server/src/main/java/com/vaadin/ui/PopupView.java
+++ b/server/src/main/java/com/vaadin/ui/PopupView.java
@@ -338,9 +338,7 @@ public class PopupView extends AbstractComponent implements HasComponents {
*/
public Registration addPopupVisibilityListener(
PopupVisibilityListener listener) {
- addListener(PopupVisibilityEvent.class, listener,
- POPUP_VISIBILITY_METHOD);
- return () -> removeListener(PopupVisibilityEvent.class, listener,
+ return addListener(PopupVisibilityEvent.class, listener,
POPUP_VISIBILITY_METHOD);
}
diff --git a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
index 13b8fedc72..2a6ab48402 100644
--- a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
+++ b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
@@ -257,10 +257,8 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
@@ -271,10 +269,8 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java
index 7ad40c2771..396c4975c1 100644
--- a/server/src/main/java/com/vaadin/ui/TabSheet.java
+++ b/server/src/main/java/com/vaadin/ui/TabSheet.java
@@ -831,9 +831,7 @@ public class TabSheet extends AbstractComponentContainer
*/
public Registration addSelectedTabChangeListener(
SelectedTabChangeListener listener) {
- addListener(SelectedTabChangeEvent.class, listener,
- SELECTED_TAB_CHANGE_METHOD);
- return () -> removeListener(SelectedTabChangeEvent.class, listener,
+ return addListener(SelectedTabChangeEvent.class, listener,
SELECTED_TAB_CHANGE_METHOD);
}
@@ -1366,10 +1364,8 @@ public class TabSheet extends AbstractComponentContainer
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
@@ -1380,10 +1376,8 @@ public class TabSheet extends AbstractComponentContainer
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java
index 34e9177e0c..22dcb437f5 100644
--- a/server/src/main/java/com/vaadin/ui/UI.java
+++ b/server/src/main/java/com/vaadin/ui/UI.java
@@ -917,10 +917,8 @@ public abstract class UI extends AbstractSingleComponentContainer
* @return a registration object for removing the listener
*/
public Registration addClickListener(ClickListener listener) {
- addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
- ClickListener.clickMethod);
- return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
- ClickEvent.class, listener);
+ return addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
+ listener, ClickListener.clickMethod);
}
/**
@@ -1621,9 +1619,8 @@ public abstract class UI extends AbstractSingleComponentContainer
@Override
public Registration addPollListener(PollListener listener) {
- addListener(EventId.POLL, PollEvent.class, listener,
+ return addListener(EventId.POLL, PollEvent.class, listener,
PollListener.POLL_METHOD);
- return () -> removeListener(EventId.POLL, PollEvent.class, listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java
index 2ab409f9d3..e3105b73fc 100644
--- a/server/src/main/java/com/vaadin/ui/Upload.java
+++ b/server/src/main/java/com/vaadin/ui/Upload.java
@@ -632,9 +632,7 @@ public class Upload extends AbstractComponent
* the Listener to be added, not null
*/
public Registration addStartedListener(StartedListener listener) {
- addListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD);
- return () -> removeListener(StartedEvent.class, listener,
- UPLOAD_STARTED_METHOD);
+ return addListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD);
}
/**
@@ -655,8 +653,7 @@ public class Upload extends AbstractComponent
* the Listener to be added, not null
*/
public Registration addFinishedListener(FinishedListener listener) {
- addListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
- return () -> removeListener(FinishedEvent.class, listener,
+ return addListener(FinishedEvent.class, listener,
UPLOAD_FINISHED_METHOD);
}
@@ -678,9 +675,7 @@ public class Upload extends AbstractComponent
* the Listener to be added, not null
*/
public Registration addFailedListener(FailedListener listener) {
- addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
- return () -> removeListener(FailedEvent.class, listener,
- UPLOAD_FAILED_METHOD);
+ return addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
}
/**
@@ -701,8 +696,7 @@ public class Upload extends AbstractComponent
* the Listener to be added, not null
*/
public Registration addSucceededListener(SucceededListener listener) {
- addListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
- return () -> removeListener(SucceededEvent.class, listener,
+ return addListener(SucceededEvent.class, listener,
UPLOAD_SUCCEEDED_METHOD);
}
@@ -756,10 +750,8 @@ public class Upload extends AbstractComponent
* the Listener to add, not null
*/
public Registration addChangeListener(ChangeListener listener) {
- super.addListener(EventId.CHANGE, ChangeEvent.class, listener,
+ return addListener(EventId.CHANGE, ChangeEvent.class, listener,
ChangeListener.FILENAME_CHANGED);
- return () -> super.removeListener(EventId.CHANGE, ChangeEvent.class,
- listener);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java
index f91d61d908..84e7ca7c7c 100644
--- a/server/src/main/java/com/vaadin/ui/Window.java
+++ b/server/src/main/java/com/vaadin/ui/Window.java
@@ -336,8 +336,8 @@ public class Window extends Panel
private static final Method WINDOW_CLOSE_METHOD;
static {
try {
- WINDOW_CLOSE_METHOD = CloseListener.class.getDeclaredMethod(
- "windowClose", CloseEvent.class);
+ WINDOW_CLOSE_METHOD = CloseListener.class
+ .getDeclaredMethod("windowClose", CloseEvent.class);
} catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException(
@@ -409,9 +409,7 @@ public class Window extends Panel
* the CloseListener to add, not null
*/
public Registration addCloseListener(CloseListener listener) {
- addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
- return () -> removeListener(CloseEvent.class, listener,
- WINDOW_CLOSE_METHOD);
+ return addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
}
/**
@@ -510,9 +508,7 @@ public class Window extends Panel
*/
public Registration addWindowModeChangeListener(
WindowModeChangeListener listener) {
- addListener(WindowModeChangeEvent.class, listener,
- WindowModeChangeListener.windowModeChangeMethod);
- return () -> removeListener(WindowModeChangeEvent.class, listener,
+ return addListener(WindowModeChangeEvent.class, listener,
WindowModeChangeListener.windowModeChangeMethod);
}
@@ -540,8 +536,8 @@ public class Window extends Panel
private static final Method WINDOW_RESIZE_METHOD;
static {
try {
- WINDOW_RESIZE_METHOD = ResizeListener.class.getDeclaredMethod(
- "windowResized", ResizeEvent.class);
+ WINDOW_RESIZE_METHOD = ResizeListener.class
+ .getDeclaredMethod("windowResized", ResizeEvent.class);
} catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException(
@@ -593,8 +589,7 @@ public class Window extends Panel
* @return a registration object for removing the listener
*/
public Registration addResizeListener(ResizeListener listener) {
- addListener(ResizeEvent.class, listener, WINDOW_RESIZE_METHOD);
- return () -> removeListener(ResizeEvent.class, listener);
+ return addListener(ResizeEvent.class, listener, WINDOW_RESIZE_METHOD);
}
/**
@@ -1052,10 +1047,8 @@ public class Window extends Panel
*/
@Override
public Registration addFocusListener(FocusListener listener) {
- addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+ return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
- return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
- listener);
}
@Override
@@ -1073,10 +1066,8 @@ public class Window extends Panel
*/
@Override
public Registration addBlurListener(BlurListener listener) {
- addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+ return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
- return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
- listener);
}
@Override
@@ -1381,7 +1372,8 @@ public class Window extends Panel
}
}
super.readDesignChildren(content, context);
- setAssistiveDescription(descriptions.toArray(new Component[descriptions.size()]));
+ setAssistiveDescription(
+ descriptions.toArray(new Component[descriptions.size()]));
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index 521a131c4c..15fc1bcb45 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -492,9 +492,8 @@ public class ColorPickerPopup extends Window implements HasValue<Color> {
public Registration addValueChangeListener(
ValueChangeListener<Color> listener) {
Objects.requireNonNull(listener, "listener cannot be null");
- addListener(ValueChangeEvent.class, listener,
+ return addListener(ValueChangeEvent.class, listener,
ValueChangeListener.VALUE_CHANGE_METHOD);
- return () -> removeListener(ValueChangeEvent.class, listener);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
index 41b2e851f3..9c4ee78069 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
@@ -112,9 +112,8 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> {
public Registration addValueChangeListener(
ValueChangeListener<Color> listener) {
Objects.requireNonNull(listener, "listener cannot be null");
- addListener(ValueChangeEvent.class, listener,
+ return addListener(ValueChangeEvent.class, listener,
ValueChangeListener.VALUE_CHANGE_METHOD);
- return () -> removeListener(ValueChangeEvent.class, listener);
}
private void valueChange(ValueChangeEvent<String> event) {
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java b/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java
index 6829cfc0e0..d095504768 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java
@@ -93,9 +93,8 @@ public class SingleSelectionModel<T> extends AbstractGridExtension<T>
*/
public Registration addSelectionChangeListener(
SingleSelectionListener<T> listener) {
- addListener(SingleSelectionEvent.class, listener,
+ return addListener(SingleSelectionEvent.class, listener,
SELECTION_CHANGE_METHOD);
- return () -> removeListener(SingleSelectionEvent.class, listener);
}
@Override
@@ -174,8 +173,7 @@ public class SingleSelectionModel<T> extends AbstractGridExtension<T>
}
doSetSelectedKey(key);
- fireEvent(
- new SingleSelectionEvent<>(grid, asSingleSelect(), true));
+ fireEvent(new SingleSelectionEvent<>(grid, asSingleSelect(), true));
}
/**
@@ -195,8 +193,7 @@ public class SingleSelectionModel<T> extends AbstractGridExtension<T>
}
doSetSelectedKey(key);
- fireEvent(new SingleSelectionEvent<>(grid, asSingleSelect(),
- false));
+ fireEvent(new SingleSelectionEvent<>(grid, asSingleSelect(), false));
}
/**
@@ -237,8 +234,7 @@ public class SingleSelectionModel<T> extends AbstractGridExtension<T>
// event fired before removing so that parent is still intact (in case
// needed)
selectedItem = null;
- fireEvent(new SingleSelectionEvent<>(grid, asSingleSelect(),
- false));
+ fireEvent(new SingleSelectionEvent<>(grid, asSingleSelect(), false));
super.remove();
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
index 8686c391c5..30b5260177 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
@@ -126,13 +126,14 @@ public abstract class ClickableRenderer<T, V> extends AbstractRenderer<T, V> {
protected ClickableRenderer(Class<V> presentationType,
String nullRepresentation) {
super(presentationType, nullRepresentation);
- registerRpc((RendererClickRpc) (String rowKey, String columnId, MouseEventDetails mouseDetails) -> {
+ registerRpc((RendererClickRpc) (String rowKey, String columnId,
+ MouseEventDetails mouseDetails) -> {
Grid<T> grid = getParentGrid();
T item = grid.getDataCommunicator().getKeyMapper().get(rowKey);
Column column = grid.getColumn(columnId);
-
- fireEvent(new RendererClickEvent<>(grid, item, column,
- mouseDetails));
+
+ fireEvent(
+ new RendererClickEvent<>(grid, item, column, mouseDetails));
});
}
@@ -144,9 +145,8 @@ public abstract class ClickableRenderer<T, V> extends AbstractRenderer<T, V> {
* the click listener to be added, not null
*/
public Registration addClickListener(RendererClickListener<T> listener) {
- addListener(RendererClickEvent.class, listener,
+ return addListener(RendererClickEvent.class, listener,
RendererClickListener.CLICK_METHOD);
- return () -> removeListener(RendererClickEvent.class, listener);
}
/**