summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/event/FieldEvents.java65
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java4
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java2
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java4
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java2
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java2
-rw-r--r--compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java181
-rw-r--r--server/src/main/java/com/vaadin/event/Action.java9
-rw-r--r--server/src/main/java/com/vaadin/event/ContextClickEvent.java15
-rw-r--r--server/src/main/java/com/vaadin/event/EventRouter.java3
-rw-r--r--server/src/main/java/com/vaadin/event/FieldEvents.java36
-rw-r--r--server/src/main/java/com/vaadin/event/LayoutEvents.java27
-rw-r--r--server/src/main/java/com/vaadin/event/MethodEventSource.java4
-rw-r--r--server/src/main/java/com/vaadin/event/UIEvents.java12
-rw-r--r--server/src/main/java/com/vaadin/navigator/Navigator.java6
-rw-r--r--server/src/main/java/com/vaadin/server/AbstractClientConnector.java10
-rw-r--r--server/src/main/java/com/vaadin/server/ClientConnector.java7
-rw-r--r--server/src/main/java/com/vaadin/server/DragAndDropService.java13
-rw-r--r--server/src/main/java/com/vaadin/server/Page.java66
-rw-r--r--server/src/main/java/com/vaadin/server/data/AbstractDataSource.java1
-rw-r--r--server/src/main/java/com/vaadin/ui/AbsoluteLayout.java25
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractColorPicker.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponent.java28
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java53
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractDateField.java45
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractField.java1
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractFocusable.java14
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java24
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java14
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java1
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java27
-rw-r--r--server/src/main/java/com/vaadin/ui/Button.java33
-rw-r--r--server/src/main/java/com/vaadin/ui/CheckBox.java19
-rw-r--r--server/src/main/java/com/vaadin/ui/ColorPickerArea.java1
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/Component.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/ComponentContainer.java29
-rw-r--r--server/src/main/java/com/vaadin/ui/CssLayout.java26
-rw-r--r--server/src/main/java/com/vaadin/ui/Embedded.java31
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/GridLayout.java26
-rw-r--r--server/src/main/java/com/vaadin/ui/HasComponents.java17
-rw-r--r--server/src/main/java/com/vaadin/ui/Image.java33
-rw-r--r--server/src/main/java/com/vaadin/ui/LegacyWindow.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/Panel.java32
-rw-r--r--server/src/main/java/com/vaadin/ui/PopupView.java35
-rw-r--r--server/src/main/java/com/vaadin/ui/TabSheet.java48
-rw-r--r--server/src/main/java/com/vaadin/ui/UI.java37
-rw-r--r--server/src/main/java/com/vaadin/ui/Upload.java142
-rw-r--r--server/src/main/java/com/vaadin/ui/Window.java71
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java17
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java17
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java14
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java10
-rw-r--r--server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java29
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java42
-rw-r--r--server/src/test/java/com/vaadin/tests/server/components/WindowTest.java11
-rw-r--r--server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java4
-rw-r--r--server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/FocusingComponents.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/ListenerOrder.java20
-rw-r--r--uitest/src/main/java/com/vaadin/tests/ModalWindow.java8
-rw-r--r--uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestBench.java135
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestDateField.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java17
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForTabSheet.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForUpload.java12
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/application/ErrorInUnloadEvent.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java22
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/AbstractOrderedLayoutTest.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java5
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/button/ButtonErrorMessage.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/button/ButtonHtml.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/button/ButtonIOSDragTest.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/button/Buttons2.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/button/ShortCutListenerModification.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/button/TooltipForDisabledButton.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSlowInFF.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/RemovalOfSelectedIcon.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java10
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java8
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/gridlayout/InsertRowInMiddle.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java16
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java10
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetNPE.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java10
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tree/TreeContainerChange.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java14
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java8
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/SubWindowOrder.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java33
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java10
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java16
-rw-r--r--uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java2
156 files changed, 1084 insertions, 981 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/event/FieldEvents.java b/compatibility-server/src/main/java/com/vaadin/v7/event/FieldEvents.java
index 2eeeb4c2ee..7a745fa464 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/event/FieldEvents.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/event/FieldEvents.java
@@ -20,6 +20,9 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.ui.Component;
import com.vaadin.util.ReflectTools;
import com.vaadin.v7.ui.Field;
@@ -33,6 +36,68 @@ import com.vaadin.v7.ui.TextField;
public interface FieldEvents {
/**
+ * The interface for adding and removing <code>FocusEvent</code> listeners.
+ * By implementing this interface a class explicitly announces that it will
+ * generate a <code>FocusEvent</code> when it receives keyboard focus.
+ *
+ * @since 6.2
+ * @see FocusListener
+ * @see FocusEvent
+ */
+ @Deprecated
+ public interface FocusNotifier extends Serializable {
+ /**
+ * Adds a <code>FocusListener</code> to the Component which gets fired
+ * when a <code>Field</code> receives keyboard focus.
+ *
+ * @param listener
+ * @see FocusListener
+ * @since 6.2
+ */
+ public void addFocusListener(FocusListener listener);
+
+ /**
+ * Removes a <code>FocusListener</code> from the Component.
+ *
+ * @param listener
+ * @see FocusListener
+ * @since 6.2
+ */
+ public void removeFocusListener(FocusListener listener);
+ }
+
+ /**
+ * The interface for adding and removing <code>BlurEvent</code> listeners.
+ * By implementing this interface a class explicitly announces that it will
+ * generate a <code>BlurEvent</code> when it loses keyboard focus.
+ *
+ * @since 6.2
+ * @see BlurListener
+ * @see BlurEvent
+ */
+ @Deprecated
+ public interface BlurNotifier extends Serializable {
+ /**
+ * Adds a <code>BlurListener</code> to the Component which gets fired
+ * when a <code>Field</code> loses keyboard focus.
+ *
+ * @param listener
+ * @see BlurListener
+ * @since 6.2
+ */
+ public void addBlurListener(BlurListener listener);
+
+ /**
+ * Removes a <code>BlurListener</code> from the Component.
+ *
+ * @param listener
+ * @see BlurListener
+ * @since 6.2
+ */
+ public void removeBlurListener(BlurListener listener);
+ }
+
+ /**
* TextChangeEvents are fired when the user is editing the text content of a
* field. Most commonly text change events are triggered by typing text with
* keyboard, but e.g. pasting content from clip board to a text field also
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
index d2b4665bda..8a6b4849f8 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
@@ -24,15 +24,15 @@ import org.jsoup.nodes.Element;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.BlurNotifier;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.v7.event.FieldEvents.BlurNotifier;
+import com.vaadin.v7.event.FieldEvents.FocusNotifier;
import com.vaadin.v7.event.FieldEvents.TextChangeEvent;
import com.vaadin.v7.event.FieldEvents.TextChangeListener;
import com.vaadin.v7.event.FieldEvents.TextChangeNotifier;
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
index 37d427b503..0ecfa9657f 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
@@ -24,7 +24,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
@@ -34,6 +33,7 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
import com.vaadin.v7.data.Container;
import com.vaadin.v7.data.util.filter.SimpleStringFilter;
+import com.vaadin.v7.event.FieldEvents;
import com.vaadin.v7.shared.ui.combobox.ComboBoxConstants;
import com.vaadin.v7.shared.ui.combobox.ComboBoxState;
import com.vaadin.v7.shared.ui.combobox.FilteringMode;
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java
index 4ee2ee4648..14d0145730 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java
@@ -28,7 +28,6 @@ import java.util.logging.Logger;
import org.jsoup.nodes.Element;
-import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
@@ -45,6 +44,7 @@ import com.vaadin.v7.data.Validator;
import com.vaadin.v7.data.Validator.InvalidValueException;
import com.vaadin.v7.data.util.converter.Converter;
import com.vaadin.v7.data.validator.DateRangeValidator;
+import com.vaadin.v7.event.FieldEvents;
import com.vaadin.v7.shared.ui.datefield.DateFieldConstants;
import com.vaadin.v7.shared.ui.datefield.TextualDateFieldState;
@@ -73,7 +73,7 @@ public class DateField extends AbstractField<Date> implements
/**
* Resolution identifier: seconds.
- *
+ *
* @deprecated As of 7.0, use {@link Resolution#SECOND}
*/
@Deprecated
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
index 752884663f..3d535f2584 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
@@ -18,13 +18,13 @@ package com.vaadin.v7.ui;
import java.util.Collection;
-import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.v7.data.Container;
+import com.vaadin.v7.event.FieldEvents;
/**
* This is a simple drop-down select without, for instance, support for
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
index 0dba641909..2cf1f57962 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
@@ -23,7 +23,6 @@ import java.util.Set;
import org.jsoup.nodes.Element;
-import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
@@ -33,6 +32,7 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignFormatter;
import com.vaadin.v7.data.Container;
+import com.vaadin.v7.event.FieldEvents;
import com.vaadin.v7.shared.ui.optiongroup.OptionGroupConstants;
import com.vaadin.v7.shared.ui.optiongroup.OptionGroupState;
diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
new file mode 100644
index 0000000000..0d6166b2d9
--- /dev/null
+++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
@@ -0,0 +1,181 @@
+package com.vaadin.tests.server.component;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.easymock.EasyMock;
+import org.junit.Assert;
+
+import com.vaadin.tests.VaadinClasses;
+import com.vaadin.ui.Component;
+
+public abstract class AbstractListenerMethodsTestBase {
+
+ public static void main(String[] args) {
+ findAllListenerMethods();
+ }
+
+ private static void findAllListenerMethods() {
+ Set<Class<?>> classes = new HashSet<>();
+ for (Class<?> c : VaadinClasses.getAllServerSideClasses()) {
+ while (c != null && c.getName().startsWith("com.vaadin.")) {
+ classes.add(c);
+ c = c.getSuperclass();
+ }
+ }
+
+ for (Class<?> c : classes) {
+ boolean found = false;
+ for (Method m : c.getDeclaredMethods()) {
+ String methodName = m.getName();
+ if (methodName.startsWith("add")
+ && methodName.endsWith("Listener")
+ && !"addListener".equals(methodName)) {
+ if (m.getParameterTypes().length != 1) {
+ continue;
+ }
+ String packageName = "com.vaadin.tests.server";
+ if (Component.class.isAssignableFrom(c)) {
+ packageName += ".component."
+ + c.getSimpleName().toLowerCase();
+ continue;
+ }
+
+ if (!found) {
+ found = true;
+ System.out.println("package " + packageName + ";");
+
+ System.out.println("import "
+ + AbstractListenerMethodsTestBase.class
+ .getName()
+ + ";");
+ System.out.println("import " + c.getName() + ";");
+ System.out
+ .println(
+ "public class " + c.getSimpleName()
+ + "Listeners extends "
+ + AbstractListenerMethodsTestBase.class
+ .getSimpleName()
+ + " {");
+ }
+
+ String listenerClassName = m.getParameterTypes()[0]
+ .getSimpleName();
+ String eventClassName = listenerClassName
+ .replaceFirst("Listener$", "Event");
+ System.out.println("public void test" + listenerClassName
+ + "() throws Exception {");
+ System.out.println(" testListener(" + c.getSimpleName()
+ + ".class, " + eventClassName + ".class, "
+ + listenerClassName + ".class);");
+ System.out.println("}");
+ }
+ }
+ if (found) {
+ System.out.println("}");
+ System.out.println();
+ }
+ }
+ }
+
+ protected void testListenerAddGetRemove(Class<?> testClass,
+ Class<?> eventClass, Class<?> listenerClass) throws Exception {
+ // Create a component for testing
+ Object c = testClass.newInstance();
+ testListenerAddGetRemove(testClass, eventClass, listenerClass, c);
+
+ }
+
+ protected void testListenerAddGetRemove(Class<?> cls, Class<?> eventClass,
+ Class<?> listenerClass, Object c) throws Exception {
+
+ Object mockListener1 = EasyMock.createMock(listenerClass);
+ Object mockListener2 = EasyMock.createMock(listenerClass);
+
+ // Verify we start from no listeners
+ verifyListeners(c, eventClass);
+
+ // Add one listener and verify
+ addListener(c, mockListener1, listenerClass);
+ verifyListeners(c, eventClass, mockListener1);
+
+ // Add another listener and verify
+ addListener(c, mockListener2, listenerClass);
+ verifyListeners(c, eventClass, mockListener1, mockListener2);
+
+ // Ensure we can fetch using parent class also
+ if (eventClass.getSuperclass() != null) {
+ verifyListeners(c, eventClass.getSuperclass(), mockListener1,
+ mockListener2);
+ }
+
+ // Remove the first and verify
+ removeListener(c, mockListener1, listenerClass);
+ verifyListeners(c, eventClass, mockListener2);
+
+ // Remove the remaining and verify
+ removeListener(c, mockListener2, listenerClass);
+ verifyListeners(c, eventClass);
+
+ }
+
+ private void removeListener(Object c, Object listener,
+ Class<?> listenerClass) throws IllegalArgumentException,
+ IllegalAccessException, InvocationTargetException,
+ SecurityException, NoSuchMethodException {
+ Method method = getRemoveListenerMethod(c.getClass(), listenerClass);
+ method.invoke(c, listener);
+
+ }
+
+ private void addListener(Object c, Object listener1, Class<?> listenerClass)
+ throws IllegalArgumentException, IllegalAccessException,
+ InvocationTargetException, SecurityException,
+ NoSuchMethodException {
+ Method method = getAddListenerMethod(c.getClass(), listenerClass);
+ method.invoke(c, listener1);
+ }
+
+ private Collection<?> getListeners(Object c, Class<?> eventType)
+ throws IllegalArgumentException, IllegalAccessException,
+ InvocationTargetException, SecurityException,
+ NoSuchMethodException {
+ Method method = getGetListenersMethod(c.getClass());
+ return (Collection<?>) method.invoke(c, eventType);
+ }
+
+ private Method getGetListenersMethod(Class<? extends Object> cls)
+ throws SecurityException, NoSuchMethodException {
+ return cls.getMethod("getListeners", Class.class);
+ }
+
+ private Method getAddListenerMethod(Class<?> cls, Class<?> listenerClass)
+ throws SecurityException, NoSuchMethodException {
+ return cls.getMethod("add" + listenerClass.getSimpleName(),
+ listenerClass);
+
+ }
+
+ private Method getRemoveListenerMethod(Class<?> cls, Class<?> listenerClass)
+ throws SecurityException, NoSuchMethodException {
+ return cls.getMethod("remove" + listenerClass.getSimpleName(),
+ listenerClass);
+
+ }
+
+ private void verifyListeners(Object c, Class<?> eventClass,
+ Object... expectedListeners) throws IllegalArgumentException,
+ SecurityException, IllegalAccessException,
+ InvocationTargetException, NoSuchMethodException {
+ Collection<?> registeredListeners = getListeners(c, eventClass);
+ Assert.assertEquals("Number of listeners", expectedListeners.length,
+ registeredListeners.size());
+
+ Assert.assertArrayEquals(expectedListeners,
+ registeredListeners.toArray());
+
+ }
+} \ No newline at end of file
diff --git a/server/src/main/java/com/vaadin/event/Action.java b/server/src/main/java/com/vaadin/event/Action.java
index 392f23dffe..49b8033417 100644
--- a/server/src/main/java/com/vaadin/event/Action.java
+++ b/server/src/main/java/com/vaadin/event/Action.java
@@ -19,6 +19,7 @@ package com.vaadin.event;
import java.io.Serializable;
import com.vaadin.server.Resource;
+import com.vaadin.shared.Registration;
/**
* Implements the action framework. This class contains subinterfaces for action
@@ -106,8 +107,14 @@ public class Action implements Serializable {
}
public interface ShortcutNotifier extends Serializable {
- public void addShortcutListener(ShortcutListener shortcut);
+ public Registration addShortcutListener(ShortcutListener shortcut);
+ /**
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addShortcutListener(ShortcutListener)}.
+ */
+ @Deprecated
public void removeShortcutListener(ShortcutListener shortcut);
}
diff --git a/server/src/main/java/com/vaadin/event/ContextClickEvent.java b/server/src/main/java/com/vaadin/event/ContextClickEvent.java
index d1b089af08..ecf53e2ba2 100644
--- a/server/src/main/java/com/vaadin/event/ContextClickEvent.java
+++ b/server/src/main/java/com/vaadin/event/ContextClickEvent.java
@@ -18,8 +18,10 @@ package com.vaadin.event;
import java.io.Serializable;
import java.lang.reflect.Method;
+import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.ui.Component;
import com.vaadin.util.ReflectTools;
@@ -64,10 +66,14 @@ public class ContextClickEvent extends ClickEvent {
* Adds a context click listener that gets notified when a context click
* happens.
*
+ * @see Registration
+ *
* @param listener
- * the context click listener to add
+ * the context click listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addContextClickListener(ContextClickListener listener);
+ public Registration addContextClickListener(
+ ContextClickListener listener);
/**
* Removes a context click listener that was previously added with
@@ -75,7 +81,12 @@ public class ContextClickEvent extends ClickEvent {
*
* @param listener
* the context click listener to remove
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addContextClickListener(FocusListener)}.
*/
+ @Deprecated
public void removeContextClickListener(ContextClickListener listener);
}
diff --git a/server/src/main/java/com/vaadin/event/EventRouter.java b/server/src/main/java/com/vaadin/event/EventRouter.java
index 9ef6c8123b..c5237d9aca 100644
--- a/server/src/main/java/com/vaadin/event/EventRouter.java
+++ b/server/src/main/java/com/vaadin/event/EventRouter.java
@@ -23,6 +23,7 @@ import java.util.EventObject;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Objects;
import java.util.logging.Logger;
import com.vaadin.server.ErrorEvent;
@@ -51,6 +52,7 @@ public class EventRouter implements MethodEventSource {
*/
@Override
public void addListener(Class<?> eventType, Object object, Method method) {
+ Objects.requireNonNull(object, "Listener must not be null.");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
@@ -65,6 +67,7 @@ public class EventRouter implements MethodEventSource {
@Override
public void addListener(Class<?> eventType, Object object,
String methodName) {
+ Objects.requireNonNull(object, "Listener must not be null.");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
diff --git a/server/src/main/java/com/vaadin/event/FieldEvents.java b/server/src/main/java/com/vaadin/event/FieldEvents.java
index ba84e96b3f..3a4cfc209e 100644
--- a/server/src/main/java/com/vaadin/event/FieldEvents.java
+++ b/server/src/main/java/com/vaadin/event/FieldEvents.java
@@ -20,6 +20,7 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import com.vaadin.shared.EventId;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
import com.vaadin.ui.Component;
import com.vaadin.ui.Component.Event;
@@ -45,20 +46,27 @@ public interface FieldEvents {
* when a <code>Field</code> receives keyboard focus.
*
* @param listener
+ * the focus listener to add, not null
+ * @return a registration object for removing the listener
* @see FocusListener
- * @since 6.2
+ * @see Registration
+ * @since 8.0
*/
- public void addFocusListener(FocusListener listener);
+ public Registration addFocusListener(FocusListener listener);
/**
- * Removes a <code>FocusListener</code> from the Component.
+ * Removes a <code>BlurListener</code> from the Component.
*
* @param listener
* @see FocusListener
* @since 6.2
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addFocusListener(FocusListener)}.
*/
+ @Deprecated
public void removeFocusListener(FocusListener listener);
-
}
/**
@@ -75,21 +83,31 @@ public interface FieldEvents {
* Adds a <code>BlurListener</code> to the Component which gets fired
* when a <code>Field</code> loses keyboard focus.
*
- * @param listener
* @see BlurListener
- * @since 6.2
+ * @see Registration
+ * @since 8.0
+ *
+ * @param listener
+ * the blur listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addBlurListener(BlurListener listener);
+ public Registration addBlurListener(BlurListener listener);
/**
* Removes a <code>BlurListener</code> from the Component.
*
- * @param listener
* @see BlurListener
* @since 6.2
+ *
+ * @param listener
+ * the listener to remove
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addFocusListener(FocusListener)}.
*/
+ @Deprecated
public void removeBlurListener(BlurListener listener);
-
}
/**
diff --git a/server/src/main/java/com/vaadin/event/LayoutEvents.java b/server/src/main/java/com/vaadin/event/LayoutEvents.java
index 9d6dd20fff..627a9610ed 100644
--- a/server/src/main/java/com/vaadin/event/LayoutEvents.java
+++ b/server/src/main/java/com/vaadin/event/LayoutEvents.java
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.shared.Connector;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.util.ReflectTools;
@@ -72,35 +73,27 @@ public interface LayoutEvents {
* The child component that was clicked is included in the
* {@link LayoutClickEvent}.
*
- * Use {@link #removeListener(LayoutClickListener)} to remove the
- * listener.
+ * @see Registration
*
* @param listener
* The listener to add
+ * @return a registration object for removing the listener
*/
- public void addLayoutClickListener(LayoutClickListener listener);
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addLayoutClickListener(LayoutClickListener)}
- **/
- @Deprecated
- public void addListener(LayoutClickListener listener);
+ public Registration addLayoutClickListener(
+ LayoutClickListener listener);
/**
* Removes an LayoutClickListener.
*
* @param listener
* LayoutClickListener to be removed
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addLayoutClickListener(LayoutClickListener)}.
*/
- public void removeLayoutClickListener(LayoutClickListener listener);
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeLayoutClickListener(LayoutClickListener)}
- **/
@Deprecated
- public void removeListener(LayoutClickListener listener);
+ public void removeLayoutClickListener(LayoutClickListener listener);
}
/**
diff --git a/server/src/main/java/com/vaadin/event/MethodEventSource.java b/server/src/main/java/com/vaadin/event/MethodEventSource.java
index f10f136671..42f4902122 100644
--- a/server/src/main/java/com/vaadin/event/MethodEventSource.java
+++ b/server/src/main/java/com/vaadin/event/MethodEventSource.java
@@ -57,6 +57,8 @@ public interface MethodEventSource extends Serializable {
* @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);
@@ -90,6 +92,8 @@ public interface MethodEventSource extends Serializable {
* @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,
String methodName);
diff --git a/server/src/main/java/com/vaadin/event/UIEvents.java b/server/src/main/java/com/vaadin/event/UIEvents.java
index a822c35926..1f696e9d6c 100644
--- a/server/src/main/java/com/vaadin/event/UIEvents.java
+++ b/server/src/main/java/com/vaadin/event/UIEvents.java
@@ -18,6 +18,7 @@ package com.vaadin.event;
import java.io.Serializable;
import java.lang.reflect.Method;
+import com.vaadin.shared.Registration;
import com.vaadin.ui.Component;
import com.vaadin.ui.UI;
import com.vaadin.util.ReflectTools;
@@ -98,10 +99,12 @@ public interface UIEvents {
*
* @see UI#setPollInterval(int)
* @see #removePollListener(PollListener)
+ * @see Registration
* @param listener
- * the {@link PollListener} to add
+ * the {@link PollListener} to add, not null
+ * @return a registration object for removing the listener
*/
- public void addPollListener(PollListener listener);
+ public Registration addPollListener(PollListener listener);
/**
* Remove a poll listener.
@@ -109,7 +112,12 @@ public interface UIEvents {
* @see #addPollListener(PollListener)
* @param listener
* the listener to be removed
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addPollListener(PollListener)}.
*/
+ @Deprecated
public void removePollListener(PollListener listener);
}
diff --git a/server/src/main/java/com/vaadin/navigator/Navigator.java b/server/src/main/java/com/vaadin/navigator/Navigator.java
index 13e3b4c2e7..4fb3906e9e 100644
--- a/server/src/main/java/com/vaadin/navigator/Navigator.java
+++ b/server/src/main/java/com/vaadin/navigator/Navigator.java
@@ -722,8 +722,7 @@ public class Navigator implements Serializable {
// a copy of the listener list is needed to avoid
// ConcurrentModificationException as a listener can add/remove
// listeners
- for (ViewChangeListener l : new ArrayList<>(
- listeners)) {
+ for (ViewChangeListener l : new ArrayList<>(listeners)) {
if (!l.beforeViewChange(event)) {
return false;
}
@@ -786,8 +785,7 @@ public class Navigator implements Serializable {
// a copy of the listener list is needed to avoid
// ConcurrentModificationException as a listener can add/remove
// listeners
- for (ViewChangeListener l : new ArrayList<>(
- listeners)) {
+ for (ViewChangeListener l : new ArrayList<>(listeners)) {
l.afterViewChange(event);
}
}
diff --git a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
index ea969bea2b..3299568778 100644
--- a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
@@ -30,11 +30,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import com.vaadin.event.EventRouter;
import com.vaadin.event.MethodEventSource;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.shared.communication.SharedState;
@@ -95,9 +97,11 @@ public abstract class AbstractClientConnector
private static final ConcurrentHashMap<Class<? extends AbstractClientConnector>, Class<? extends SharedState>> stateTypeCache = new ConcurrentHashMap<>();
@Override
- public void addAttachListener(AttachListener listener) {
+ public Registration addAttachListener(AttachListener listener) {
addListener(AttachEvent.ATTACH_EVENT_IDENTIFIER, AttachEvent.class,
listener, AttachListener.attachMethod);
+ return () -> removeListener(AttachEvent.ATTACH_EVENT_IDENTIFIER,
+ AttachEvent.class, listener);
}
@Override
@@ -107,9 +111,11 @@ public abstract class AbstractClientConnector
}
@Override
- public void addDetachListener(DetachListener listener) {
+ public Registration addDetachListener(DetachListener listener) {
addListener(DetachEvent.DETACH_EVENT_IDENTIFIER, DetachEvent.class,
listener, DetachListener.detachMethod);
+ return () -> removeListener(DetachEvent.DETACH_EVENT_IDENTIFIER,
+ DetachEvent.class, listener);
}
@Override
diff --git a/server/src/main/java/com/vaadin/server/ClientConnector.java b/server/src/main/java/com/vaadin/server/ClientConnector.java
index 87c6b8309e..80453d4733 100644
--- a/server/src/main/java/com/vaadin/server/ClientConnector.java
+++ b/server/src/main/java/com/vaadin/server/ClientConnector.java
@@ -23,6 +23,7 @@ import java.util.List;
import com.vaadin.event.ConnectorEvent;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.shared.Connector;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.ui.UI;
import com.vaadin.util.ReflectTools;
@@ -95,12 +96,14 @@ public interface ClientConnector extends Connector {
public void detach(DetachEvent event);
}
- public void addAttachListener(AttachListener listener);
+ public Registration addAttachListener(AttachListener listener);
+ @Deprecated
public void removeAttachListener(AttachListener listener);
- public void addDetachListener(DetachListener listener);
+ public Registration addDetachListener(DetachListener listener);
+ @Deprecated
public void removeDetachListener(DetachListener listener);
/**
diff --git a/server/src/main/java/com/vaadin/server/DragAndDropService.java b/server/src/main/java/com/vaadin/server/DragAndDropService.java
index 23bea5138b..d23c87e468 100644
--- a/server/src/main/java/com/vaadin/server/DragAndDropService.java
+++ b/server/src/main/java/com/vaadin/server/DragAndDropService.java
@@ -34,6 +34,7 @@ import com.vaadin.event.dd.TargetDetails;
import com.vaadin.event.dd.TargetDetailsImpl;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.shared.ApplicationConstants;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.SharedState;
import com.vaadin.shared.ui.dd.DragEventType;
import com.vaadin.ui.Component;
@@ -360,18 +361,26 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
}
@Override
- public void addAttachListener(AttachListener listener) {
+ public Registration addAttachListener(AttachListener listener) {
+ return () -> {
+ /* NO-OP */
+ };
}
@Override
+ @Deprecated
public void removeAttachListener(AttachListener listener) {
}
@Override
- public void addDetachListener(DetachListener listener) {
+ public Registration addDetachListener(DetachListener listener) {
+ return () -> {
+ /* NO-OP */
+ };
}
@Override
+ @Deprecated
public void removeDetachListener(DetachListener listener) {
}
diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java
index 9330c08a28..35fc6b96e8 100644
--- a/server/src/main/java/com/vaadin/server/Page.java
+++ b/server/src/main/java/com/vaadin/server/Page.java
@@ -27,6 +27,8 @@ import java.util.LinkedList;
import java.util.List;
import com.vaadin.event.EventRouter;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.ui.PageClientRpc;
import com.vaadin.shared.ui.ui.PageState;
@@ -506,24 +508,18 @@ public class Page implements Serializable {
*
* @see #getUriFragment()
* @see #setUriFragment(String)
- * @see #removeUriFragmentChangedListener(UriFragmentChangedListener)
+ * @see Registration
*
* @param listener
* the URI fragment listener to add
+ * @return a registration object for removing the listener
*/
- public void addUriFragmentChangedListener(
+ public Registration addUriFragmentChangedListener(
Page.UriFragmentChangedListener listener) {
addListener(UriFragmentChangedEvent.class, listener,
URI_FRAGMENT_CHANGED_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addUriFragmentChangedListener(UriFragmentChangedListener)}
- **/
- @Deprecated
- public void addListener(Page.UriFragmentChangedListener listener) {
- addUriFragmentChangedListener(listener);
+ return () -> removeListener(UriFragmentChangedEvent.class, listener,
+ URI_FRAGMENT_CHANGED_METHOD);
}
/**
@@ -533,7 +529,12 @@ public class Page implements Serializable {
* the URI fragment listener to remove
*
* @see Page#addUriFragmentChangedListener(UriFragmentChangedListener)
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addUriFragmentChangedListener(FocusListener)}.
*/
+ @Deprecated
public void removeUriFragmentChangedListener(
Page.UriFragmentChangedListener listener) {
removeListener(UriFragmentChangedEvent.class, listener,
@@ -541,15 +542,6 @@ public class Page implements Serializable {
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeUriFragmentChangedListener(UriFragmentChangedListener)}
- **/
- @Deprecated
- public void removeListener(Page.UriFragmentChangedListener listener) {
- removeUriFragmentChangedListener(listener);
- }
-
- /**
* Sets the fragment part in the current location URI. Optionally fires a
* {@link UriFragmentChangedEvent}.
* <p>
@@ -745,24 +737,23 @@ public class Page implements Serializable {
*
* @param resizeListener
* the listener to add
+ * @return a registration object for removing the listener
*
* @see BrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent)
* @see UI#setResizeLazy(boolean)
+ * @see Registration
*/
- public void addBrowserWindowResizeListener(
+ public Registration addBrowserWindowResizeListener(
BrowserWindowResizeListener resizeListener) {
addListener(BrowserWindowResizeEvent.class, resizeListener,
BROWSER_RESIZE_METHOD);
getState(true).hasResizeListeners = true;
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addBrowserWindowResizeListener(BrowserWindowResizeListener)}
- **/
- @Deprecated
- public void addListener(BrowserWindowResizeListener resizeListener) {
- addBrowserWindowResizeListener(resizeListener);
+ return () -> {
+ removeListener(BrowserWindowResizeEvent.class, resizeListener,
+ BROWSER_RESIZE_METHOD);
+ getState(true).hasResizeListeners = hasEventRouter()
+ && eventRouter.hasListeners(BrowserWindowResizeEvent.class);
+ };
}
/**
@@ -771,7 +762,13 @@ public class Page implements Serializable {
*
* @param resizeListener
* the listener to remove
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addBrowserWindowResizeListener(BrowserWindowResizeListener)}
+ * .
*/
+ @Deprecated
public void removeBrowserWindowResizeListener(
BrowserWindowResizeListener resizeListener) {
removeListener(BrowserWindowResizeEvent.class, resizeListener,
@@ -781,15 +778,6 @@ public class Page implements Serializable {
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeBrowserWindowResizeListener(BrowserWindowResizeListener)}
- **/
- @Deprecated
- public void removeListener(BrowserWindowResizeListener resizeListener) {
- removeBrowserWindowResizeListener(resizeListener);
- }
-
- /**
* Gets the last known height of the browser window in which this UI
* resides.
*
diff --git a/server/src/main/java/com/vaadin/server/data/AbstractDataSource.java b/server/src/main/java/com/vaadin/server/data/AbstractDataSource.java
index 9dba0bd35e..f54056e1b0 100644
--- a/server/src/main/java/com/vaadin/server/data/AbstractDataSource.java
+++ b/server/src/main/java/com/vaadin/server/data/AbstractDataSource.java
@@ -36,7 +36,6 @@ public abstract class AbstractDataSource<T> implements DataSource<T> {
@Override
public Registration addDataSourceListener(DataSourceListener listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(DataChangeEvent.class, listener,
DataSourceListener.class.getMethods()[0]);
return () -> removeListener(DataChangeEvent.class, listener);
diff --git a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
index d435bc806b..5aa008e829 100644
--- a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Objects;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
@@ -32,6 +33,7 @@ import com.vaadin.server.Sizeable;
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.absolutelayout.AbsoluteLayoutServerRpc;
import com.vaadin.shared.ui.absolutelayout.AbsoluteLayoutState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
@@ -643,38 +645,21 @@ public class AbsoluteLayout 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)
*
diff --git a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
index d7d12c6d03..695187a6eb 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
@@ -18,10 +18,12 @@ package com.vaadin.ui;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
+import java.util.Objects;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerServerRpc;
import com.vaadin.shared.ui.colorpicker.ColorPickerState;
@@ -217,11 +219,13 @@ public abstract class AbstractColorPicker extends AbstractComponent
}
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
+ public Registration addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
+ return () -> removeListener(ColorChangeEvent.class, listener);
}
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
removeListener(ColorChangeEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
index a34b09e9d8..f794cab51b 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Logger;
@@ -57,6 +58,7 @@ import com.vaadin.shared.ComponentConstants;
import com.vaadin.shared.ContextClickRpc;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.ComponentStateUtil;
import com.vaadin.shared.util.SharedUtil;
import com.vaadin.ui.declarative.DesignAttributeHandler;
@@ -787,16 +789,14 @@ public abstract class AbstractComponent extends AbstractClientConnector
* implemented interface.
*/
@Override
- public void addListener(Component.Listener listener) {
+ public Registration addListener(Component.Listener listener) {
addListener(Component.Event.class, listener, COMPONENT_EVENT_METHOD);
+ return () -> removeListener(Component.Event.class, listener,
+ COMPONENT_EVENT_METHOD);
}
- /*
- * Removes a previously registered listener from this component. Don't add a
- * JavaDoc comment here, we use the default documentation from implemented
- * interface.
- */
@Override
+ @Deprecated
public void removeListener(Component.Listener listener) {
removeListener(Component.Event.class, listener, COMPONENT_EVENT_METHOD);
}
@@ -1084,8 +1084,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
} else {
// remove responsive extensions
- List<Extension> extensions = new ArrayList<>(
- getExtensions());
+ List<Extension> extensions = new ArrayList<>(getExtensions());
for (Extension e : extensions) {
if (e instanceof Responsive) {
removeExtension(e);
@@ -1263,8 +1262,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
* implementation
*/
protected Collection<String> getCustomAttributes() {
- ArrayList<String> l = new ArrayList<>(
- Arrays.asList(customAttributes));
+ ArrayList<String> l = new ArrayList<>(Arrays.asList(customAttributes));
if (this instanceof Focusable) {
l.add("tab-index");
l.add("tabindex");
@@ -1365,10 +1363,13 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
- public void addShortcutListener(ShortcutListener shortcut) {
+ public Registration addShortcutListener(ShortcutListener shortcut) {
+ Objects.requireNonNull(shortcut, "Listener must not be null.");
getActionManager().addAction(shortcut);
+ return () -> getActionManager().removeAction(shortcut);
}
+ @Deprecated
public void removeShortcutListener(ShortcutListener shortcut) {
getActionManager().removeAction(shortcut);
}
@@ -1394,7 +1395,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
@Override
- public void addContextClickListener(ContextClickListener listener) {
+ public Registration addContextClickListener(ContextClickListener listener) {
// Register default Context Click RPC if needed. This RPC won't be
// called if there are no listeners on the server-side. A client-side
// connector can override this and use a different RPC channel.
@@ -1410,9 +1411,12 @@ public abstract class AbstractComponent extends AbstractClientConnector
addListener(EventId.CONTEXT_CLICK, ContextClickEvent.class, listener,
ContextClickEvent.CONTEXT_CLICK_METHOD);
+ return () -> removeListener(EventId.CONTEXT_CLICK,
+ ContextClickEvent.class, listener);
}
@Override
+ @Deprecated
public void removeContextClickListener(ContextClickListener listener) {
removeListener(EventId.CONTEXT_CLICK, ContextClickEvent.class,
listener);
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
index b5fe4e9bcd..8c10027cc4 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import com.vaadin.server.ComponentSizeValidator;
+import com.vaadin.shared.Registration;
/**
* Extension to {@link AbstractComponent} that defines the default
@@ -99,58 +100,36 @@ public abstract class AbstractComponentContainer extends AbstractComponent
/* documented in interface */
@Override
- public void addComponentAttachListener(ComponentAttachListener listener) {
+ public Registration addComponentAttachListener(
+ ComponentAttachListener listener) {
addListener(ComponentAttachEvent.class, listener,
ComponentAttachListener.attachMethod);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)}
- **/
- @Override
- @Deprecated
- public void addListener(ComponentAttachListener listener) {
- addComponentAttachListener(listener);
+ return () -> removeListener(ComponentAttachEvent.class, listener,
+ ComponentAttachListener.attachMethod);
}
/* documented in interface */
@Override
+ @Deprecated
public void removeComponentAttachListener(
ComponentAttachListener listener) {
removeListener(ComponentAttachEvent.class, listener,
ComponentAttachListener.attachMethod);
}
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)}
- **/
- @Override
- @Deprecated
- public void addListener(ComponentDetachListener listener) {
- addComponentDetachListener(listener);
- }
-
/* documented in interface */
@Override
- public void addComponentDetachListener(ComponentDetachListener listener) {
+ public Registration addComponentDetachListener(
+ ComponentDetachListener listener) {
addListener(ComponentDetachEvent.class, listener,
ComponentDetachListener.detachMethod);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)}
- **/
- @Override
- @Deprecated
- public void removeListener(ComponentAttachListener listener) {
- removeComponentAttachListener(listener);
+ return () -> removeListener(ComponentDetachEvent.class, listener,
+ ComponentDetachListener.detachMethod);
}
/* documented in interface */
@Override
+ @Deprecated
public void removeComponentDetachListener(
ComponentDetachListener listener) {
removeListener(ComponentDetachEvent.class, listener,
@@ -158,16 +137,6 @@ public abstract class AbstractComponentContainer extends AbstractComponent
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)}
- **/
- @Override
- @Deprecated
- public void removeListener(ComponentDetachListener listener) {
- removeComponentDetachListener(listener);
- }
-
- /**
* Fires the component attached event. This should be called by the
* addComponent methods after the component have been added to this
* container.
diff --git a/server/src/main/java/com/vaadin/ui/AbstractDateField.java b/server/src/main/java/com/vaadin/ui/AbstractDateField.java
index ac945256f7..ab0aed1b0c 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractDateField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractDateField.java
@@ -32,11 +32,14 @@ import com.vaadin.data.Result;
import com.vaadin.data.validator.RangeValidator;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.BlurNotifier;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.UserError;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.datefield.DateFieldConstants;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.shared.ui.datefield.TextualDateFieldState;
@@ -52,7 +55,7 @@ import com.vaadin.ui.declarative.DesignContext;
*
*/
public abstract class AbstractDateField extends AbstractField<Date>
- implements LegacyComponent {
+ implements LegacyComponent, FocusNotifier, BlurNotifier {
/**
* Value of the field.
@@ -669,46 +672,30 @@ public abstract class AbstractDateField extends AbstractField<Date>
markAsDirty();
}
- /**
- * Adds a <code>FocusListener</code> to the Component which gets fired when
- * a <code>LegacyField</code> receives keyboard focus.
- *
- * @param listener
- * @see FocusListener
- */
- public void addFocusListener(FocusListener listener) {
+ @Override
+ public Registration addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
+ return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
+ listener);
}
- /**
- * Removes a <code>FocusListener</code> from the Component.
- *
- * @param listener
- * @see FocusListener
- */
+ @Override
+ @Deprecated
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
- /**
- * Adds a <code>BlurListener</code> to the Component which gets fired when a
- * <code>LegacyField</code> loses keyboard focus.
- *
- * @param listener
- * @see BlurListener
- */
- public void addBlurListener(BlurListener listener) {
+ @Override
+ public Registration addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
+ return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
+ listener);
}
- /**
- * Removes a <code>BlurListener</code> from the Component.
- *
- * @param listener
- * @see BlurListener
- */
+ @Override
+ @Deprecated
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractField.java b/server/src/main/java/com/vaadin/ui/AbstractField.java
index 4946d3c95b..012a5df5a1 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractField.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractField.java
@@ -101,7 +101,6 @@ public abstract class AbstractField<T> extends AbstractComponent
@Override
public Registration addValueChangeListener(
ValueChangeListener<? super T> listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(ValueChange.class, listener, VALUE_CHANGE_METHOD);
return () -> removeListener(ValueChange.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractFocusable.java b/server/src/main/java/com/vaadin/ui/AbstractFocusable.java
index ac0f911fbc..eb0c957a80 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractFocusable.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractFocusable.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui;
+import java.util.Objects;
+
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.BlurNotifier;
@@ -22,6 +24,7 @@ import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.event.FieldEvents.FocusNotifier;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.TabIndexState;
import com.vaadin.ui.Component.Focusable;
@@ -45,24 +48,29 @@ public abstract class AbstractFocusable extends AbstractComponent
}
@Override
- public void addBlurListener(BlurListener listener) {
+ public Registration addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
+ return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}
@Override
- public void addFocusListener(FocusListener listener) {
+ public Registration addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
-
+ return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
index 4094ee383c..48b47ca2d5 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
@@ -303,7 +303,6 @@ public abstract class AbstractMultiSelect<T>
*/
public Registration addSelectionListener(
MultiSelectionListener<T> listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(MultiSelectionEvent.class, listener,
SELECTION_CHANGE_METHOD);
return () -> removeListener(MultiSelectionEvent.class, listener);
@@ -404,4 +403,4 @@ public abstract class AbstractMultiSelect<T>
this.itemEnabledProvider = itemEnabledProvider;
}
-} \ No newline at end of file
+}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
index 331a0e72be..3be9ca668a 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
@@ -31,6 +31,7 @@ import com.vaadin.server.Sizeable;
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.orderedlayout.AbstractOrderedLayoutServerRpc;
import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
@@ -367,39 +368,22 @@ public abstract class AbstractOrderedLayout 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);
- }
-
- /**
* Returns the index of the given component.
*
* @param component
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java b/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
index 3e47a739cf..dc92ece1e9 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
@@ -24,6 +24,7 @@ import org.jsoup.select.Elements;
import com.vaadin.server.ComponentSizeValidator;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
+import com.vaadin.shared.Registration;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignException;
@@ -57,14 +58,17 @@ public abstract class AbstractSingleComponentContainer extends AbstractComponent
/* documented in interface */
@Override
- public void addComponentAttachListener(ComponentAttachListener listener) {
+ public Registration addComponentAttachListener(
+ ComponentAttachListener listener) {
addListener(ComponentAttachEvent.class, listener,
ComponentAttachListener.attachMethod);
-
+ return () -> removeListener(ComponentAttachEvent.class, listener,
+ ComponentAttachListener.attachMethod);
}
/* documented in interface */
@Override
+ @Deprecated
public void removeComponentAttachListener(
ComponentAttachListener listener) {
removeListener(ComponentAttachEvent.class, listener,
@@ -73,13 +77,17 @@ public abstract class AbstractSingleComponentContainer extends AbstractComponent
/* documented in interface */
@Override
- public void addComponentDetachListener(ComponentDetachListener listener) {
+ public Registration addComponentDetachListener(
+ ComponentDetachListener listener) {
addListener(ComponentDetachEvent.class, listener,
ComponentDetachListener.detachMethod);
+ return () -> removeListener(ComponentDetachEvent.class, listener,
+ ComponentDetachListener.detachMethod);
}
/* documented in interface */
@Override
+ @Deprecated
public void removeComponentDetachListener(
ComponentDetachListener listener) {
removeListener(ComponentDetachEvent.class, listener,
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
index 257e1c9da8..bf521f34cb 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
@@ -269,7 +269,6 @@ public abstract class AbstractSingleSelect<T> extends
*/
public Registration addSelectionListener(
SingleSelectionListener<T> listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(SingleSelectionChange.class, listener,
SELECTION_CHANGE_METHOD);
return () -> removeListener(SingleSelectionChange.class, listener);
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,45 +576,32 @@ 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.
*
* @since 7.5.0
* @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);
diff --git a/server/src/main/java/com/vaadin/ui/Button.java b/server/src/main/java/com/vaadin/ui/Button.java
index da77a1760b..499713ffbd 100644
--- a/server/src/main/java/com/vaadin/ui/Button.java
+++ b/server/src/main/java/com/vaadin/ui/Button.java
@@ -30,6 +30,7 @@ import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.event.ShortcutListener;
import com.vaadin.server.Resource;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.button.ButtonServerRpc;
import com.vaadin.shared.ui.button.ButtonState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
@@ -118,7 +119,7 @@ public class Button extends AbstractFocusable
*/
public Button(String caption, ClickListener listener) {
this(caption);
- addListener(listener);
+ addClickListener(listener);
}
/**
@@ -306,21 +307,17 @@ public class Button extends AbstractFocusable
/**
* Adds the button click listener.
*
+ * @see Registration
+ *
* @param listener
* the Listener to be added.
+ * @return a registration object for removing the listener
*/
- public void addClickListener(ClickListener listener) {
+ public Registration addClickListener(ClickListener listener) {
addListener(ClickEvent.class, listener,
ClickListener.BUTTON_CLICK_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addClickListener(ClickListener)}
- **/
- @Deprecated
- public void addListener(ClickListener listener) {
- addClickListener(listener);
+ return () -> removeListener(ClickEvent.class, listener,
+ ClickListener.BUTTON_CLICK_METHOD);
}
/**
@@ -328,22 +325,18 @@ public class Button extends AbstractFocusable
*
* @param listener
* the Listener to be removed.
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addClickListener(ClickListener)}.
*/
+ @Deprecated
public void removeClickListener(ClickListener listener) {
removeListener(ClickEvent.class, listener,
ClickListener.BUTTON_CLICK_METHOD);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeClickListener(ClickListener)}
- **/
- @Deprecated
- public void removeListener(ClickListener listener) {
- removeClickListener(listener);
- }
-
- /**
* Simulates a button click, notifying all server-side listeners.
*
* No action is taken is the button is disabled.
diff --git a/server/src/main/java/com/vaadin/ui/CheckBox.java b/server/src/main/java/com/vaadin/ui/CheckBox.java
index 2620b42464..4fa08a82b5 100644
--- a/server/src/main/java/com/vaadin/ui/CheckBox.java
+++ b/server/src/main/java/com/vaadin/ui/CheckBox.java
@@ -21,18 +21,21 @@ import java.util.Collection;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
+import com.vaadin.event.FieldEvents;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
import com.vaadin.shared.ui.checkbox.CheckBoxState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
-public class CheckBox extends AbstractField<Boolean> {
+public class CheckBox extends AbstractField<Boolean>
+ implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
private CheckBoxServerRpc rpc = new CheckBoxServerRpc() {
@@ -145,20 +148,30 @@ public class CheckBox extends AbstractField<Boolean> {
getState().checked = value;
}
- public void addBlurListener(BlurListener listener) {
+ @Override
+ public Registration addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
+ return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
+ listener);
}
+ @Override
+ @Deprecated
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}
- public void addFocusListener(FocusListener listener) {
+ @Override
+ public Registration addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
+ return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
+ listener);
}
+ @Override
+ @Deprecated
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/ColorPickerArea.java b/server/src/main/java/com/vaadin/ui/ColorPickerArea.java
index c4f3971259..dc2adfed3a 100644
--- a/server/src/main/java/com/vaadin/ui/ColorPickerArea.java
+++ b/server/src/main/java/com/vaadin/ui/ColorPickerArea.java
@@ -73,5 +73,4 @@ public class ColorPickerArea extends AbstractColorPicker {
getState().width = "30px";
}
}
-
}
diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java
index 5ed454d370..31dbb7da94 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Consumer;
-import java.util.function.Function;
import com.vaadin.data.HasValue;
import com.vaadin.event.FieldEvents;
@@ -288,23 +287,29 @@ public class ComboBox<T> extends AbstractSingleSelect<T> implements HasValue<T>,
}
@Override
- public void addBlurListener(BlurListener listener) {
+ public Registration addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
+ return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}
@Override
- public void addFocusListener(FocusListener listener) {
+ public Registration addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
+ return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/Component.java b/server/src/main/java/com/vaadin/ui/Component.java
index 993d88d992..ffca8b808c 100644
--- a/server/src/main/java/com/vaadin/ui/Component.java
+++ b/server/src/main/java/com/vaadin/ui/Component.java
@@ -29,6 +29,7 @@ import com.vaadin.server.ErrorMessage;
import com.vaadin.server.Resource;
import com.vaadin.server.Sizeable;
import com.vaadin.server.VariableOwner;
+import com.vaadin.shared.Registration;
import com.vaadin.ui.declarative.DesignContext;
/**
@@ -972,10 +973,11 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
*
* @param listener
* the new Listener to be registered.
+ * @return a registration object for removing this listener
* @see Component.Event
- * @see #removeListener(Listener)
+ * @see Registration
*/
- public void addListener(Component.Listener listener);
+ public Registration addListener(Component.Listener listener);
/**
* Removes a previously registered component event listener from this
@@ -984,7 +986,12 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
* @param listener
* the listener to be removed.
* @see #addListener(Listener)
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addListener(Component.Listener)}.
*/
+ @Deprecated
public void removeListener(Component.Listener listener);
/**
diff --git a/server/src/main/java/com/vaadin/ui/ComponentContainer.java b/server/src/main/java/com/vaadin/ui/ComponentContainer.java
index ba6594d10d..b11f2e9a69 100644
--- a/server/src/main/java/com/vaadin/ui/ComponentContainer.java
+++ b/server/src/main/java/com/vaadin/ui/ComponentContainer.java
@@ -111,33 +111,4 @@ public interface ComponentContainer
* moved to this container.
*/
public void moveComponentsFrom(ComponentContainer source);
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addComponentAttachListener(ComponentAttachListener)}
- **/
- @Deprecated
- public void addListener(ComponentAttachListener listener);
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeComponentAttachListener(ComponentAttachListener)}
- **/
- @Deprecated
- public void removeListener(ComponentAttachListener listener);
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addComponentDetachListener(ComponentDetachListener)}
- **/
- @Deprecated
- public void addListener(ComponentDetachListener listener);
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeComponentDetachListener(ComponentDetachListener)}
- **/
- @Deprecated
- public void removeListener(ComponentDetachListener listener);
-
}
diff --git a/server/src/main/java/com/vaadin/ui/CssLayout.java b/server/src/main/java/com/vaadin/ui/CssLayout.java
index 381e7aa463..d4daf67419 100644
--- a/server/src/main/java/com/vaadin/ui/CssLayout.java
+++ b/server/src/main/java/com/vaadin/ui/CssLayout.java
@@ -17,6 +17,7 @@ package com.vaadin.ui;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Objects;
import org.jsoup.nodes.Element;
@@ -26,6 +27,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.csslayout.CssLayoutServerRpc;
import com.vaadin.shared.ui.csslayout.CssLayoutState;
import com.vaadin.ui.declarative.DesignContext;
@@ -303,39 +305,22 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
}
@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);
- }
-
- /**
* Returns the index of the given component.
*
* @param component
@@ -397,5 +382,4 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
designElement.appendChild(childNode);
}
}
-
}
diff --git a/server/src/main/java/com/vaadin/ui/Embedded.java b/server/src/main/java/com/vaadin/ui/Embedded.java
index b0c7f1725b..e4dcee096f 100644
--- a/server/src/main/java/com/vaadin/ui/Embedded.java
+++ b/server/src/main/java/com/vaadin/ui/Embedded.java
@@ -27,6 +27,7 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.server.Resource;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.embedded.EmbeddedConstants;
import com.vaadin.shared.ui.embedded.EmbeddedServerRpc;
@@ -524,23 +525,17 @@ public class Embedded extends AbstractComponent implements LegacyComponent {
* the user clicks inside the component. Depending on the content the event
* may be blocked and in that case no event is fired.
*
- * Use {@link #removeListener(ClickListener)} to remove the listener.
+ * @see Registration
*
* @param listener
* The listener to add
+ * @return a registration object for removing the listener
*/
- public void addClickListener(ClickListener listener) {
+ public Registration addClickListener(ClickListener listener) {
addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
ClickListener.clickMethod);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addClickListener(ClickListener)}
- **/
- @Deprecated
- public void addListener(ClickListener listener) {
- addClickListener(listener);
+ return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
+ ClickEvent.class, listener);
}
/**
@@ -549,21 +544,17 @@ public class Embedded extends AbstractComponent implements LegacyComponent {
*
* @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)}.
*/
+ @Deprecated
public void removeClickListener(ClickListener listener) {
removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
listener);
}
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeClickListener(ClickListener)}
- **/
- @Deprecated
- public void removeListener(ClickListener listener) {
- removeClickListener(listener);
- }
-
@Override
public void changeVariables(Object source, Map<String, Object> variables) {
// TODO Remove once LegacyComponent is no longer implemented
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index b1a2c64ec8..e2df8b437b 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -2020,7 +2020,6 @@ public class Grid<T> extends AbstractSingleSelect<T> implements HasComponents {
* @return a registration for the listener
*/
public Registration addColumnResizeListener(ColumnResizeListener listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(ColumnResizeEvent.class, listener, COLUMN_RESIZE_METHOD);
return () -> removeListener(ColumnResizeEvent.class, listener,
COLUMN_RESIZE_METHOD);
@@ -2036,7 +2035,6 @@ public class Grid<T> extends AbstractSingleSelect<T> implements HasComponents {
*/
public Registration addItemClickListener(
ItemClickListener<? super T> listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(GridConstants.ITEM_CLICK_EVENT_ID, ItemClick.class,
listener, ITEM_CLICK_METHOD);
return () -> removeListener(ItemClick.class, listener);
@@ -2051,7 +2049,6 @@ public class Grid<T> extends AbstractSingleSelect<T> implements HasComponents {
*/
public Registration addColumnVisibilityChangeListener(
ColumnVisibilityChangeListener listener) {
- Objects.requireNonNull(listener, "listener cannot be null");
addListener(ColumnVisibilityChangeEvent.class, listener,
COLUMN_VISIBILITY_METHOD);
return () -> removeListener(ColumnVisibilityChangeEvent.class, listener,
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)
*
diff --git a/server/src/main/java/com/vaadin/ui/HasComponents.java b/server/src/main/java/com/vaadin/ui/HasComponents.java
index e74eb6dd32..847a6fada2 100644
--- a/server/src/main/java/com/vaadin/ui/HasComponents.java
+++ b/server/src/main/java/com/vaadin/ui/HasComponents.java
@@ -19,6 +19,7 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Iterator;
+import com.vaadin.shared.Registration;
import com.vaadin.util.ReflectTools;
/**
@@ -50,10 +51,13 @@ public interface HasComponents extends Component, Iterable<Component> {
/**
* Listens the component attach events.
*
+ * @see Registration
+ *
* @param listener
- * the listener to add.
+ * the listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addComponentAttachListener(
+ public Registration addComponentAttachListener(
ComponentAttachListener listener);
/**
@@ -61,19 +65,26 @@ public interface HasComponents extends Component, Iterable<Component> {
*
* @param listener
* the listener to removed.
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in
+ * the registration object returned from
+ * {@link #addComponentAttachListener(ComponentAttachListener)}
+ * .
*/
+ @Deprecated
public void removeComponentAttachListener(
ComponentAttachListener listener);
/**
* Listens the component detach events.
*/
- public void addComponentDetachListener(
+ public Registration addComponentDetachListener(
ComponentDetachListener listener);
/**
* Stops the listening component detach events.
*/
+ @Deprecated
public void removeComponentDetachListener(
ComponentDetachListener listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/Image.java b/server/src/main/java/com/vaadin/ui/Image.java
index af698ecc97..fca1bc7b8a 100644
--- a/server/src/main/java/com/vaadin/ui/Image.java
+++ b/server/src/main/java/com/vaadin/ui/Image.java
@@ -20,6 +20,7 @@ import com.vaadin.event.MouseEvents.ClickListener;
import com.vaadin.server.Resource;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.image.ImageServerRpc;
import com.vaadin.shared.ui.image.ImageState;
@@ -76,36 +77,21 @@ public class Image extends AbstractEmbedded {
}
/**
- * @deprecated As of 7.0, use {@link #addClickListener(ClickListener)}
- * instead
- */
- @Deprecated
- public void addListener(ClickListener listener) {
- addClickListener(listener);
- }
-
- /**
* Add a click listener to the component. The listener is called whenever
* the user clicks inside the component. Depending on the content the event
* may be blocked and in that case no event is fired.
*
- * Use {@link #removeClickListener(ClickListener)} to remove the listener.
+ * @see Registration
*
* @param listener
- * The listener to add
+ * The listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addClickListener(ClickListener listener) {
+ public Registration addClickListener(ClickListener listener) {
addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
ClickListener.clickMethod);
- }
-
- /**
- * @deprecated As of 7.0, use {@link #removeClickListener(ClickListener)}
- * instead
- */
- @Deprecated
- public void removeListener(ClickListener listener) {
- removeClickListener(listener);
+ return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
+ ClickEvent.class, listener);
}
/**
@@ -114,7 +100,12 @@ 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)}.
*/
+ @Deprecated
public void removeClickListener(ClickListener listener) {
removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
listener);
diff --git a/server/src/main/java/com/vaadin/ui/LegacyWindow.java b/server/src/main/java/com/vaadin/ui/LegacyWindow.java
index a6771da379..2705d56486 100644
--- a/server/src/main/java/com/vaadin/ui/LegacyWindow.java
+++ b/server/src/main/java/com/vaadin/ui/LegacyWindow.java
@@ -329,7 +329,7 @@ public class LegacyWindow extends UI {
*/
@Deprecated
public void addListener(BrowserWindowResizeListener resizeListener) {
- getPage().addListener(resizeListener);
+ getPage().addBrowserWindowResizeListener(resizeListener);
}
/**
@@ -342,7 +342,7 @@ public class LegacyWindow extends UI {
*/
@Deprecated
public void removeListener(BrowserWindowResizeListener resizeListener) {
- getPage().removeListener(resizeListener);
+ getPage().removeBrowserWindowResizeListener(resizeListener);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/Panel.java b/server/src/main/java/com/vaadin/ui/Panel.java
index 1f7197a76c..7b1333d898 100644
--- a/server/src/main/java/com/vaadin/ui/Panel.java
+++ b/server/src/main/java/com/vaadin/ui/Panel.java
@@ -31,6 +31,7 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.server.Scrollable;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.panel.PanelServerRpc;
import com.vaadin.shared.ui.panel.PanelState;
import com.vaadin.ui.Component.Focusable;
@@ -268,23 +269,17 @@ public class Panel extends AbstractSingleComponentContainer
* inside the Panel, provided the targeted component does not prevent the
* click event from propagating.
*
- * Use {@link #removeListener(ClickListener)} to remove the listener.
+ * @see Registration
*
* @param listener
- * The listener to add
+ * The listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addClickListener(ClickListener listener) {
+ public Registration addClickListener(ClickListener listener) {
addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
ClickListener.clickMethod);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addClickListener(ClickListener)}
- **/
- @Deprecated
- public void addListener(ClickListener listener) {
- addClickListener(listener);
+ return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
+ ClickEvent.class, listener);
}
/**
@@ -293,22 +288,17 @@ public class Panel 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 #addClickListener(ClickListener)}.
*/
+ @Deprecated
public void removeClickListener(ClickListener listener) {
removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
listener);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeClickListener(ClickListener)}
- **/
- @Deprecated
- public void removeListener(ClickListener listener) {
- removeClickListener(listener);
- }
-
- /**
* {@inheritDoc}
*/
@Override
diff --git a/server/src/main/java/com/vaadin/ui/PopupView.java b/server/src/main/java/com/vaadin/ui/PopupView.java
index ed540f149c..497e052f22 100644
--- a/server/src/main/java/com/vaadin/ui/PopupView.java
+++ b/server/src/main/java/com/vaadin/ui/PopupView.java
@@ -24,6 +24,7 @@ import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.parser.Tag;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.popupview.PopupViewServerRpc;
import com.vaadin.shared.ui.popupview.PopupViewState;
import com.vaadin.ui.declarative.DesignContext;
@@ -334,25 +335,19 @@ public class PopupView extends AbstractComponent implements HasComponents {
* Add a listener that is called whenever the visibility of the popup is
* changed.
*
- * @param listener
- * the listener to add
* @see PopupVisibilityListener
* @see PopupVisibilityEvent
- * @see #removeListener(PopupVisibilityListener)
*
+ * @param listener
+ * the listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addPopupVisibilityListener(PopupVisibilityListener listener) {
+ public Registration addPopupVisibilityListener(
+ PopupVisibilityListener listener) {
addListener(PopupVisibilityEvent.class, listener,
POPUP_VISIBILITY_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addPopupVisibilityListener(PopupVisibilityListener)}
- **/
- @Deprecated
- public void addListener(PopupVisibilityListener listener) {
- addPopupVisibilityListener(listener);
+ return () -> removeListener(PopupVisibilityEvent.class, listener,
+ POPUP_VISIBILITY_METHOD);
}
/**
@@ -363,7 +358,12 @@ public class PopupView extends AbstractComponent implements HasComponents {
* the listener to remove
* @see PopupVisibilityListener
* @see #addListener(PopupVisibilityListener)
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addPopupVisibilityListener(PopupVisibilityListener)}.
*/
+ @Deprecated
public void removePopupVisibilityListener(
PopupVisibilityListener listener) {
removeListener(PopupVisibilityEvent.class, listener,
@@ -371,15 +371,6 @@ public class PopupView extends AbstractComponent implements HasComponents {
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removePopupVisibilityListener(PopupVisibilityListener)}
- **/
- @Deprecated
- public void removeListener(PopupVisibilityListener listener) {
- removePopupVisibilityListener(listener);
- }
-
- /**
* This event is received by the PopupVisibilityListeners when the
* visibility of the popup changes. You can get the new visibility directly
* with {@link #isPopupVisible()}, or get the PopupView that produced the
diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java
index a03b342ba0..79fe6227a1 100644
--- a/server/src/main/java/com/vaadin/ui/TabSheet.java
+++ b/server/src/main/java/com/vaadin/ui/TabSheet.java
@@ -39,6 +39,7 @@ import com.vaadin.server.ErrorMessage;
import com.vaadin.server.KeyMapper;
import com.vaadin.server.Resource;
import com.vaadin.shared.ComponentConstants;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.tabsheet.TabState;
import com.vaadin.shared.ui.tabsheet.TabsheetClientRpc;
import com.vaadin.shared.ui.tabsheet.TabsheetServerRpc;
@@ -843,32 +844,34 @@ public class TabSheet extends AbstractComponentContainer
}
/**
- * Adds a tab selection listener
+ * Adds a tab selection listener.
+ *
+ * @see Registration
*
* @param listener
- * the Listener to be added.
+ * the Listener to be added, not null
+ * @return a registration object for removing the listener
*/
- public void addSelectedTabChangeListener(
+ public Registration addSelectedTabChangeListener(
SelectedTabChangeListener listener) {
addListener(SelectedTabChangeEvent.class, listener,
SELECTED_TAB_CHANGE_METHOD);
+ return () -> removeListener(SelectedTabChangeEvent.class, listener,
+ SELECTED_TAB_CHANGE_METHOD);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #addSelectedTabChangeListener(SelectedTabChangeListener)}
- **/
- @Deprecated
- public void addListener(SelectedTabChangeListener listener) {
- addSelectedTabChangeListener(listener);
- }
-
- /**
- * Removes a tab selection listener
+ * Removes a tab selection listener.
*
* @param listener
* the Listener to be removed.
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #removeSelectedTabChangeListener(SelectedTabChangeListener)}
+ * .
*/
+ @Deprecated
public void removeSelectedTabChangeListener(
SelectedTabChangeListener listener) {
removeListener(SelectedTabChangeEvent.class, listener,
@@ -876,15 +879,6 @@ public class TabSheet extends AbstractComponentContainer
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeSelectedTabChangeListener(SelectedTabChangeListener)}
- **/
- @Deprecated
- public void removeListener(SelectedTabChangeListener listener) {
- removeSelectedTabChangeListener(listener);
- }
-
- /**
* Sends an event that the currently selected tab has changed.
*/
protected void fireSelectedTabChange() {
@@ -1399,23 +1393,29 @@ public class TabSheet extends AbstractComponentContainer
}
@Override
- public void addBlurListener(BlurListener listener) {
+ public Registration addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
+ return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}
@Override
- public void addFocusListener(FocusListener listener) {
+ public Registration addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
+ return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java
index 82bbea7039..34e9177e0c 100644
--- a/server/src/main/java/com/vaadin/ui/UI.java
+++ b/server/src/main/java/com/vaadin/ui/UI.java
@@ -60,6 +60,7 @@ import com.vaadin.server.communication.PushConnection;
import com.vaadin.shared.Connector;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.shared.ui.ui.DebugWindowClientRpc;
import com.vaadin.shared.ui.ui.DebugWindowServerRpc;
@@ -909,23 +910,17 @@ public abstract class UI extends AbstractSingleComponentContainer
* UI, provided the targeted component does not prevent the click event from
* propagating.
*
- * Use {@link #removeListener(ClickListener)} to remove the listener.
+ * @see Registration
*
* @param listener
- * The listener to add
+ * The listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addClickListener(ClickListener listener) {
+ public Registration addClickListener(ClickListener listener) {
addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener,
ClickListener.clickMethod);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addClickListener(ClickListener)}
- **/
- @Deprecated
- public void addListener(ClickListener listener) {
- addClickListener(listener);
+ return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
+ ClickEvent.class, listener);
}
/**
@@ -934,21 +929,17 @@ public abstract class UI 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 #removeClickListener(ClickListener)}.
*/
+ @Deprecated
public void removeClickListener(ClickListener listener) {
removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class,
listener);
}
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeClickListener(ClickListener)}
- **/
- @Deprecated
- public void removeListener(ClickListener listener) {
- removeClickListener(listener);
- }
-
@Override
public boolean isConnectorEnabled() {
// TODO How can a UI be invisible? What does it mean?
@@ -1629,12 +1620,14 @@ public abstract class UI extends AbstractSingleComponentContainer
}
@Override
- public void addPollListener(PollListener listener) {
+ public Registration addPollListener(PollListener listener) {
addListener(EventId.POLL, PollEvent.class, listener,
PollListener.POLL_METHOD);
+ return () -> removeListener(EventId.POLL, PollEvent.class, listener);
}
@Override
+ @Deprecated
public void removePollListener(PollListener listener) {
removeListener(EventId.POLL, PollEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java
index 9077a35b95..5d2d4763e7 100644
--- a/server/src/main/java/com/vaadin/ui/Upload.java
+++ b/server/src/main/java/com/vaadin/ui/Upload.java
@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Objects;
import com.vaadin.server.NoInputStreamException;
import com.vaadin.server.NoOutputStreamException;
@@ -29,6 +30,7 @@ import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.StreamVariable.StreamingProgressEvent;
import com.vaadin.shared.EventId;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.upload.UploadClientRpc;
import com.vaadin.shared.ui.upload.UploadServerRpc;
import com.vaadin.shared.ui.upload.UploadState;
@@ -65,9 +67,9 @@ import com.vaadin.util.ReflectTools;
* button.
*
* <p>
- * Note! Because of browser dependent implementations of <input type="file">
- * element, setting size for Upload component is not supported. For some
- * browsers setting size may work to some extend.
+ * Note! Because of browser dependent implementations of
+ * <input type="file"> element, setting size for Upload component is not
+ * supported. For some browsers setting size may work to some extend.
*
* @author Vaadin Ltd.
* @since 3.0
@@ -627,19 +629,12 @@ public class Upload extends AbstractComponent
* Adds the upload started event listener.
*
* @param listener
- * the Listener to be added.
+ * the Listener to be added, not null
*/
- public void addStartedListener(StartedListener listener) {
+ public Registration addStartedListener(StartedListener listener) {
addListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addStartedListener(StartedListener)}
- **/
- @Deprecated
- public void addListener(StartedListener listener) {
- addStartedListener(listener);
+ return () -> removeListener(StartedEvent.class, listener,
+ UPLOAD_STARTED_METHOD);
}
/**
@@ -648,36 +643,21 @@ public class Upload extends AbstractComponent
* @param listener
* the Listener to be removed.
*/
+ @Deprecated
public void removeStartedListener(StartedListener listener) {
removeListener(StartedEvent.class, listener, UPLOAD_STARTED_METHOD);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeStartedListener(StartedListener)}
- **/
- @Deprecated
- public void removeListener(StartedListener listener) {
- removeStartedListener(listener);
- }
-
- /**
* Adds the upload received event listener.
*
* @param listener
- * the Listener to be added.
+ * the Listener to be added, not null
*/
- public void addFinishedListener(FinishedListener listener) {
+ public Registration addFinishedListener(FinishedListener listener) {
addListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addFinishedListener(FinishedListener)}
- **/
- @Deprecated
- public void addListener(FinishedListener listener) {
- addFinishedListener(listener);
+ return () -> removeListener(FinishedEvent.class, listener,
+ UPLOAD_FINISHED_METHOD);
}
/**
@@ -686,36 +666,21 @@ public class Upload extends AbstractComponent
* @param listener
* the Listener to be removed.
*/
+ @Deprecated
public void removeFinishedListener(FinishedListener listener) {
removeListener(FinishedEvent.class, listener, UPLOAD_FINISHED_METHOD);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeFinishedListener(FinishedListener)}
- **/
- @Deprecated
- public void removeListener(FinishedListener listener) {
- removeFinishedListener(listener);
- }
-
- /**
* Adds the upload interrupted event listener.
*
* @param listener
- * the Listener to be added.
+ * the Listener to be added, not null
*/
- public void addFailedListener(FailedListener listener) {
+ public Registration addFailedListener(FailedListener listener) {
addListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addFailedListener(FailedListener)}
- **/
- @Deprecated
- public void addListener(FailedListener listener) {
- addFailedListener(listener);
+ return () -> removeListener(FailedEvent.class, listener,
+ UPLOAD_FAILED_METHOD);
}
/**
@@ -724,36 +689,21 @@ public class Upload extends AbstractComponent
* @param listener
* the Listener to be removed.
*/
+ @Deprecated
public void removeFailedListener(FailedListener listener) {
removeListener(FailedEvent.class, listener, UPLOAD_FAILED_METHOD);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeFailedListener(FailedListener)}
- **/
- @Deprecated
- public void removeListener(FailedListener listener) {
- removeFailedListener(listener);
- }
-
- /**
* Adds the upload success event listener.
*
* @param listener
- * the Listener to be added.
+ * the Listener to be added, not null
*/
- public void addSucceededListener(SucceededListener listener) {
+ public Registration addSucceededListener(SucceededListener listener) {
addListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addSucceededListener(SucceededListener)}
- **/
- @Deprecated
- public void addListener(SucceededListener listener) {
- addSucceededListener(listener);
+ return () -> removeListener(SucceededEvent.class, listener,
+ UPLOAD_SUCCEEDED_METHOD);
}
/**
@@ -762,39 +712,28 @@ public class Upload extends AbstractComponent
* @param listener
* the Listener to be removed.
*/
+ @Deprecated
public void removeSucceededListener(SucceededListener listener) {
removeListener(SucceededEvent.class, listener, UPLOAD_SUCCEEDED_METHOD);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeSucceededListener(SucceededListener)}
- **/
- @Deprecated
- public void removeListener(SucceededListener listener) {
- removeSucceededListener(listener);
- }
-
- /**
* Adds the upload progress event listener.
*
* @param listener
* the progress listener to be added
*/
- public void addProgressListener(ProgressListener listener) {
+ public Registration addProgressListener(ProgressListener listener) {
+ Objects.requireNonNull(listener, "Listener must not be null.");
if (progressListeners == null) {
progressListeners = new LinkedHashSet<>();
}
progressListeners.add(listener);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addProgressListener(ProgressListener)}
- **/
- @Deprecated
- public void addListener(ProgressListener listener) {
- addProgressListener(listener);
+ return () -> {
+ if (progressListeners != null) {
+ progressListeners.remove(listener);
+ }
+ };
}
/**
@@ -803,6 +742,7 @@ public class Upload extends AbstractComponent
* @param listener
* the progress listener to be removed
*/
+ @Deprecated
public void removeProgressListener(ProgressListener listener) {
if (progressListeners != null) {
progressListeners.remove(listener);
@@ -813,11 +753,13 @@ public class Upload extends AbstractComponent
* Adds a filename change event listener
*
* @param listener
- * the Listener to add
+ * the Listener to add, not null
*/
- public void addChangeListener(ChangeListener listener) {
+ public Registration addChangeListener(ChangeListener listener) {
super.addListener(EventId.CHANGE, ChangeEvent.class, listener,
ChangeListener.FILENAME_CHANGED);
+ return () -> super.removeListener(EventId.CHANGE, ChangeEvent.class,
+ listener);
}
/**
@@ -826,20 +768,12 @@ public class Upload extends AbstractComponent
* @param listener
* the listener to be removed
*/
+ @Deprecated
public void removeChangeListener(ChangeListener listener) {
super.removeListener(EventId.CHANGE, ChangeEvent.class, listener);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeProgressListener(ProgressListener)}
- **/
- @Deprecated
- public void removeListener(ProgressListener listener) {
- removeProgressListener(listener);
- }
-
- /**
* Emit upload received event.
*
* @param filename
diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java
index c0eac75970..82acf0ee6f 100644
--- a/server/src/main/java/com/vaadin/ui/Window.java
+++ b/server/src/main/java/com/vaadin/ui/Window.java
@@ -43,6 +43,7 @@ import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.shared.Connector;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.shared.ui.window.WindowServerRpc;
@@ -106,8 +107,7 @@ public class Window extends Panel
/**
* Holds registered CloseShortcut instances for query and later removal
*/
- private List<CloseShortcut> closeShortcuts = new ArrayList<>(
- 4);
+ private List<CloseShortcut> closeShortcuts = new ArrayList<>(4);
/**
* Creates a new, empty window
@@ -406,19 +406,12 @@ public class Window extends Panel
* </p>
*
* @param listener
- * the CloseListener to add.
+ * the CloseListener to add, not null
*/
- public void addCloseListener(CloseListener listener) {
+ public Registration addCloseListener(CloseListener listener) {
addListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addCloseListener(CloseListener)}
- **/
- @Deprecated
- public void addListener(CloseListener listener) {
- addCloseListener(listener);
+ return () -> removeListener(CloseEvent.class, listener,
+ WINDOW_CLOSE_METHOD);
}
/**
@@ -431,19 +424,11 @@ public class Window extends Panel
* @param listener
* the CloseListener to remove.
*/
+ @Deprecated
public void removeCloseListener(CloseListener listener) {
removeListener(CloseEvent.class, listener, WINDOW_CLOSE_METHOD);
}
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #removeCloseListener(CloseListener)}
- **/
- @Deprecated
- public void removeListener(CloseListener listener) {
- removeCloseListener(listener);
- }
-
protected void fireClose() {
fireEvent(new Window.CloseEvent(this));
}
@@ -523,9 +508,12 @@ public class Window extends Panel
* @param listener
* the WindowModeChangeListener to add.
*/
- public void addWindowModeChangeListener(WindowModeChangeListener listener) {
+ public Registration addWindowModeChangeListener(
+ WindowModeChangeListener listener) {
addListener(WindowModeChangeEvent.class, listener,
WindowModeChangeListener.windowModeChangeMethod);
+ return () -> removeListener(WindowModeChangeEvent.class, listener,
+ WindowModeChangeListener.windowModeChangeMethod);
}
/**
@@ -534,6 +522,7 @@ public class Window extends Panel
* @param listener
* the WindowModeChangeListener to remove.
*/
+ @Deprecated
public void removeWindowModeChangeListener(
WindowModeChangeListener listener) {
removeListener(WindowModeChangeEvent.class, listener,
@@ -597,19 +586,15 @@ public class Window extends Panel
/**
* Add a resize listener.
*
+ * @see Registration
+ *
* @param listener
+ * the listener to add, not null
+ * @return a registration object for removing the listener
*/
- public void addResizeListener(ResizeListener listener) {
+ public Registration addResizeListener(ResizeListener listener) {
addListener(ResizeEvent.class, listener, WINDOW_RESIZE_METHOD);
- }
-
- /**
- * @deprecated As of 7.0, replaced by
- * {@link #addResizeListener(ResizeListener)}
- **/
- @Deprecated
- public void addListener(ResizeListener listener) {
- addResizeListener(listener);
+ return () -> removeListener(ResizeEvent.class, listener);
}
/**
@@ -617,20 +602,12 @@ public class Window extends Panel
*
* @param listener
*/
+ @Deprecated
public void removeResizeListener(ResizeListener listener) {
removeListener(ResizeEvent.class, listener);
}
/**
- * @deprecated As of 7.0, replaced by
- * {@link #removeResizeListener(ResizeListener)}
- **/
- @Deprecated
- public void removeListener(ResizeListener listener) {
- removeResizeListener(listener);
- }
-
- /**
* Fire the resize event.
*/
protected void fireResize() {
@@ -1085,12 +1062,15 @@ public class Window extends Panel
* .event.FieldEvents.FocusListener)
*/
@Override
- public void addFocusListener(FocusListener listener) {
+ public Registration addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
+ return () -> removeListener(FocusEvent.EVENT_ID, FocusEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}
@@ -1103,12 +1083,15 @@ public class Window extends Panel
* event.FieldEvents.BlurListener)
*/
@Override
- public void addBlurListener(BlurListener listener) {
+ public Registration addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
+ return () -> removeListener(BlurEvent.EVENT_ID, BlurEvent.class,
+ listener);
}
@Override
+ @Deprecated
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
index cbb1ba9795..77b939e8b4 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
@@ -17,11 +17,12 @@ package com.vaadin.ui.components.colorpicker;
import java.lang.reflect.Method;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerGradientServerRpc;
import com.vaadin.shared.ui.colorpicker.ColorPickerGradientState;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
+import com.vaadin.ui.AbstractComponent;
/**
* A component that represents a color gradient within a color picker.
@@ -103,11 +104,13 @@ public class ColorPickerGradient extends AbstractComponent
}
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
+ public Registration addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
+ return () -> removeListener(ColorChangeEvent.class, listener);
}
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
removeListener(ColorChangeEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
index 9e5580c719..544d6c9c9e 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerGridServerRpc;
import com.vaadin.shared.ui.colorpicker.ColorPickerGridState;
@@ -182,15 +183,10 @@ public class ColorPickerGrid extends AbstractComponent
markAsDirty();
}
- /**
- * Adds a color change listener
- *
- * @param listener
- * The color change listener
- */
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
+ public Registration addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
+ return () -> removeListener(ColorChangeEvent.class, listener);
}
@Override
@@ -198,13 +194,8 @@ public class ColorPickerGrid extends AbstractComponent
return colorGrid[x][y];
}
- /**
- * Removes a color change listener
- *
- * @param listener
- * The listener
- */
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
removeListener(ColorChangeEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
index 1173faf152..de0b1f4c52 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.ui.CustomComponent;
@@ -188,24 +189,14 @@ public class ColorPickerHistory extends CustomComponent
return getColorHistory().contains(c);
}
- /**
- * Adds a color change listener
- *
- * @param listener
- * The listener
- */
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
+ public Registration addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
+ return () -> removeListener(ColorChangeEvent.class, listener);
}
- /**
- * Removes a color change listener
- *
- * @param listener
- * The listener
- */
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
removeListener(ColorChangeEvent.class, listener);
}
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 8876e4809d..59c7033775 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
@@ -25,8 +25,10 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.colorpicker.Color;
+import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -39,7 +41,6 @@ import com.vaadin.ui.Slider.ValueOutOfBoundsException;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
-import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
/**
* A component that represents color selection popup within a color picker.
@@ -569,11 +570,13 @@ public class ColorPickerPopup extends Window
}
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
+ public Registration addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
+ return () -> removeListener(ColorChangeEvent.class, listener);
}
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
removeListener(ColorChangeEvent.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 e7d9395e06..c747002bde 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,11 +112,13 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector {
}
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
+ public Registration addColorChangeListener(ColorChangeListener listener) {
addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD);
+ return () -> removeListener(ColorChangeEvent.class, listener);
}
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
removeListener(ColorChangeEvent.class, listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
index ac0da15fc5..fd37d3345a 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
@@ -18,6 +18,7 @@ package com.vaadin.ui.components.colorpicker;
import java.util.EnumSet;
import com.vaadin.data.HasValue.ValueChange;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
@@ -200,11 +201,12 @@ public class ColorPickerSelect extends CustomComponent
}
@Override
- public void addColorChangeListener(ColorChangeListener listener) {
- grid.addColorChangeListener(listener);
+ public Registration addColorChangeListener(ColorChangeListener listener) {
+ return grid.addColorChangeListener(listener);
}
@Override
+ @Deprecated
public void removeColorChangeListener(ColorChangeListener listener) {
grid.removeColorChangeListener(listener);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
index 7980111e2b..505365ec63 100644
--- a/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
@@ -17,20 +17,32 @@ package com.vaadin.ui.components.colorpicker;
import java.io.Serializable;
+import com.vaadin.shared.Registration;
+
public interface HasColorChangeListener extends Serializable {
/**
* Adds a {@link ColorChangeListener} to the component.
*
+ * @see Registration
+ *
* @param listener
+ * the listener to add, not null
+ * @return a registration object for removing the listener
*/
- void addColorChangeListener(ColorChangeListener listener);
+ Registration addColorChangeListener(ColorChangeListener listener);
/**
* Removes a {@link ColorChangeListener} from the component.
*
* @param listener
+ * the listener to remove
+ *
+ * @deprecated As of 8.0, replaced by {@link Registration#remove()} in the
+ * registration object returned from
+ * {@link #addColorChangeListener(ColorChangeListener)}.
*/
+ @Deprecated
void removeColorChangeListener(ColorChangeListener listener);
}
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 2617827b77..87cdae84af 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.grid.renderers.RendererClickRpc;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
@@ -38,8 +39,7 @@ import com.vaadin.util.ReflectTools;
* @since 7.4
* @author Vaadin Ltd
*/
-public abstract class ClickableRenderer<T, V>
- extends AbstractRenderer<T, V> {
+public abstract class ClickableRenderer<T, V> extends AbstractRenderer<T, V> {
/**
* An interface for listening to {@link RendererClickEvent renderer click
@@ -147,11 +147,12 @@ public abstract class ClickableRenderer<T, V>
* every time one of the buttons rendered by this renderer is clicked.
*
* @param listener
- * the click listener to be added
+ * the click listener to be added, not null
*/
- public void addClickListener(RendererClickListener<T> listener) {
+ public Registration addClickListener(RendererClickListener<T> listener) {
addListener(RendererClickEvent.class, listener,
RendererClickListener.CLICK_METHOD);
+ return () -> removeListener(RendererClickEvent.class, listener);
}
/**
@@ -160,6 +161,7 @@ public abstract class ClickableRenderer<T, V>
* @param listener
* the click listener to be removed
*/
+ @Deprecated
public void removeClickListener(RendererClickListener<T> listener) {
removeListener(RendererClickEvent.class, listener);
}
diff --git a/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java b/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java
new file mode 100644
index 0000000000..3ca5092ac5
--- /dev/null
+++ b/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java
@@ -0,0 +1,29 @@
+package com.vaadin.server;
+
+import java.lang.reflect.Method;
+import java.util.regex.Pattern;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.VaadinClasses;
+
+public class RemoveListenersDeprecatedTest {
+
+ @Test
+ public void allRemoveListenerMethodsMarkedAsDeprecated() {
+ Pattern methodPattern = Pattern.compile("remove.*Listener");
+ for (Class<? extends Object> serverClass : VaadinClasses
+ .getComponents()) {
+ for (Method method : serverClass.getMethods()) {
+ if (methodPattern.matcher(method.getName()).matches()) {
+ Assert.assertNotNull(
+ "Method " + method.getName() + " in class "
+ + serverClass.getSimpleName()
+ + " has not been marked as deprecated.",
+ method.getAnnotation(Deprecated.class));
+ }
+ }
+ }
+ }
+}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
index 8f1c54ff6f..2203635430 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
@@ -9,6 +9,7 @@ import java.util.Set;
import org.easymock.EasyMock;
import org.junit.Assert;
+import com.vaadin.shared.Registration;
import com.vaadin.tests.VaadinClasses;
import com.vaadin.ui.Component;
@@ -99,11 +100,13 @@ public abstract class AbstractListenerMethodsTestBase {
verifyListeners(c, eventClass);
// Add one listener and verify
- addListener(c, mockListener1, listenerClass);
+ Registration listener1Registration = addListener(c, mockListener1,
+ listenerClass);
verifyListeners(c, eventClass, mockListener1);
// Add another listener and verify
- addListener(c, mockListener2, listenerClass);
+ Registration listener2Registration = addListener(c, mockListener2,
+ listenerClass);
verifyListeners(c, eventClass, mockListener1, mockListener2);
// Ensure we can fetch using parent class also
@@ -113,30 +116,21 @@ public abstract class AbstractListenerMethodsTestBase {
}
// Remove the first and verify
- removeListener(c, mockListener1, listenerClass);
+ listener1Registration.remove();
verifyListeners(c, eventClass, mockListener2);
// Remove the remaining and verify
- removeListener(c, mockListener2, listenerClass);
+ listener2Registration.remove();
verifyListeners(c, eventClass);
}
- private void removeListener(Object c, Object listener,
+ private Registration addListener(Object c, Object listener1,
Class<?> listenerClass) throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException,
SecurityException, NoSuchMethodException {
- Method method = getRemoveListenerMethod(c.getClass(), listenerClass);
- method.invoke(c, listener);
-
- }
-
- private void addListener(Object c, Object listener1, Class<?> listenerClass)
- throws IllegalArgumentException, IllegalAccessException,
- InvocationTargetException, SecurityException,
- NoSuchMethodException {
Method method = getAddListenerMethod(c.getClass(), listenerClass);
- method.invoke(c, listener1);
+ return (Registration) method.invoke(c, listener1);
}
private Collection<?> getListeners(Object c, Class<?> eventType)
@@ -154,16 +148,14 @@ public abstract class AbstractListenerMethodsTestBase {
private Method getAddListenerMethod(Class<?> cls, Class<?> listenerClass)
throws SecurityException, NoSuchMethodException {
- return cls.getMethod("add" + listenerClass.getSimpleName(),
- listenerClass);
-
- }
-
- private Method getRemoveListenerMethod(Class<?> cls, Class<?> listenerClass)
- throws SecurityException, NoSuchMethodException {
- return cls.getMethod("remove" + listenerClass.getSimpleName(),
- listenerClass);
-
+ Method addListenerMethod = cls.getMethod(
+ "add" + listenerClass.getSimpleName(), listenerClass);
+ if (addListenerMethod.getReturnType() != Registration.class) {
+ throw new NoSuchMethodException(
+ cls.getSimpleName() + ".add" + listenerClass.getSimpleName()
+ + " has wrong return type, expected Registration");
+ }
+ return addListenerMethod;
}
private void verifyListeners(Object c, Class<?> eventClass,
diff --git a/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java b/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java
index a38ba9b0f9..52e367abf2 100644
--- a/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/components/WindowTest.java
@@ -7,6 +7,7 @@ import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
+import com.vaadin.shared.Registration;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Window;
import com.vaadin.ui.Window.CloseEvent;
@@ -35,7 +36,8 @@ public class WindowTest {
EasyMock.replay(cl);
// Add listener and send a close event -> should end up in listener once
- window.addListener(cl);
+ Registration windowCloseListenerRegistration = window
+ .addCloseListener(cl);
sendClose(window);
// Ensure listener was called once
@@ -43,7 +45,7 @@ public class WindowTest {
// Remove the listener and send close event -> should not end up in
// listener
- window.removeListener(cl);
+ windowCloseListenerRegistration.remove();
sendClose(window);
// Ensure listener still has been called only once
@@ -63,7 +65,8 @@ public class WindowTest {
// Add listener and send a resize event -> should end up in listener
// once
- window.addListener(rl);
+ Registration windowResizeListenerRegistration = window
+ .addResizeListener(rl);
sendResize(window);
// Ensure listener was called once
@@ -71,7 +74,7 @@ public class WindowTest {
// Remove the listener and send close event -> should not end up in
// listener
- window.removeListener(rl);
+ windowResizeListenerRegistration.remove();
sendResize(window);
// Ensure listener still has been called only once
diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java
index c7bb725cc9..7b160106d8 100644
--- a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java
@@ -41,6 +41,7 @@ import com.vaadin.navigator.ViewProvider;
import com.vaadin.server.Page;
import com.vaadin.server.Page.UriFragmentChangedEvent;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.Registration;
import com.vaadin.tests.server.navigator.ClassBasedViewProviderTest.TestView;
import com.vaadin.tests.server.navigator.ClassBasedViewProviderTest.TestView2;
import com.vaadin.ui.Component;
@@ -226,9 +227,10 @@ public class NavigatorTest {
}
@Override
- public void addUriFragmentChangedListener(
+ public Registration addUriFragmentChangedListener(
UriFragmentChangedListener listener) {
addUriFragmentCalled = true;
+ return () -> removeUriFragmentCalled = true;
}
@Override
diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
index 9fb52351f8..6c7a3cf0d8 100644
--- a/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
@@ -25,6 +25,7 @@ import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.Navigator.UriFragmentManager;
import com.vaadin.server.Page;
import com.vaadin.server.Page.UriFragmentChangedEvent;
+import com.vaadin.shared.Registration;
public class UriFragmentManagerTest {
@@ -49,12 +50,13 @@ public class UriFragmentManagerTest {
@Test
public void testListener() {
// create mocks
- IMocksControl control = EasyMock.createControl();
+ IMocksControl control = EasyMock.createNiceControl();
Navigator navigator = control.createMock(Navigator.class);
Page page = control.createMock(Page.class);
UriFragmentManager manager = new UriFragmentManager(page);
manager.setNavigator(navigator);
+ control.resetToNice();
EasyMock.expect(page.getUriFragment()).andReturn("!test");
navigator.navigateTo("test");
@@ -100,9 +102,10 @@ public class UriFragmentManagerTest {
}
@Override
- public void addUriFragmentChangedListener(
+ public Registration addUriFragmentChangedListener(
UriFragmentChangedListener listener) {
addUriFragmentCalled = true;
+ return () -> removeUriFragmentCalled = true;
}
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java b/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java
index 0de6a03986..3f86939378 100644
--- a/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java
+++ b/uitest/src/main/java/com/vaadin/tests/FocusingComponents.java
@@ -53,7 +53,7 @@ public class FocusingComponents extends CustomComponent {
}
Button focus = new Button("focus");
- focus.addListener(new Button.ClickListener() {
+ focus.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
f.focus();
diff --git a/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java b/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java
index 3e885f1078..c4fe9a2a65 100644
--- a/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java
+++ b/uitest/src/main/java/com/vaadin/tests/ListenerOrder.java
@@ -47,18 +47,18 @@ public class ListenerOrder extends com.vaadin.server.LegacyApplication
MyClickListener mutualListener = new MyClickListener("mutual1");
addListeners(b1, 1);
- b1.addListener(mutualListener);
- b1.addListener(mutualListener);
- b1.addListener(this);
- b1.addListener(mutualListener);
+ b1.addClickListener(mutualListener);
+ b1.addClickListener(mutualListener);
+ b1.addClickListener(this);
+ b1.addClickListener(mutualListener);
Button.ClickListener b1Listener = addListeners(b1, 3);
- b1.addListener(mutualListener);
- b1.addListener(this);
+ b1.addClickListener(mutualListener);
+ b1.addClickListener(this);
// b1.addListener((ValueChangeListener) this);
- b1.addListener(mutualListener);
- b1.removeListener(b1Listener);
+ b1.addClickListener(mutualListener);
+ b1.removeClickListener(b1Listener);
// remove non-existing listener
- b1.removeListener(new Button.ClickListener() {
+ b1.removeClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
}
@@ -103,7 +103,7 @@ public class ListenerOrder extends com.vaadin.server.LegacyApplication
Button.ClickListener listener = null;
for (int i = 0; i < count; i++) {
listener = new MyClickListener(name);
- b.addListener(listener);
+ b.addClickListener(listener);
}
// return last listener added
return listener;
diff --git a/uitest/src/main/java/com/vaadin/tests/ModalWindow.java b/uitest/src/main/java/com/vaadin/tests/ModalWindow.java
index b366e2d01b..91946fad4a 100644
--- a/uitest/src/main/java/com/vaadin/tests/ModalWindow.java
+++ b/uitest/src/main/java/com/vaadin/tests/ModalWindow.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -56,12 +56,12 @@ public class ModalWindow extends com.vaadin.server.LegacyApplication
// Main window button
final Button b = new Button("Test Button in main window");
- b.addListener(this);
+ b.addClickListener(this);
b.setTabIndex(2);
main.addComponent(b);
reopen = new Button("Open modal subwindow");
- reopen.addListener(this);
+ reopen.addClickListener(this);
reopen.setTabIndex(3);
main.addComponent(reopen);
@@ -95,7 +95,7 @@ public class ModalWindow extends com.vaadin.server.LegacyApplication
// Modal window button
final Button b = new Button("Test Button in modal window");
b.setTabIndex(5);
- b.addListener(this);
+ b.addClickListener(this);
layout.addComponent(b);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java b/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java
index 0dbe05fdee..d878c19aa8 100644
--- a/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java
+++ b/uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -71,7 +71,7 @@ public class OrderedLayoutSwapComponents extends CustomComponent {
ol.setId(name.replaceAll(" ", ""));
ol.addComponent(new Label(name));
up = new Button("up");
- up.addListener(new Button.ClickListener() {
+ up.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
int newIndex = order.indexOf(MyComponent.this) - 1;
@@ -89,7 +89,7 @@ public class OrderedLayoutSwapComponents extends CustomComponent {
ol.addComponent(up);
down = new Button("down");
- down.addListener(new Button.ClickListener() {
+ down.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
int newIndex = order.indexOf(MyComponent.this) + 1;
diff --git a/uitest/src/main/java/com/vaadin/tests/TestBench.java b/uitest/src/main/java/com/vaadin/tests/TestBench.java
index 2f77086ed7..d66f58e539 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestBench.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestBench.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -133,80 +133,83 @@ public class TestBench extends com.vaadin.server.LegacyApplication
VerticalLayout lo = new VerticalLayout();
lo.addComponent(menu);
- mainWindow.getPage().addListener(new Page.UriFragmentChangedListener() {
- @Override
- public void uriFragmentChanged(UriFragmentChangedEvent source) {
- String fragment = source.getUriFragment();
- if (fragment != null && !"".equals(fragment)) {
- // try to find a proper test class
-
- // exact match
- Iterator<?> iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class<?> c = (Class<?>) next;
- String string = c.getName();
- if (string.equals(fragment)) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
+ mainWindow.getPage().addUriFragmentChangedListener(
+ new Page.UriFragmentChangedListener() {
+ @Override
+ public void uriFragmentChanged(
+ UriFragmentChangedEvent source) {
+ String fragment = source.getUriFragment();
+ if (fragment != null && !"".equals(fragment)) {
+ // try to find a proper test class
+
+ // exact match
+ Iterator<?> iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class<?> c = (Class<?>) next;
+ String string = c.getName();
+ if (string.equals(fragment)) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
}
- }
- }
- // simple name match
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class<?> c = (Class<?>) next;
- String string = c.getSimpleName();
- if (string.equals(fragment)) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
+ // simple name match
+ iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class<?> c = (Class<?>) next;
+ String string = c.getSimpleName();
+ if (string.equals(fragment)) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
}
- }
- }
- // ticket match
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class<?> c = (Class<?>) next;
- String string = c.getSimpleName();
- if (string.startsWith("Ticket" + fragment)) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
+ // ticket match
+ iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class<?> c = (Class<?>) next;
+ String string = c.getSimpleName();
+ if (string
+ .startsWith("Ticket" + fragment)) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
}
- }
- }
- // just partly mach lowercase
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class<?> c = (Class<?>) next;
- String string = c.getSimpleName();
- if (string.toLowerCase()
- .contains(fragment.toLowerCase())) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
+ // just partly mach lowercase
+ iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class<?> c = (Class<?>) next;
+ String string = c.getSimpleName();
+ if (string.toLowerCase()
+ .contains(fragment.toLowerCase())) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
}
- }
- }
- getMainWindow().showNotification(
- "No potential matc for #" + fragment);
+ getMainWindow().showNotification(
+ "No potential matc for #" + fragment);
- }
+ }
- }
- });
+ }
+ });
mainLayout.addComponent(lo);
diff --git a/uitest/src/main/java/com/vaadin/tests/TestDateField.java b/uitest/src/main/java/com/vaadin/tests/TestDateField.java
index 7a63c628b4..c3d96a6214 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestDateField.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestDateField.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -85,5 +85,4 @@ public class TestDateField extends CustomComponent {
df.setIcon(res);
super.attach();
}
-
}
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java b/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java
index 10c3328e89..707aa51d6f 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -72,7 +72,7 @@ public class TestForContainerFilterable extends CustomComponent {
t.setContainerDataSource(ic);
// Handler
- filterButton.addListener(new Button.ClickListener() {
+ filterButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
ic.removeAllContainerFilters();
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java b/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
index 3f53686071..7344d05403 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -40,7 +40,6 @@ import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.FailedEvent;
import com.vaadin.ui.Upload.FailedListener;
import com.vaadin.ui.Upload.FinishedEvent;
-import com.vaadin.ui.Upload.FinishedListener;
import com.vaadin.ui.Upload.StartedEvent;
import com.vaadin.ui.Upload.StartedListener;
import com.vaadin.ui.Upload.SucceededEvent;
@@ -76,12 +75,12 @@ public class TestForStyledUpload extends LegacyApplication
up = new Upload(null, buffer);
up.setButtonCaption("Select file");
up.setImmediate(true);
- up.addListener((FinishedListener) this);
- up.addListener((FailedListener) this);
- up.addListener((SucceededListener) this);
- up.addListener((StartedListener) this);
+ up.addFinishedListener(this);
+ up.addFailedListener(this);
+ up.addSucceededListener(this);
+ up.addStartedListener(this);
- up.addListener(new Upload.ProgressListener() {
+ up.addProgressListener(new Upload.ProgressListener() {
@Override
public void updateProgress(long readBytes, long contentLenght) {
@@ -128,7 +127,7 @@ public class TestForStyledUpload extends LegacyApplication
main.addComponent(status);
Button cancel = new Button("Cancel current upload");
- cancel.addListener(new Button.ClickListener() {
+ cancel.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
buffer.cancel();
@@ -138,7 +137,7 @@ public class TestForStyledUpload extends LegacyApplication
main.addComponent(cancel);
final Button restart = new Button("Restart demo application");
- restart.addListener(new Button.ClickListener() {
+ restart.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForTabSheet.java b/uitest/src/main/java/com/vaadin/tests/TestForTabSheet.java
index 4dfa1b96a6..dc37ee0f6d 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForTabSheet.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForTabSheet.java
@@ -17,10 +17,10 @@ public class TestForTabSheet extends CustomComponent
TestForTabSheet() {
setCompositionRoot(tabsheet);
- tabsheet.addListener(this);
+ tabsheet.addSelectedTabChangeListener(this);
/* Listen for button click events. */
- tab1_root.addListener(this);
+ tab1_root.addClickListener(this);
tabsheet.addTab(tab1_root, "First Tab", null);
/* A tab that is initially disabled. */
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForUpload.java b/uitest/src/main/java/com/vaadin/tests/TestForUpload.java
index 5014dcfac4..e5cc82374d 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForUpload.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForUpload.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -116,7 +116,7 @@ public class TestForUpload extends CustomComponent
}
});
- up.addListener(new StartedListener() {
+ up.addStartedListener(new StartedListener() {
private static final long serialVersionUID = 5508883803861085154L;
@Override
@@ -130,7 +130,7 @@ public class TestForUpload extends CustomComponent
}
});
- up.addListener(new Upload.FinishedListener() {
+ up.addFinishedListener(new Upload.FinishedListener() {
private static final long serialVersionUID = -3773034195991947371L;
@Override
@@ -174,7 +174,7 @@ public class TestForUpload extends CustomComponent
}
});
- up.addListener(new Upload.ProgressListener() {
+ up.addProgressListener(new Upload.ProgressListener() {
@Override
public void updateProgress(long readBytes, long contentLenght) {
@@ -205,7 +205,7 @@ public class TestForUpload extends CustomComponent
main.addComponent(beSluggish);
main.addComponent(throwExecption);
main.addComponent(interrupt);
- interrupt.addListener(new Button.ClickListener() {
+ interrupt.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
up.interruptUpload();
@@ -246,7 +246,7 @@ public class TestForUpload extends CustomComponent
main.addComponent(status);
final Button restart = new Button("R");
- restart.addListener(new Button.ClickListener() {
+ restart.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java b/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java
index c12a70c04d..73e9e887ad 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -62,7 +62,7 @@ public class TestSetVisibleAndCaching
selectPanel(selectedPanel);
- buttonNextPanel.addListener(new ClickListener() {
+ buttonNextPanel.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
selectedPanel++;
diff --git a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
index 6cde8350ed..584a952885 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -69,7 +69,7 @@ public class TestSizeableIncomponents extends LegacyApplication {
select.setWidth("400px");
prev = new Button("<<-|");
- prev.addListener(new Button.ClickListener() {
+ prev.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Object cur = select.getValue();
@@ -85,7 +85,7 @@ public class TestSizeableIncomponents extends LegacyApplication {
}
});
next = new Button("|->>");
- next.addListener(new Button.ClickListener() {
+ next.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Object cur = select.getValue();
diff --git a/uitest/src/main/java/com/vaadin/tests/application/ErrorInUnloadEvent.java b/uitest/src/main/java/com/vaadin/tests/application/ErrorInUnloadEvent.java
index a09c4c845a..891e823336 100644
--- a/uitest/src/main/java/com/vaadin/tests/application/ErrorInUnloadEvent.java
+++ b/uitest/src/main/java/com/vaadin/tests/application/ErrorInUnloadEvent.java
@@ -50,7 +50,7 @@ public class ErrorInUnloadEvent extends AbstractTestCase {
formLayout.addComponent(login);
mainWindow.setContent(formLayout);
- login.addListener(new ClickListener() {
+ login.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
String username = userField.getValue();
@@ -82,7 +82,7 @@ public class ErrorInUnloadEvent extends AbstractTestCase {
title.addStyleName("header-title");
header.addComponent(title);
Button logout = new Button("Logout");
- logout.addListener(new ClickListener() {
+ logout.addClickListener(new ClickListener() {
@Override
public void buttonClick(final ClickEvent event) {
user = null;
diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java
index f50be07af9..c3a8fcbbf5 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java
@@ -7,17 +7,15 @@ import java.util.LinkedHashMap;
import com.vaadin.ui.AbstractComponentContainer;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
-import com.vaadin.ui.HasComponents.ComponentAttachEvent;
+import com.vaadin.ui.DateField;
import com.vaadin.ui.HasComponents.ComponentAttachListener;
-import com.vaadin.ui.HasComponents.ComponentDetachEvent;
import com.vaadin.ui.HasComponents.ComponentDetachListener;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.DateField;
+import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.ui.RichTextArea;
import com.vaadin.v7.ui.Table;
import com.vaadin.v7.ui.TextArea;
import com.vaadin.v7.ui.TextField;
@@ -147,11 +145,11 @@ public abstract class AbstractComponentContainerTest<T extends AbstractComponent
@Override
public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener(
- (ComponentAttachListener) AbstractComponentContainerTest.this);
+ c.addComponentAttachListener(
+ AbstractComponentContainerTest.this);
} else {
- c.removeListener(
- (ComponentAttachListener) AbstractComponentContainerTest.this);
+ c.removeComponentAttachListener(
+ AbstractComponentContainerTest.this);
}
}
};
@@ -161,11 +159,11 @@ public abstract class AbstractComponentContainerTest<T extends AbstractComponent
@Override
public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener(
- (ComponentDetachListener) AbstractComponentContainerTest.this);
+ c.addComponentDetachListener(
+ AbstractComponentContainerTest.this);
} else {
- c.removeListener(
- (ComponentDetachListener) AbstractComponentContainerTest.this);
+ c.removeComponentDetachListener(
+ AbstractComponentContainerTest.this);
}
}
};
diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractOrderedLayoutTest.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
index 0e91dd9109..6cf544f16c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
@@ -15,8 +15,7 @@ public abstract class AbstractOrderedLayoutTest<T extends AbstractOrderedLayout>
@Override
public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener(
- (LayoutClickListener) AbstractOrderedLayoutTest.this);
+ c.addLayoutClickListener(AbstractOrderedLayoutTest.this);
} else {
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java b/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java
index a82044bf57..3a27561284 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java
@@ -15,9 +15,9 @@ import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.OptionGroup;
-import com.vaadin.v7.ui.TextField;
public class FocusAndBlurListeners extends TestBase {
@@ -37,7 +37,6 @@ public class FocusAndBlurListeners extends TestBase {
Label msg = new Label(new Date() + " Blurred "
+ event.getComponent().getCaption());
messages.addComponentAsFirst(msg);
-
}
};
private VerticalLayout messages = new VerticalLayout();
@@ -72,7 +71,7 @@ public class FocusAndBlurListeners extends TestBase {
ogm.setMultiSelect(true);
l.addComponent(ogm);
- btn.addListener(new ClickListener() {
+ btn.addClickListener(new ClickListener() {
private int i;
diff --git a/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java b/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java
index 8f6f98fd89..3b331a23df 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java
@@ -118,7 +118,7 @@ public class TouchScrollables extends TestBase {
final Table table = new Table();
Button button = new Button("Toggle lazyloading");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
if (table.getCacheRate() == 100) {
@@ -133,7 +133,7 @@ public class TouchScrollables extends TestBase {
cssLayout.addComponent(button);
button = new Button("Toggle selectable");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
table.setSelectable(!table.isSelectable());
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonErrorMessage.java b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonErrorMessage.java
index b27f948669..38195a34ed 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonErrorMessage.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonErrorMessage.java
@@ -10,7 +10,7 @@ public class ButtonErrorMessage extends TestBase {
@Override
protected void setup() {
Button b = new Button("Click for error");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
throw new NullPointerException();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonHtml.java b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonHtml.java
index 0b1ab42667..d1ad20922c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonHtml.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonHtml.java
@@ -23,7 +23,7 @@ public class ButtonHtml extends TestBase {
addComponent(b);
final Button swapButton = new Button("<i>Swap button<i>");
- swapButton.addListener(new Button.ClickListener() {
+ swapButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonIOSDragTest.java b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonIOSDragTest.java
index 15e44f177d..d80fd028d2 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonIOSDragTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonIOSDragTest.java
@@ -32,7 +32,7 @@ public class ButtonIOSDragTest extends AbstractTestUI {
final VerticalLayout layout = new VerticalLayout();
Button offset = new Button("Drag me");
- offset.addListener(new ClickListener() {
+ offset.addClickListener(new ClickListener() {
@Override
public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
Notification.show("Button clicked!");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/Buttons2.java b/uitest/src/main/java/com/vaadin/tests/components/button/Buttons2.java
index 4f75dfbfef..df344b1a45 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/button/Buttons2.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/button/Buttons2.java
@@ -24,9 +24,9 @@ public class Buttons2<T extends Button> extends AbstractComponentTest<T>
@Override
public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener((Button.ClickListener) Buttons2.this);
+ c.addClickListener(Buttons2.this);
} else {
- c.removeListener((Button.ClickListener) Buttons2.this);
+ c.removeClickListener(Buttons2.this);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/ShortCutListenerModification.java b/uitest/src/main/java/com/vaadin/tests/components/button/ShortCutListenerModification.java
index 025dfbb9c3..2a3d569671 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/button/ShortCutListenerModification.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/button/ShortCutListenerModification.java
@@ -41,8 +41,8 @@ public class ShortCutListenerModification extends TestBase
Button button1 = new Button("b1 (CTRL-C)");
Button button2 = new Button("b2 (CTRL-V)");
- button1.addListener(this);
- button2.addListener(this);
+ button1.addClickListener(this);
+ button2.addClickListener(this);
button1.setClickShortcut(KeyCode.C, ModifierKey.CTRL);
button2.setClickShortcut(KeyCode.V, ModifierKey.CTRL);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/TooltipForDisabledButton.java b/uitest/src/main/java/com/vaadin/tests/components/button/TooltipForDisabledButton.java
index c1f1846415..b4bafb05a2 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/button/TooltipForDisabledButton.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/button/TooltipForDisabledButton.java
@@ -25,7 +25,7 @@ public class TooltipForDisabledButton extends TestBase {
buttonEnabled.setDescription("Tooltip for enabled");
buttonDisabled.setDescription("Tooltip for disabled");
- buttonDisabled.addListener(new Button.ClickListener() {
+ buttonDisabled.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -34,7 +34,7 @@ public class TooltipForDisabledButton extends TestBase {
});
- buttonEnabled.addListener(new Button.ClickListener() {
+ buttonEnabled.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
index 4938f24241..9ea835aac5 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
@@ -27,7 +27,7 @@ public class ComboBoxCombinedWithEnterShortcut extends TestBase {
Button aButton = new Button("Show Value");
aButton.setClickShortcut(KeyCode.ENTER);
- aButton.addListener(new Button.ClickListener() {
+ aButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
index 40bdf0c7a1..09b84ba882 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
@@ -55,7 +55,7 @@ public class ComboBoxDataSourceChange extends TestBase {
state.addComponent(t);
Button b = new Button("Use ds1");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -71,7 +71,7 @@ public class ComboBoxDataSourceChange extends TestBase {
state.addComponent(t);
b = new Button("Use ds2");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java
index ad70412e9f..93c62db9e5 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java
@@ -29,7 +29,7 @@ public class ComboBoxInPopupView extends TestBase {
final ComboBox cb2 = new ComboBox();
cb2.setWidth("260px");
PopupView pv2 = new PopupView("<u>2. focused (click)</u>", cb2);
- pv2.addListener(new PopupVisibilityListener() {
+ pv2.addPopupVisibilityListener(new PopupVisibilityListener() {
@Override
public void popupVisibilityChange(PopupVisibilityEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSlowInFF.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSlowInFF.java
index baf8f7487b..1a9c197365 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSlowInFF.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSlowInFF.java
@@ -23,7 +23,7 @@ public class ComboBoxSlowInFF extends TestBase {
}
Button fill = new Button("fill it");
- fill.addListener(new Button.ClickListener() {
+ fill.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
t.removeAllItems();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/RemovalOfSelectedIcon.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/RemovalOfSelectedIcon.java
index b8609de3e2..3a3a6bb3ea 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/RemovalOfSelectedIcon.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/RemovalOfSelectedIcon.java
@@ -20,7 +20,7 @@ public class RemovalOfSelectedIcon extends TestBase {
Button btClear = new Button("Clear button");
btClear.setImmediate(true);
- btClear.addListener(new Button.ClickListener() {
+ btClear.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java b/uitest/src/main/java/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
index 2351b02e2a..73080b4d2f 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
@@ -18,7 +18,7 @@ public class CustomComponentSizeUpdate extends TestBase {
cc.setWidth("500px");
cc.setHeight("500px");
- nb.addListener(new ClickListener() {
+ nb.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
index 30a34e4fc4..5e9df766d2 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
@@ -58,7 +58,7 @@ public class DateFieldEmptyValid extends TestBase {
checkEmpty();
Button b = new Button("Clear date");
b.setId("clear");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -70,7 +70,7 @@ public class DateFieldEmptyValid extends TestBase {
b = new Button("Set date to 4.5.1990");
b.setId("set4.5.1990");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
@SuppressWarnings("deprecation")
@@ -82,7 +82,7 @@ public class DateFieldEmptyValid extends TestBase {
addComponent(b);
b = new Button("Set date to 5.6.2000 using a property data source");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
@SuppressWarnings("deprecation")
@@ -99,7 +99,7 @@ public class DateFieldEmptyValid extends TestBase {
b = new Button(
"Set date to 27.8.2005 by changing a new property data source from null, ds attached before value setting.");
b.setId("set-via-ds");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
@SuppressWarnings("deprecation")
@@ -115,7 +115,7 @@ public class DateFieldEmptyValid extends TestBase {
b = new Button("Check value");
b.setId("check-value");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
log.log("Checking state");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
index 339eff6972..84ac1c6106 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
@@ -46,7 +46,7 @@ public class DateFieldReadOnly extends AbstractTestUI {
addComponent(timeField);
Button b = new Button("Switch read-only");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java b/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java
index 3225b0af9a..c581779b92 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java
@@ -17,7 +17,7 @@ public class EmbeddedClickListenerRelativeCoordinates extends TestBase {
xLabel.setId("x");
final Label yLabel = new Label();
yLabel.setId("y");
- e.addListener(new ClickListener() {
+ e.addClickListener(new ClickListener() {
@Override
public void click(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java b/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
index 7632577227..9320e9ef6a 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
@@ -44,7 +44,7 @@ public class EmbeddedImageRefresh extends TestBase {
// The button requests repainting the embedded.
Button button = new Button("refr");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
embedded.markAsDirty();
@@ -52,7 +52,7 @@ public class EmbeddedImageRefresh extends TestBase {
});
addComponent(button);
button = new Button("refr name");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
((StreamResource) embedded.getSource())
@@ -62,7 +62,7 @@ public class EmbeddedImageRefresh extends TestBase {
});
addComponent(button);
button = new Button("200x200");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
embedded.setWidth("200px");
@@ -71,7 +71,7 @@ public class EmbeddedImageRefresh extends TestBase {
});
addComponent(button);
button = new Button("undef");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
embedded.setSizeUndefined();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/gridlayout/InsertRowInMiddle.java b/uitest/src/main/java/com/vaadin/tests/components/gridlayout/InsertRowInMiddle.java
index 78b4a9d417..764464c838 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/gridlayout/InsertRowInMiddle.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/gridlayout/InsertRowInMiddle.java
@@ -30,7 +30,7 @@ public class InsertRowInMiddle extends AbstractTestUI {
final GridLayout layout = new GridLayout(1, 2);
layout.addComponent(new Label("some row"), 0, 0);
Button newRowButton = new Button("Insert Row");
- newRowButton.addListener(new Button.ClickListener() {
+ newRowButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
layout.insertRow(1);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java b/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java
index 82969fdb08..2a20b46911 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java
@@ -27,7 +27,7 @@ public class LabelWrapping extends TestBase {
final Label longLabel = new Label(longString);
Button changeLength = new Button("Change length");
- changeLength.addListener(new Button.ClickListener() {
+ changeLength.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
if (longLabel.getValue().equals(longString)) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java b/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java
index c17fa15612..9fae2490b5 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java
@@ -18,7 +18,7 @@ public class NativeButtonHtml extends TestBase {
addComponent(b);
final NativeButton swapButton = new NativeButton("<i>Swap button<i>");
- swapButton.addListener(new Button.ClickListener() {
+ swapButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java b/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java
index 25bc05c771..f4d0c77428 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java
@@ -16,7 +16,7 @@ public class NotificationsAndModalWindow extends TestBase {
Notification.TYPE_WARNING_MESSAGE);
Button b = new Button("Button");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Window w = new Window("This is a window");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java
index 79dc0a88ef..416e5c8d09 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java
@@ -381,7 +381,7 @@ public class BoxLayoutTest extends AbstractTestUI {
l.addComponent(label);
l.addComponent(new Button("Component 2"));
- l.addListener(new LayoutClickListener() {
+ l.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
if (event.getChildComponent() == null
diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java
index 6179694686..f55db0d0ee 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java
@@ -58,7 +58,7 @@ public class LayoutClickListenerTest extends TestBase {
layout.addComponent(nestedLayout);
// Listen for layout click events
- layout.addListener(new LayoutClickListener() {
+ layout.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
index a18400ce08..f18fb39fda 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
@@ -25,7 +25,7 @@ public class ReplaceComponentNPE extends TestBase {
outer.setMargin(true);
Button changer = new Button("ReplaceComponent");
- changer.addListener(new Button.ClickListener() {
+ changer.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getLayout().replaceComponent(button, outer);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java
index 7cc1d27e43..0e17a1729b 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java
@@ -13,7 +13,7 @@ public class PanelClickListenerRelativeCoordinates extends TestBase {
VerticalLayout panelLayout = new VerticalLayout();
panelLayout.setMargin(true);
Panel panel = new Panel("Panel's caption", panelLayout);
- panel.addListener(new ClickListener() {
+ panel.addClickListener(new ClickListener() {
@Override
public void click(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java
index 15ca0d521e..e4f9eb46f0 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java
@@ -23,7 +23,7 @@ public class PanelShouldNotScroll extends TestBase {
p.setHeight("600px");
pl.addComponent(foo());
addMore = new Button("Add");
- addMore.addListener(new ClickListener() {
+ addMore.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
pl.removeComponent(addMore);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java b/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java
index 97dd15f4b4..d343d9d85e 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java
@@ -21,7 +21,7 @@ public class ComboBoxAddWhileFiltering extends TestBase {
populate(comboBox);
Button b = new Button("add item (^N)");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
addItem(comboBox);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
index 5fa6860c34..0d75f654d2 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
@@ -1,7 +1,6 @@
package com.vaadin.tests.components.splitpanel;
import com.vaadin.server.Sizeable;
-import com.vaadin.server.Sizeable.Unit;
import com.vaadin.tests.components.AbstractComponentContainerTest;
import com.vaadin.ui.AbstractSplitPanel;
import com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent;
@@ -16,11 +15,9 @@ public abstract class AbstractSplitPanelTest<T extends AbstractSplitPanel>
@Override
public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener(
- (SplitterClickListener) AbstractSplitPanelTest.this);
+ c.addSplitterClickListener(AbstractSplitPanelTest.this);
} else {
- c.removeListener(
- (SplitterClickListener) AbstractSplitPanelTest.this);
+ c.removeSplitterClickListener(AbstractSplitPanelTest.this);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
index 3025da57e7..9b86b1f95e 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
@@ -39,7 +39,7 @@ public class SplitPanelExtraScrollbars extends AbstractTestCase
private Button createButton(String height) {
Button b = new NativeButton("A BIG button");
b.setHeight(height);
- b.addListener(this);
+ b.addClickListener(this);
return b;
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java
index 88654b8ffc..e5ebef01fa 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java
@@ -25,12 +25,14 @@ public class SplitPanelReversePosition extends TestBase {
hsplit.setSizeFull();
hsplit.setImmediate(true);
hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, hsplitReversed);
- hsplit.addListener(new HorizontalSplitPanel.SplitterClickListener() {
- @Override
- public void splitterClick(SplitterClickEvent event) {
- getMainWindow().showNotification("Horizontal Splitter Clicked");
- }
- });
+ hsplit.addSplitterClickListener(
+ new HorizontalSplitPanel.SplitterClickListener() {
+ @Override
+ public void splitterClick(SplitterClickEvent event) {
+ getMainWindow().showNotification(
+ "Horizontal Splitter Clicked");
+ }
+ });
TextArea area = new TextArea("");
area.setSizeFull();
@@ -40,7 +42,7 @@ public class SplitPanelReversePosition extends TestBase {
vsplit.setSizeFull();
vsplit.setImmediate(true);
vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, vsplitReversed);
- vsplit.addListener(new SplitterClickListener() {
+ vsplit.addSplitterClickListener(new SplitterClickListener() {
@Override
public void splitterClick(SplitterClickEvent event) {
getMainWindow().showNotification("Vertical Splitter Clicked");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java b/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java
index b73e71bc45..3ec2a430aa 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java
@@ -21,7 +21,7 @@ public class AddNonRenderedRow extends TestBase {
}
Button addrowButton = new Button("Add row");
- addrowButton.addListener(new ClickListener() {
+ addrowButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent pEvent) {
addRow();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java
index 555ba7eaab..0807f7946b 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java
@@ -67,7 +67,7 @@ public class ContainerChangeWithPartlySamePropertyIds extends TestBase {
public TableTestComponent() {
Button switchContainerButton = new Button("switch container");
- switchContainerButton.addListener(new ClickListener() {
+ switchContainerButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
if (testTable.getContainerDataSource() == containerA) {
@@ -80,7 +80,7 @@ public class ContainerChangeWithPartlySamePropertyIds extends TestBase {
this.addComponent(switchContainerButton);
Button clearButton = new Button("clear (click twice)");
- clearButton.addListener(new ClickListener() {
+ clearButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java b/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java
index 0fd201fc9a..c4df124a15 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java
@@ -47,7 +47,7 @@ public class MultiSelectWithRemovedRow extends TestBase {
addComponent(table);
Button showButton = new Button("Show selection");
- showButton.addListener(new Button.ClickListener() {
+ showButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent clickEvent) {
Collection<?> selection = (Collection<?>) table.getValue();
@@ -57,7 +57,7 @@ public class MultiSelectWithRemovedRow extends TestBase {
addComponent(showButton);
Button removeButton = new Button("Remove selection");
- removeButton.addListener(new Button.ClickListener() {
+ removeButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent clickEvent) {
Collection<?> selection = (Collection<?>) table.getValue();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java b/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
index 14ec0e6412..4f5f088a16 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
@@ -45,7 +45,7 @@ public class ScrollDetachSynchronization extends TestBase {
mainLayout.addComponent(firstLayout);
mainLayout.setExpandRatio(firstLayout, 1);
- first.addListener(new Button.ClickListener() {
+ first.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -55,7 +55,7 @@ public class ScrollDetachSynchronization extends TestBase {
}
}
});
- second.addListener(new Button.ClickListener() {
+ second.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java b/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java
index 12f677d60d..439ebf6975 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java
@@ -29,7 +29,7 @@ public class SetCurrentPageFirstItemId extends TestBase {
}
Button addrowButton = new Button("Add row");
- addrowButton.addListener(new ClickListener() {
+ addrowButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent pEvent) {
Object id = addRow();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java
index 185a7e3d67..a559e8f743 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java
@@ -44,7 +44,7 @@ public class TableContextMenuOnField extends TestBase {
VerticalLayout layout = new VerticalLayout();
layout.addComponent(new TextField());
- layout.addListener(new LayoutClickListener() {
+ layout.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
index 6750b152aa..0d39d211d3 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
@@ -25,7 +25,7 @@ public class TableModifcationsWhenScrolledRight extends TestBase {
}
t.addItem(row).getItemProperty("name").setValue("Row" + row);
- btn.addListener(new ClickListener() {
+ btn.addClickListener(new ClickListener() {
Integer row = 2;
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java
index 93bd94b774..abc549e4bd 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java
@@ -64,7 +64,7 @@ public class TableReduceContainerSize extends TestBase {
final Label label = new Label();
addComponent(label);
Button button = new Button("Click");
- button.addListener(new Button.ClickListener() {
+ button.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
@@ -80,7 +80,7 @@ public class TableReduceContainerSize extends TestBase {
});
addComponent(button);
Button button2 = new Button("Filter");
- button2.addListener(new Button.ClickListener() {
+ button2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
try {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java
index c83964a829..0410b23996 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java
@@ -138,7 +138,7 @@ public class TableToggleVisibility extends AbstractTestCase {
setCaption("- " + table.getCaption());
- addListener(new ClickListener() {
+ addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
index 45890ced73..3dd2d0cd0a 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
@@ -48,7 +48,7 @@ public class RemoveTabs extends TestBase {
getLayout().addComponent(tabsheet);
closeCurrent = new Button("Close current tab");
- closeCurrent.addListener(new Button.ClickListener() {
+ closeCurrent.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
closeCurrentTab();
@@ -57,7 +57,7 @@ public class RemoveTabs extends TestBase {
});
closeCurrentWithTab = new Button("Close current tab with Tab");
- closeCurrentWithTab.addListener(new Button.ClickListener() {
+ closeCurrentWithTab.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
closeCurrentTabWithTab();
@@ -66,7 +66,7 @@ public class RemoveTabs extends TestBase {
});
closeFirst = new Button("close first tab");
- closeFirst.addListener(new Button.ClickListener() {
+ closeFirst.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
closeFirstTab();
@@ -75,7 +75,7 @@ public class RemoveTabs extends TestBase {
});
closeLast = new Button("close last tab");
- closeLast.addListener(new Button.ClickListener() {
+ closeLast.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
closeLastTab();
@@ -84,7 +84,7 @@ public class RemoveTabs extends TestBase {
});
reorderTabs = new Button("reorder");
- reorderTabs.addListener(new Button.ClickListener() {
+ reorderTabs.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
reorder();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java
index ece3693bfd..3910b3a4f1 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java
@@ -66,9 +66,9 @@ public class TabSheetTest<T extends TabSheet> extends
@Override
public void execute(T c, Boolean value, Object data) {
if (value) {
- c.addListener((SelectedTabChangeListener) TabSheetTest.this);
+ c.addSelectedTabChangeListener(TabSheetTest.this);
} else {
- c.removeListener((SelectedTabChangeListener) TabSheetTest.this);
+ c.removeSelectedTabChangeListener(TabSheetTest.this);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetNPE.java b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
index 0aa10662fa..9e469ba77c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
@@ -44,7 +44,7 @@ public class TabsheetNPE extends AbstractTestCase implements ClickListener {
layout.addComponent(tabSheet);
Button btn = new Button("Enable and activate tab");
- btn.addListener(this);
+ btn.addClickListener(this);
layout.addComponent(btn);
return layout;
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java
index a588e9c862..3fd15ecdcc 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java
@@ -25,7 +25,7 @@ public class ScrollCursor extends TestBase {
+ "ds\n" + "fds\n" + "fds\nfs");
addComponent(textArea);
Button button = new Button("Scroll");
- button.addListener(new ClickListener() {
+ button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -33,7 +33,7 @@ public class ScrollCursor extends TestBase {
}
});
Button wrap = new Button("Set wrap");
- wrap.addListener(new ClickListener() {
+ wrap.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -42,7 +42,7 @@ public class ScrollCursor extends TestBase {
});
Button toBegin = new Button("To begin");
- toBegin.addListener(new ClickListener() {
+ toBegin.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -51,7 +51,7 @@ public class ScrollCursor extends TestBase {
});
Button toMiddle = new Button("To middle");
- toMiddle.addListener(new ClickListener() {
+ toMiddle.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -60,7 +60,7 @@ public class ScrollCursor extends TestBase {
});
Button toEnd = new Button("To end");
- toEnd.addListener(new ClickListener() {
+ toEnd.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java
index 79239da7e7..9ffc7cce38 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java
@@ -23,7 +23,7 @@ public class TextFieldWithProperty extends TestBase {
Button b = new Button(
"Set BAR to underlaying property (should propagate to UI)");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
op.setValue("BAR");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java
index 58f542ccfb..9967980d16 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java
@@ -95,14 +95,14 @@ public class TextFieldWithPropertyFormatter extends TestBase {
Button b = new Button(
"Sync (typing 12345.6789 and clicking this should format field)");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
}
});
addComponent(b);
b = new Button("Set '12345.6789' to textfield on the server side");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
tf1.setValue("12345.6789");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeContainerChange.java b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeContainerChange.java
index d6167b4bff..be260ef30f 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeContainerChange.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeContainerChange.java
@@ -55,7 +55,7 @@ public class TreeContainerChange extends TestBase {
state.addComponent(t);
Button b = new Button("Use ds1");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
@@ -71,7 +71,7 @@ public class TreeContainerChange extends TestBase {
state.addComponent(t);
b = new Button("Use ds2");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
index 92b14e33c4..a3e73bd40c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
@@ -20,21 +20,21 @@ public class ChangeDataSourcePageLengthZero extends TestBase {
setupContainer(tt, 20);
addComponent(tt);
Button page1 = new Button("Set new data source (20 items)");
- page1.addListener(new Button.ClickListener() {
+ page1.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
setupContainer(tt, 20);
}
});
Button page2 = new Button("Set new data source (10 items)");
- page2.addListener(new Button.ClickListener() {
+ page2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
setupContainer(tt, 10);
}
});
Button addButton = new Button("Add item");
- addButton.addListener(new Button.ClickListener() {
+ addButton.addClickListener(new Button.ClickListener() {
private int i = 1;
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java
index 64a7e34fcc..8e5b30639c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -50,7 +50,7 @@ public class RemoveAllItemsRefresh extends TestBase {
addComponent(treeLayout);
Button cleanUp = new Button("clear");
- cleanUp.addListener(new ClickListener() {
+ cleanUp.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
treeContainer.removeAllItems();
@@ -59,7 +59,7 @@ public class RemoveAllItemsRefresh extends TestBase {
addComponent(cleanUp);
Button refresh = new Button("fill");
- refresh.addListener(new ClickListener() {
+ refresh.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
fill();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java
index 95f215b66b..e3000e8fb7 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java
@@ -23,7 +23,7 @@ public class RowHeightWithoutRows extends TestBase {
Button refresh = new Button("Add two elements");
addComponent(refresh);
- refresh.addListener(new ClickListener() {
+ refresh.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
addTwoElements();
}
@@ -31,7 +31,7 @@ public class RowHeightWithoutRows extends TestBase {
Button reset = new Button("Reset");
addComponent(reset);
- reset.addListener(new ClickListener() {
+ reset.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
container.removeAllItems();
}
@@ -39,7 +39,7 @@ public class RowHeightWithoutRows extends TestBase {
Button refresh5 = new Button("Add five elements");
addComponent(refresh5);
- refresh5.addListener(new ClickListener() {
+ refresh5.addClickListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
container.addBean(new User("John", "Doe"));
container.addBean(new User("Mark", "Twain"));
diff --git a/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java b/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java
index bcad8589d6..55b93c609f 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java
@@ -17,12 +17,14 @@ public class UriFragment extends AbstractTestUI {
fragmentLabel.setId("fragmentLabel");
addComponent(fragmentLabel);
updateLabel();
- getPage().addListener(new Page.UriFragmentChangedListener() {
- @Override
- public void uriFragmentChanged(UriFragmentChangedEvent event) {
- updateLabel();
- }
- });
+ getPage().addUriFragmentChangedListener(
+ new Page.UriFragmentChangedListener() {
+ @Override
+ public void uriFragmentChanged(
+ UriFragmentChangedEvent event) {
+ updateLabel();
+ }
+ });
addComponent(createButton("test", "Navigate to #test", "test"));
addComponent(createButton("empty", "Navigate to #", ""));
diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java b/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java
index 671e46e4d7..4b0b8e99c3 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java
@@ -40,7 +40,7 @@ public class ForceSubmit extends TestBase implements Receiver {
addComponent(u);
- u.addListener(new Upload.FinishedListener() {
+ u.addFinishedListener(new Upload.FinishedListener() {
@Override
public void uploadFinished(FinishedEvent event) {
String filename = event.getFilename();
@@ -50,14 +50,14 @@ public class ForceSubmit extends TestBase implements Receiver {
}
});
- u.addListener(new Upload.FailedListener() {
+ u.addFailedListener(new Upload.FailedListener() {
@Override
public void uploadFailed(FailedEvent event) {
getMainWindow().showNotification("Failed. No file selected?");
}
});
- u.addListener(new Upload.StartedListener() {
+ u.addStartedListener(new Upload.StartedListener() {
@Override
public void uploadStarted(StartedEvent event) {
getMainWindow().showNotification(
@@ -67,7 +67,7 @@ public class ForceSubmit extends TestBase implements Receiver {
Button button = new Button(
"I'm an external button (not the uploads builtin), hit me to start upload.");
- button.addListener(new ClickListener() {
+ button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
u.submitUpload();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java
index de0cca5009..41f4f31588 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java
@@ -22,7 +22,7 @@ public class TestUploadFilename extends TestBase {
addComponent(upload);
addComponent(result);
- upload.addListener(new Upload.FinishedListener() {
+ upload.addFinishedListener(new Upload.FinishedListener() {
@Override
public void uploadFinished(FinishedEvent event) {
result.setValue("Got file (should not contain path): "
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
index 455fb2e531..bd0cb109b0 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
@@ -89,7 +89,7 @@ public class AttachShouldBeCalledForSubWindows extends AbstractTestCase {
log(this);
}
};
- okButton.addListener(new ClickListener() {
+ okButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java b/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java
index 8184d10d85..1a54c399d8 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java
@@ -27,7 +27,7 @@ public class ExecuteJavaScript extends AbstractTestCase {
private Button createScriptButton(final String script) {
Button b = new Button(script);
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java b/uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java
index 70d83a466b..cf9eb1b9eb 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java
@@ -70,10 +70,10 @@ public class LazyWindowResize extends AbstractTestCase {
resizeListenerCheckBox.setImmediate(true);
resizeListenerCheckBox.addValueChangeListener(event -> {
if (resizeListenerCheckBox.getValue()) {
- subWindow.addListener(resizeListener);
+ subWindow.addResizeListener(resizeListener);
mainWindow.addListener(browserWindowResizeListener);
} else {
- subWindow.removeListener(resizeListener);
+ subWindow.removeResizeListener(resizeListener);
mainWindow.removeListener(browserWindowResizeListener);
}
});
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowOrder.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowOrder.java
index f4dae2aa75..6b92a4b1eb 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowOrder.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowOrder.java
@@ -63,8 +63,8 @@ public class SubWindowOrder extends TestBase {
addComponent(winSel);
addComponent(bf);
addComponent(toggleModality);
- bf.addListener(this);
- toggleModality.addListener(this);
+ bf.addClickListener(this);
+ toggleModality.addClickListener(this);
}
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
index 8b705a418b..8ef94a2465 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
@@ -40,22 +40,23 @@ public class SubWindowWithUndefinedHeight extends TestBase {
final TabSheet tabsheet = new TabSheet();
tabsheet.addComponent(tabButton);
tabsheet.addComponent(table);
- tabsheet.addListener(new TabSheet.SelectedTabChangeListener() {
- @Override
- public void selectedTabChange(
- TabSheet.SelectedTabChangeEvent event) {
- if (tabsheet.getSelectedTab() == tabButton) {
- tabsheet.setSizeUndefined();
- layout.setSizeUndefined();
- subwindow.setSizeUndefined();
- } else if (tabsheet.getSelectedTab() == table) {
- subwindow.setWidth("500px");
- subwindow.setHeight("500px");
- layout.setSizeFull();
- tabsheet.setSizeFull();
- }
- }
- });
+ tabsheet.addSelectedTabChangeListener(
+ new TabSheet.SelectedTabChangeListener() {
+ @Override
+ public void selectedTabChange(
+ TabSheet.SelectedTabChangeEvent event) {
+ if (tabsheet.getSelectedTab() == tabButton) {
+ tabsheet.setSizeUndefined();
+ layout.setSizeUndefined();
+ subwindow.setSizeUndefined();
+ } else if (tabsheet.getSelectedTab() == table) {
+ subwindow.setWidth("500px");
+ subwindow.setHeight("500px");
+ layout.setSizeFull();
+ tabsheet.setSizeFull();
+ }
+ }
+ });
layout.addComponent(tabsheet);
Button button = new Button("click me", new Button.ClickListener() {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java
index 38cb1412a2..62443f43cd 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java
@@ -31,7 +31,7 @@ public class SubWindows extends TestBase {
private Component createRemoveButton() {
Button b = new Button("Remove");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java
index 00cd580ed8..65a6256b89 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java
@@ -28,7 +28,7 @@ public class WindowClickEvents extends TestBase {
@Override
protected void setup() {
VerticalLayout layout = new VerticalLayout();
- layout.addListener(new LayoutClickListener() {
+ layout.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
WindowClickEvents.this.click("Sub window layout", event);
@@ -36,7 +36,7 @@ public class WindowClickEvents extends TestBase {
});
((VerticalLayout) getMainWindow().getContent())
- .addListener(new LayoutClickListener() {
+ .addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
WindowClickEvents.this.click("Main window layout",
@@ -45,7 +45,7 @@ public class WindowClickEvents extends TestBase {
});
layout.setMargin(true);
Window centered = new Window("A window with a click listener", layout);
- centered.addListener(new ClickListener() {
+ centered.addClickListener(new ClickListener() {
@Override
public void click(ClickEvent event) {
@@ -61,7 +61,7 @@ public class WindowClickEvents extends TestBase {
l.setSizeUndefined();
Button b = new Button(
"Clicking here should not produce a layout click event");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
@@ -75,7 +75,7 @@ public class WindowClickEvents extends TestBase {
getMainWindow().addWindow(centered);
log = new Log(5);
addComponent(log);
- getMainWindow().addListener(new ClickListener() {
+ getMainWindow().addClickListener(new ClickListener() {
@Override
public void click(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java
index a662ee7175..3a9b4a9315 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java
@@ -80,7 +80,7 @@ class ResizeListenerWindow extends Window {
hl.addComponent(new Label("Current size: "));
hl.addComponent(sizeLabel);
- addListener(new ResizeListener() {
+ addResizeListener(new ResizeListener() {
@Override
public void windowResized(ResizeEvent e) {
updateLabel();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java b/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java
index dd78f6e154..2c3eb75244 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java
@@ -24,7 +24,7 @@ public class WindowScrollingUp extends AbstractTestCase {
table.setPageLength(50);
final Button up = new Button("up");
- up.addListener(new Button.ClickListener() {
+ up.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java b/uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java
index 5013c6e220..9390f068cb 100644
--- a/uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java
+++ b/uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java
@@ -34,7 +34,7 @@ public class MassInsertMemoryLeakTestApp extends LegacyApplication {
public void init() {
setMainWindow(new LegacyWindow("SQLContainer Test", buildLayout()));
- process.addListener(new Button.ClickListener() {
+ process.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
MassInsert mi = new MassInsert();
diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java b/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java
index 86f47ac505..502b476f3c 100644
--- a/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java
+++ b/uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java
@@ -498,7 +498,7 @@ public class DDTest6 extends TestBase {
l.addComponent(new Embedded(null, icon2));
l.addComponent(new Label(name));
- l.addListener(new LayoutClickListener() {
+ l.addLayoutClickListener(new LayoutClickListener() {
@Override
@SuppressWarnings("static-access")
public void layoutClick(LayoutClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java
index 827e3be162..9795973e93 100644
--- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java
@@ -57,7 +57,7 @@ public abstract class AbstractBeanFieldGroupTest extends TestBase {
protected Button getCommitButton() {
if (commitButton == null) {
commitButton = new Button("Commit");
- commitButton.addListener(new ClickListener() {
+ commitButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java
index c0ffcca0df..f0e3f300d7 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java
@@ -60,7 +60,7 @@ public class CaptionsInLayouts extends AbstractTestUI {
private Component addCaptionText() {
Button b = new Button("Add caption text");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
index 957821a450..82752d67d4 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
@@ -68,7 +68,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
private Component addCaptionText() {
Button b = new Button("Add caption text");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java b/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java
index 33ccda1a4b..2c670661fc 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java
@@ -44,7 +44,7 @@ public class ComplexGLColumnExpansionWithColSpan extends AbstractTestCase {
gl.addComponent(b2, 0, 2);
b1.setWidth(270, Sizeable.UNITS_PIXELS);
b2.setWidth(270, Sizeable.UNITS_PIXELS);
- b1.addListener(new Button.ClickListener() {
+ b1.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
cols++;
@@ -70,7 +70,7 @@ public class ComplexGLColumnExpansionWithColSpan extends AbstractTestCase {
mainLayout.setExpandRatio(gl, 100);
Button restart = new Button("restart");
mainLayout.addComponent(restart);
- restart.addListener(new Button.ClickListener() {
+ restart.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
close();
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java b/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java
index 60519cf1c0..77e49f4a87 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java
@@ -52,7 +52,7 @@ public class CssLayoutCustomCss extends TestBase implements ClickListener {
private Button createButton(String string) {
NativeButton button = new NativeButton(string);
css.put(button, string);
- button.addListener(this);
+ button.addClickListener(this);
return button;
}
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java b/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java
index ed3c5e66d3..b8f898e1f3 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java
@@ -32,7 +32,7 @@ public class CssLayoutSizeChangePropagation extends TestBase {
sp.addComponent(cssLayout);
Button button = new Button("b");
- button.addListener(new ClickListener() {
+ button.addClickListener(new ClickListener() {
boolean bool = true;
@Override
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java b/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java
index c985117ab6..0306aea7f6 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java
@@ -44,7 +44,7 @@ public class DeepComponentTrees extends TestBase {
root.setWidth("600px");
root.setHeight("200px");
final Button b = new Button("Go try your luck with " + i + " layouts!");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java b/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java
index 3531a4e13c..7e60b06ab0 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java
@@ -29,7 +29,7 @@ public class GridLayoutNPE extends TestBase {
lo.addComponent(b);
lo.addComponent(b2);
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
@@ -49,7 +49,7 @@ public class GridLayoutNPE extends TestBase {
});
- b2.addListener(new Button.ClickListener() {
+ b2.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java b/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java
index 5e187d1f79..1dc63f1240 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java
@@ -21,7 +21,7 @@ public class MovingInvisibleField extends TestBase {
"A visible text field");
tfHidden.setVisible(false);
Button b = new Button("Move hidden textfield to other layout");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java
index 72be418a22..65550cf651 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java
@@ -63,7 +63,7 @@ public class TestLayoutPerformance extends TestBase {
Button b = new Button("Render component");
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java b/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
index d00acf0983..2a9892ad18 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
@@ -41,7 +41,7 @@ public class VerticalLayoutWithRelativeSizeComponentsInitiallyHidden
Button b = new Button(
"Click to set bar visible. Button should stay visible.");
- b.addListener(new ClickListener() {
+ b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
diff --git a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
index 2c3e3360fe..62fd78a06f 100644
--- a/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
+++ b/uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -47,12 +47,14 @@ public class UsingUriFragments extends UI {
layout.addComponent(label);
// React to fragment changes
- getPage().addListener(new UriFragmentChangedListener() {
- @Override
- public void uriFragmentChanged(UriFragmentChangedEvent source) {
- handleFragment(source.getUriFragment());
- }
- });
+ getPage().addUriFragmentChangedListener(
+ new UriFragmentChangedListener() {
+ @Override
+ public void uriFragmentChanged(
+ UriFragmentChangedEvent source) {
+ handleFragment(source.getUriFragment());
+ }
+ });
// Handle the fragment received in the initial request
handleFragment(getPage().getUriFragment());
diff --git a/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java b/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java
index 88ca1cf5b6..81aa197a48 100644
--- a/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java
+++ b/uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java
@@ -21,7 +21,7 @@ public class NonExistingFileResource extends TestBase {
private Button createButton(final String filename) {
Button b = new Button("Download " + filename);
- b.addListener(new Button.ClickListener() {
+ b.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {