]> source.dussan.org Git - vaadin-framework.git/commitdiff
Unify listeners on the server side
authorAleksi Hietanen <aleksi@vaadin.com>
Fri, 23 Sep 2016 10:14:52 +0000 (13:14 +0300)
committerDenis Anisimov <denis@vaadin.com>
Thu, 29 Sep 2016 13:14:35 +0000 (13:14 +0000)
This patch updates server side add*Listener methods to return
a registration object and deprecates their corresponding
remove*Listener methods.

Additionally this patch removes add/removeListener methods which were
deprecated in 7.0.

Change-Id: I26ac5f11882512288fbbf601c7cb2aaff653ec76

156 files changed:
compatibility-server/src/main/java/com/vaadin/v7/event/FieldEvents.java
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java [new file with mode: 0644]
server/src/main/java/com/vaadin/event/Action.java
server/src/main/java/com/vaadin/event/ContextClickEvent.java
server/src/main/java/com/vaadin/event/EventRouter.java
server/src/main/java/com/vaadin/event/FieldEvents.java
server/src/main/java/com/vaadin/event/LayoutEvents.java
server/src/main/java/com/vaadin/event/MethodEventSource.java
server/src/main/java/com/vaadin/event/UIEvents.java
server/src/main/java/com/vaadin/navigator/Navigator.java
server/src/main/java/com/vaadin/server/AbstractClientConnector.java
server/src/main/java/com/vaadin/server/ClientConnector.java
server/src/main/java/com/vaadin/server/DragAndDropService.java
server/src/main/java/com/vaadin/server/Page.java
server/src/main/java/com/vaadin/server/data/AbstractDataSource.java
server/src/main/java/com/vaadin/ui/AbsoluteLayout.java
server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
server/src/main/java/com/vaadin/ui/AbstractComponent.java
server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java
server/src/main/java/com/vaadin/ui/AbstractDateField.java
server/src/main/java/com/vaadin/ui/AbstractField.java
server/src/main/java/com/vaadin/ui/AbstractFocusable.java
server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
server/src/main/java/com/vaadin/ui/AbstractSingleComponentContainer.java
server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
server/src/main/java/com/vaadin/ui/Button.java
server/src/main/java/com/vaadin/ui/CheckBox.java
server/src/main/java/com/vaadin/ui/ColorPickerArea.java
server/src/main/java/com/vaadin/ui/ComboBox.java
server/src/main/java/com/vaadin/ui/Component.java
server/src/main/java/com/vaadin/ui/ComponentContainer.java
server/src/main/java/com/vaadin/ui/CssLayout.java
server/src/main/java/com/vaadin/ui/Embedded.java
server/src/main/java/com/vaadin/ui/Grid.java
server/src/main/java/com/vaadin/ui/GridLayout.java
server/src/main/java/com/vaadin/ui/HasComponents.java
server/src/main/java/com/vaadin/ui/Image.java
server/src/main/java/com/vaadin/ui/LegacyWindow.java
server/src/main/java/com/vaadin/ui/Panel.java
server/src/main/java/com/vaadin/ui/PopupView.java
server/src/main/java/com/vaadin/ui/TabSheet.java
server/src/main/java/com/vaadin/ui/UI.java
server/src/main/java/com/vaadin/ui/Upload.java
server/src/main/java/com/vaadin/ui/Window.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerSelect.java
server/src/main/java/com/vaadin/ui/components/colorpicker/HasColorChangeListener.java
server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
server/src/test/java/com/vaadin/tests/server/components/WindowTest.java
server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java
server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java
uitest/src/main/java/com/vaadin/tests/FocusingComponents.java
uitest/src/main/java/com/vaadin/tests/ListenerOrder.java
uitest/src/main/java/com/vaadin/tests/ModalWindow.java
uitest/src/main/java/com/vaadin/tests/OrderedLayoutSwapComponents.java
uitest/src/main/java/com/vaadin/tests/TestBench.java
uitest/src/main/java/com/vaadin/tests/TestDateField.java
uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java
uitest/src/main/java/com/vaadin/tests/TestForStyledUpload.java
uitest/src/main/java/com/vaadin/tests/TestForTabSheet.java
uitest/src/main/java/com/vaadin/tests/TestForUpload.java
uitest/src/main/java/com/vaadin/tests/TestSetVisibleAndCaching.java
uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
uitest/src/main/java/com/vaadin/tests/application/ErrorInUnloadEvent.java
uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java
uitest/src/main/java/com/vaadin/tests/components/AbstractOrderedLayoutTest.java
uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java
uitest/src/main/java/com/vaadin/tests/components/TouchScrollables.java
uitest/src/main/java/com/vaadin/tests/components/button/ButtonErrorMessage.java
uitest/src/main/java/com/vaadin/tests/components/button/ButtonHtml.java
uitest/src/main/java/com/vaadin/tests/components/button/ButtonIOSDragTest.java
uitest/src/main/java/com/vaadin/tests/components/button/Buttons2.java
uitest/src/main/java/com/vaadin/tests/components/button/ShortCutListenerModification.java
uitest/src/main/java/com/vaadin/tests/components/button/TooltipForDisabledButton.java
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopupView.java
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSlowInFF.java
uitest/src/main/java/com/vaadin/tests/components/combobox/RemovalOfSelectedIcon.java
uitest/src/main/java/com/vaadin/tests/components/customcomponent/CustomComponentSizeUpdate.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldEmptyValid.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java
uitest/src/main/java/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java
uitest/src/main/java/com/vaadin/tests/components/gridlayout/InsertRowInMiddle.java
uitest/src/main/java/com/vaadin/tests/components/label/LabelWrapping.java
uitest/src/main/java/com/vaadin/tests/components/nativebutton/NativeButtonHtml.java
uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsAndModalWindow.java
uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java
uitest/src/main/java/com/vaadin/tests/components/orderedlayout/LayoutClickListenerTest.java
uitest/src/main/java/com/vaadin/tests/components/orderedlayout/ReplaceComponentNPE.java
uitest/src/main/java/com/vaadin/tests/components/panel/PanelClickListenerRelativeCoordinates.java
uitest/src/main/java/com/vaadin/tests/components/panel/PanelShouldNotScroll.java
uitest/src/main/java/com/vaadin/tests/components/select/ComboBoxAddWhileFiltering.java
uitest/src/main/java/com/vaadin/tests/components/splitpanel/AbstractSplitPanelTest.java
uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java
uitest/src/main/java/com/vaadin/tests/components/splitpanel/SplitPanelReversePosition.java
uitest/src/main/java/com/vaadin/tests/components/table/AddNonRenderedRow.java
uitest/src/main/java/com/vaadin/tests/components/table/ContainerChangeWithPartlySamePropertyIds.java
uitest/src/main/java/com/vaadin/tests/components/table/MultiSelectWithRemovedRow.java
uitest/src/main/java/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
uitest/src/main/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemId.java
uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuOnField.java
uitest/src/main/java/com/vaadin/tests/components/table/TableModifcationsWhenScrolledRight.java
uitest/src/main/java/com/vaadin/tests/components/table/TableReduceContainerSize.java
uitest/src/main/java/com/vaadin/tests/components/table/TableToggleVisibility.java
uitest/src/main/java/com/vaadin/tests/components/tabsheet/RemoveTabs.java
uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetTest.java
uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabsheetNPE.java
uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithProperty.java
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java
uitest/src/main/java/com/vaadin/tests/components/tree/TreeContainerChange.java
uitest/src/main/java/com/vaadin/tests/components/treetable/ChangeDataSourcePageLengthZero.java
uitest/src/main/java/com/vaadin/tests/components/treetable/RemoveAllItemsRefresh.java
uitest/src/main/java/com/vaadin/tests/components/treetable/RowHeightWithoutRows.java
uitest/src/main/java/com/vaadin/tests/components/ui/UriFragment.java
uitest/src/main/java/com/vaadin/tests/components/upload/ForceSubmit.java
uitest/src/main/java/com/vaadin/tests/components/upload/TestUploadFilename.java
uitest/src/main/java/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
uitest/src/main/java/com/vaadin/tests/components/window/ExecuteJavaScript.java
uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java
uitest/src/main/java/com/vaadin/tests/components/window/SubWindowOrder.java
uitest/src/main/java/com/vaadin/tests/components/window/SubWindowWithUndefinedHeight.java
uitest/src/main/java/com/vaadin/tests/components/window/SubWindows.java
uitest/src/main/java/com/vaadin/tests/components/window/WindowClickEvents.java
uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java
uitest/src/main/java/com/vaadin/tests/components/window/WindowScrollingUp.java
uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java
uitest/src/main/java/com/vaadin/tests/dd/DDTest6.java
uitest/src/main/java/com/vaadin/tests/fieldgroup/AbstractBeanFieldGroupTest.java
uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java
uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
uitest/src/main/java/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java
uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java
uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java
uitest/src/main/java/com/vaadin/tests/layouts/DeepComponentTrees.java
uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutNPE.java
uitest/src/main/java/com/vaadin/tests/layouts/MovingInvisibleField.java
uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutPerformance.java
uitest/src/main/java/com/vaadin/tests/layouts/VerticalLayoutWithRelativeSizeComponentsInitiallyHidden.java
uitest/src/main/java/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java
uitest/src/main/java/com/vaadin/tests/resources/NonExistingFileResource.java

index 2eeeb4c2eeb44a2265986ecd63d47e381051f286..7a745fa464a876ac96f94f718b61a78275362f88 100644 (file)
@@ -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;
@@ -32,6 +35,68 @@ import com.vaadin.v7.ui.TextField;
 @Deprecated
 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
index d2b4665bda0ef4f64283bf14fbba07ff05e932f0..8a6b4849f8e6de59d67e5ca6f314839147b8d3cb 100644 (file)
@@ -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;
index 37d427b503791a42498a91df32884dc1cd17a239..0ecfa9657fb8c9ecf343ee1d3ee06c20d8699672 100644 (file)
@@ -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;
index 4ee2ee4648107197aecff23edc248877b68938f5..14d014573008428867396051390cd5f6aed6de2a 100644 (file)
@@ -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
index 752884663f02c6d2727218668ad812ffb614efe4..3d535f25841e5d06e494378bf989bf00f59426d7 100644 (file)
@@ -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
index 0dba6419099a79a6c9fe085342a7c853e204b900..2cf1f57962e0d2c5c39bd2a03ea4fc1138517d58 100644 (file)
@@ -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 (file)
index 0000000..0d6166b
--- /dev/null
@@ -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
index 392f23dffe37159f410c429cfc5b3dfa5e97e2f3..49b80334172ce4dcc79882a814510eea8e851339 100644 (file)
@@ -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);
     }
 
index d1b089af0822efcb54ec1f80398cf497e6cacacc..ecf53e2ba21093fd01e3eeccc6e9e39652fffb58 100644 (file)
@@ -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);
     }
 
index 9ef6c8123bffe0cb308e6dc4fb2df91f246dc6bf..c5237d9acabb975ea4de111573d648b18cef6cbb 100644 (file)
@@ -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<>();
         }
index ba84e96b3f09d7a6cc966b986070ff23c49224b0..3a4cfc209e8ee5a7e858143f1cead9bd9c1e0f35 100644 (file)
@@ -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);
-
     }
 
     /**
index 9d6dd20fffebecdcef0ef9629c87668d36bd0900..627a9610ed4e20da2c359559169e740f26454e15 100644 (file)
@@ -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);
     }
 
     /**
index f10f136671f729b0f6c7455ab0da8dc040720695..42f49021228a66d7e040164c58b0cfb0ac0fff3e 100644 (file)
@@ -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);
index a822c359266e9ca00dec4e02234e6438eab17f94..1f696e9d6cdee3ad15f843c951c6edbe53c112a7 100644 (file)
@@ -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);
     }
 
index 13e3b4c2e7ce7ab3aa8d057385ff58f5946b1107..4fb3906e9e3690d65262c2fb50a151ac5fe837bf 100644 (file)
@@ -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);
         }
     }
index ea969bea2b0e11240b0feae02c979adc80ffd0e9..3299568778129483fd881dd05729bd5fde4af6f9 100644 (file)
@@ -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
index 87c6b8309eb9bf45c91ebb8be114fa4cd01728fc..80453d4733a169478cf0f8e81e007f58c9220729 100644 (file)
@@ -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);
 
     /**
index 23bea5138bd96d004cede255a67f815c5ce68500..d23c87e468daea6ec8c31f43cc90a3a1eace6c28 100644 (file)
@@ -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) {
     }
 
index 9330c08a2873f272ebc8739cfbeef94e2ad2512d..35fc6b96e85bd08922895900b44aee71e45981bd 100644 (file)
@@ -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,22 +529,18 @@ 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,
                 URI_FRAGMENT_CHANGED_METHOD);
     }
 
-    /**
-     * @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}.
@@ -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,
@@ -780,15 +777,6 @@ public class Page implements Serializable {
                 && eventRouter.hasListeners(BrowserWindowResizeEvent.class);
     }
 
-    /**
-     * @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.
index 9dba0bd35e6aca7a52bdce8b378efadd684248a0..f54056e1b07cdc8ac6427b8f29165dfad6f3daa9 100644 (file)
@@ -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);
index d435bc806b03000731fee1765a7300684cb193d1..5aa008e8293bb9627e27b29d93df835fad675e44 100644 (file)
@@ -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)
      *
index d7d12c6d03995a749cda8a9a8a54fae8f97e2625..695187a6eb9680fec628e46a27a012f0afd791a9 100644 (file)
@@ -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);
     }
index a34b09e9d81e6ac8ea0f35fb14438dfd47a1e438..f794cab51b7807110a0174e1afe724bcb7ca5340 100644 (file)
@@ -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);
index b5fe4e9bcd8d7e8caf8d0fa20f248b86e0a66c55..8c10027cc4eda980ab70427576c40f3ada9eebd9 100644 (file)
@@ -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,74 +100,42 @@ 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,
                 ComponentDetachListener.detachMethod);
     }
 
-    /**
-     * @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
index ac945256f79679d9e40917cf1d8a70771c3f2bbc..ab0aed1b0c1e0ddb4ed94eea03469d7097ae2745 100644 (file)
@@ -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);
     }
index 4946d3c95b9cec342d1d3d101e2fefb938471e73..012a5df5a166a5da4f568fec63715d4790f328a1 100644 (file)
@@ -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);
     }
index ac0f911fbc30f47bff21ecd791120c09e4ee755a..eb0c957a803cbc39ec0836bcbfe0251fb6314144 100644 (file)
@@ -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);
     }
index 4094ee383c2b235a74a2a19aea530fbdde25a03a..48b47ca2d588ed47a8b78b22f9c8e0966e34882e 100644 (file)
@@ -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
+}
index 331a0e72be8dd8ee4b6ad63a81361218efb01753..3be9ca668abb3ebb26ac0c52666bda68ab9fe610 100644 (file)
@@ -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,38 +368,21 @@ 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.
      *
index 3e47a739cfdf5ae626575c3884e8781768ca66ca..dc92ece1e9f14696865331c61f6836eae0859492 100644 (file)
@@ -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,
index 257e1c9da8ab9fe8ee76c3fab7b8fbee370b3f02..bf521f34cb3a7820723f4973eeba1fc39e1a8956 100644 (file)
@@ -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);
index 3add13cd4a03862ce3016d1c1004bd061e5828b2..5f481cb537fb27df1225bde50d52437138be89dc 100644 (file)
@@ -29,6 +29,7 @@ import com.vaadin.server.SizeWithUnit;
 import com.vaadin.server.Sizeable;
 import com.vaadin.shared.EventId;
 import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.Registration;
 import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelRpc;
 import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState;
 import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState;
@@ -575,34 +576,20 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
 
     }
 
-    public void addSplitterClickListener(SplitterClickListener listener) {
+    public Registration addSplitterClickListener(
+            SplitterClickListener listener) {
         addListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class,
                 listener, SplitterClickListener.clickMethod);
+        return () -> removeListener(EventId.CLICK_EVENT_IDENTIFIER,
+                SplitterClickEvent.class, listener);
     }
 
-    /**
-     * @deprecated As of 7.0, replaced by
-     *             {@link #addSplitterClickListener(SplitterClickListener)}
-     **/
     @Deprecated
-    public void addListener(SplitterClickListener listener) {
-        addSplitterClickListener(listener);
-    }
-
     public void removeSplitterClickListener(SplitterClickListener listener) {
         removeListener(EventId.CLICK_EVENT_IDENTIFIER, SplitterClickEvent.class,
                 listener);
     }
 
-    /**
-     * @deprecated As of 7.0, replaced by
-     *             {@link #removeSplitterClickListener(SplitterClickListener)}
-     **/
-    @Deprecated
-    public void removeListener(SplitterClickListener listener) {
-        removeSplitterClickListener(listener);
-    }
-
     /**
      * Register a listener to handle {@link SplitPositionChangeEvent}s.
      *
@@ -610,10 +597,11 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
      * @param listener
      *            {@link SplitPositionChangeListener} to be registered.
      */
-    public void addSplitPositionChangeListener(
+    public Registration addSplitPositionChangeListener(
             SplitPositionChangeListener listener) {
         addListener(SplitPositionChangeEvent.class, listener,
                 SplitPositionChangeListener.moveMethod);
+        return () -> removeListener(SplitPositionChangeEvent.class, listener);
     }
 
     /**
@@ -623,6 +611,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
      * @param listener
      *            SplitPositionChangeListener to be removed.
      */
+    @Deprecated
     public void removeSplitPositionChangeListener(
             SplitPositionChangeListener listener) {
         removeListener(SplitPositionChangeEvent.class, listener);
index da77a1760bd156d50ddc602f0c0d15b0bc0e6a66..499713ffbd2d696fcd81ef0fc9b6f146df677379 100644 (file)
@@ -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,21 +325,17 @@ 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.
      *
index 2620b4246480dd4fc1f646c707aa07a71645e7ca..4fa08a82b5d6e00760d2a9c92f117f2ffb049d15 100644 (file)
@@ -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);
     }
index c4f3971259513ab86f10867952762030da768994..dc2adfed3a1a425260374fe7832f2ae56d5e9a9c 100644 (file)
@@ -73,5 +73,4 @@ public class ColorPickerArea extends AbstractColorPicker {
             getState().width = "30px";
         }
     }
-
 }
index 5ed454d370d80c1f64779ccb5cd1af05921860b8..31dbb7da9420057e6aeebb5f77ae15544300f6f1 100644 (file)
@@ -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);
     }
index 993d88d992802fe1daca3c1b32444988d78fe370..ffca8b808cd12b27b501c5bc34420d629aa3ff3e 100644 (file)
@@ -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);
 
     /**
index ba6594d10d312f18f7832411cf233818579965e6..b11f2e9a6941dd137a18a48604375bf0441e7277 100644 (file)
@@ -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);
-
 }
index 381e7aa4633a89e4bc3234c7c9207baa292f44dc..d4daf674194516ddd20bead68e7c29a57f0ddc93 100644 (file)
@@ -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,38 +305,21 @@ 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.
      *
@@ -397,5 +382,4 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
             designElement.appendChild(childNode);
         }
     }
-
 }
index b0c7f1725b2703ea67c2399cb8e13621839d8c15..e4dcee096fda125542d54805a12ec8c5382a0689 100644 (file)
@@ -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
index b1a2c64ec8de254a96da843e97430e1cb3501d62..e2df8b437b4b6b62f448f0178b11a3986f0628bc 100644 (file)
@@ -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,
index 6e74071f657d2c1f37379534680bad41c5e11c33..40b8575c36cec4c236811444f9521266e283d14e 100644 (file)
@@ -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)
      *
index e74eb6dd32a2d6e77af2be29dae1a27a6e8928b7..847a6fada276606b9c844d0f1f731dc4774a8ad7 100644 (file)
@@ -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);
     }
index af698ecc97cf3f6de1f19326d87bec59a8295a5d..fca1bc7b8ad594ebdcba1e9dfb973cc5ff4ab416 100644 (file)
@@ -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;
 
@@ -75,37 +76,22 @@ public class Image extends AbstractEmbedded {
         return (ImageState) super.getState();
     }
 
-    /**
-     * @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);
index a6771da379b4b1a64a54a151f6398771f44f76ff..2705d56486c4ee01f8e2139c088a5a3f36005dec 100644 (file)
@@ -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);
     }
 
     /**
index 1f7197a76c506211ff99745f5547c6d02c9d078c..7b1333d89810c07f7df4401b4889e742b6d470ed 100644 (file)
@@ -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,21 +288,16 @@ 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}
      */
index ed540f149c5b08e4744fd6df0f81f01f8d2655bc..497e052f22b99c59cbe979f641d832db7f2118f2 100644 (file)
@@ -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,22 +358,18 @@ 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,
                 POPUP_VISIBILITY_METHOD);
     }
 
-    /**
-     * @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
index a03b342ba0d66079e1308dc8e8c00e13dfc67bec..79fe6227a18ed0e3a78fdda3ba346f35c898fe89 100644 (file)
@@ -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,47 +844,40 @@ 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,
                 SELECTED_TAB_CHANGE_METHOD);
     }
 
-    /**
-     * @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.
      */
@@ -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);
     }
index 82bbea7039f6846b7a5a026f0110ade94d59188e..34e9177e0cc5b6d3a1ce8f32fe9ed02e656946ad 100644 (file)
@@ -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);
     }
index 9077a35b9520f82da970cdfbbb2ae6d4d9929efa..5d2d4763e73ba26f4658004f9e249caa528cdede 100644 (file)
@@ -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,19 +768,11 @@ 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.
      *
index c0eac75970b7a5d6b069155ec2a857c514f9e7b4..82acf0ee6f42ad93dc7be608a9fdfa042dfb9b02 100644 (file)
@@ -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,19 +602,11 @@ 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.
      */
@@ -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);
     }
index cbb1ba9795c39af1c0ef3be724669f6a1e19ffe2..77b939e8b4ad085aac2fb8e42978094266ed1fce 100644 (file)
@@ -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);
     }
index 9e5580c7193a507a9274c4f61fe9d903d97ed97e..544d6c9c9ea0ab619b4ef69c9d9c83593bdb73bb 100644 (file)
@@ -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);
     }
index 1173faf1527e2ae57d5e3e704ed7039e3b2fe597..de0b1f4c52687239f48d594619d79d3c2de515e3 100644 (file)
@@ -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);
     }
index 8876e4809d784aa2f2a4faa9b38d85dca8eeddc6..59c70337757ecc1faf5627bec5fdc45f30f52611 100644 (file)
@@ -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);
     }
index e7d9395e0635301eb149dd9186d38410cc3eac20..c747002bde65e70566e8dedbf4485c419f6ba904 100644 (file)
@@ -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);
     }
index ac0da15fc55c4171c5c7525900098d963edf5793..fd37d3345aa928251671a41192a7235c1f36c453 100644 (file)
@@ -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);
     }
index 7980111e2b5340b189270b22f89859d95bad5be0..505365ec63d45657a9b027881662462a8184d4ee 100644 (file)
@@ -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);
 
 }
index 2617827b7774e4be2c624b8fb724af2582146643..87cdae84af330a09c0a69e0d153bf1b1358f60de 100644 (file)
@@ -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 (file)
index 0000000..3ca5092
--- /dev/null
@@ -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));
+                }
+            }
+        }
+    }
+}
index 8f1c54ff6f6371541a61b23fd96a0a7ac1ed2770..22036354300ed25350d49e87c2adae4c8f8a7792 100644 (file)
@@ -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,
index a38ba9b0f957884cb6517f8188988204b21e9c28..52e367abf2714e0697f87499bc0f52e421bf6f85 100644 (file)
@@ -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
index c7bb725cc9e02372d517bf6890ed23644ce89246..7b160106d83451546a9db69db68b3003f1c72e6e 100644 (file)
@@ -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
index 9fb52351f8bd5df9a893b98ddbbff0aee6ea9ce6..6c7a3cf0d89c908010413bf0aba77ee779104306 100644 (file)
@@ -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
index 0de6a0398681117404019664fff2f4814e257972..3f86939378845eb6548251f207885ee0d7c31e98 100644 (file)
@@ -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();
index 3e885f1078bb6cead75e14c1d7fd70da46054128..c4fe9a2a65a30fbc1beccf18897dc1eff98fdb9e 100644 (file)
@@ -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;
index b366e2d01b16aa0a235c5c4ac5baf3354daf5f2a..91946fad4a5cddcf05fd3834bb94746a4816c542 100644 (file)
@@ -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);
     }
 }
index 0dbe05fdeef1a671a4e556058cff882af11cadb4..d878c19aa8a65128348923760d727d2f01ea3e94 100644 (file)
@@ -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;
index 2f77086ed7fb96f8ae49d8687bd0002ed8d56841..d66f58e539ffbba730c1f0471f06981dc8f9f9d3 100644 (file)
@@ -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);
 
index 7a63c628b429244a9266e02fa0799abaf3e4c8de..c3d96a6214a721c7fc6bc7453a37ced712eb9e5a 100644 (file)
@@ -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();
     }
-
 }
index 10c3328e891b86aac25f48485625abe4aebe2a23..707aa51d6fa2d2ec15aebef6c471ead46ede0c84 100644 (file)
@@ -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();
index 3f53686071af2f6ea4b556660e44b47cd058822f..7344d05403aae923534bec4bbf296f74ca4212d0 100644 (file)
@@ -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) {
index 4dfa1b96a675abc45f8a319992e464c0215bcda0..dc37ee0f6de29f3e1941959fa9b889df3c13c2ef 100644 (file)
@@ -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. */
index 5014dcfac4c5f3359c99b591ba14ee0ef049737e..e5cc82374d6b56b5b63287370b08f02f023a4896 100644 (file)
@@ -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) {
index c12a70c04d33e36efa616ef8e2bdb0241c82303f..73e9e887ade9d7e65777220e9fc23df1cc74b3d2 100644 (file)
@@ -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++;
index 6cde8350ed5be48664747d6e0c6baa950c14eae8..584a952885fc42c1669ed0fcc5d1b00666b2fac4 100644 (file)
@@ -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();
index a09c4c845a71b19044e6d25bc27c1333bce8099d..891e8233367f98cf8ee5a7564d83a9f588ae53d9 100644 (file)
@@ -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;
index f50be07af9d28055cf33121f3ed157f117db2223..c3a8fcbbf5769a9a42a31ebdf5f814d611440945 100644 (file)
@@ -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);
             }
         }
     };
index 0e91dd91098aebb976f914d56335acd4a2bff1c0..6cf544f16c7a777a9da2e156dc7ce99e4e1db364 100644 (file)
@@ -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 {
 
             }
index a82044bf57026e1bdd8ba1569199a3b8eed83135..3a2756128435e70d84f21b9b8080297ff095346b 100644 (file)
@@ -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;
 
index 8f6f98fd898ffc5d491d9d53ef2fc1e8ad78a285..3b331a23df454692cdce0f7c7e7d6c54e54feb71 100644 (file)
@@ -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());
index b27f948669c9a4369649e0c2381dda5dd2508e63..38195a34edace1b1107d59662342f994eed1345e 100644 (file)
@@ -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();
index 0b1ab42667f158ced30dfe87bb092f499e6e9927..d1ad20922cd042642754eb5c22a02fec39d62b8b 100644 (file)
@@ -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) {
index 15e44f177d87d826f444bb2c9faf55d6317e1958..d80fd028d2b513f33bb5d85b7ed1503dcaca8af1 100644 (file)
@@ -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!");
index 4f75dfbfef2f11d30695a1574a6e84a830a38a36..df344b1a450e41fbd81fa6b04179e93c8769fe74 100644 (file)
@@ -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);
             }
 
         }
index 025dfbb9c3a3c69701cafa3c8d6daa1f071f57dc..2a3d569671e1302ac9082b7cff67c30f142522e9 100644 (file)
@@ -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);
index c1f1846415e3525338bdc92b13b3e7a3da6359d5..b4bafb05a2fae217f188f7b1371c333ad6d2e215 100644 (file)
@@ -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) {
index 4938f242419beab0309b6ae5d14f962039111a30..9ea835aac53665fba42e3aa9af7409b1e11b599d 100644 (file)
@@ -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) {
index 40bdf0c7a1f4e3a1dfa8375da82532c9875c4d09..09b84ba882fa9a6cef651d16bb0b5fa4e761b013 100644 (file)
@@ -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) {
index ad70412e9f11c830caa8cb71dedf727fb5a94ca2..93c62db9e52c5bf94e0d048dd546761f2af0f39e 100644 (file)
@@ -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) {
index baf8f7487b2054e514e8af4be305c43a6585e2b6..1a9c1973653f594e4ca767c10ef7eac8838e8a9b 100644 (file)
@@ -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();
index b8609de3e238a22442365d293ccd4ba55ed6c21a..3a3a6bb3ea1cd1e6c6f7de1ff12ed78d69a62b3c 100644 (file)
@@ -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) {
index 2351b02e2a37732c962d7d326be38298ce5399ee..73080b4d2fcd6facd9357f140978c5dc76350e21 100644 (file)
@@ -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) {
index 30a34e4fc4538180f75695b182a04c8a298d32ea..5e9df766d2b2b2808049a3eb08c6bcbb17c13493 100644 (file)
@@ -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");
index 339eff6972193e980c46897570f3f041732863ae..84ac1c61062d68f776f858489c51584863dd1010 100644 (file)
@@ -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) {
index 3225b0af9a0d9e942fb85e2eaf69b5bef6d0eedd..c581779b927e35ca22845303780e5f38fba1ef6d 100644 (file)
@@ -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) {
index 7632577227c3a301c923353dcf64d985d4dfe64d..9320e9ef6a191e879eb61a49ff17cf395029e3b0 100644 (file)
@@ -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();
index 78b4a9d4170b4206e9df24ba6b0fd4e8bb5a2047..764464c838948c3ce51f3e94187013baf97f13d7 100644 (file)
@@ -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);
index 82969fdb0896da79fc7c40390145ccb362a676cc..2a20b469119960bd90d344ae82399827ec045ea4 100644 (file)
@@ -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)) {
index c17fa156123fce7690307933ff59b769ae57e0cd..9fae2490b5635aff895b38aaf83feb180d494259 100644 (file)
@@ -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) {
index 25bc05c771b73745d0c7d8127baeb4ebdeff14d1..f4d0c77428871c94eca91cb91d0f7e58ca249b65 100644 (file)
@@ -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");
index 79dc0a88ef7d636a4722250b8406e7653397436d..416e5c8d096a15e9c5a4111cd867d88dc10e3ae0 100644 (file)
@@ -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
index 6179694686faf77a3f95eac6cd4b2df9cda4f06f..f55db0d0ee09363baaa824e3f77e4256c7ebfce7 100644 (file)
@@ -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) {
 
index a18400ce088dbc77415e1a3f236c694469fd360a..f18fb39fda291812b029d611e2ce6a04fc93ffd3 100644 (file)
@@ -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);
index 7cc1d27e43c3e4691fa53d1882d973cbb8f57c61..0e17a1729b3e8b2c7d10178ba5d5cdb9132cb045 100644 (file)
@@ -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) {
index 15ca0d521ed8c638d65deb031c476a7ea29223ac..e4f9eb46f01ea498056ccbc1c2c588d563332390 100644 (file)
@@ -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);
index 97dd15f4b4a775c6f146d9d3aeb7e7959143736c..d343d9d85ebc5519c3efed4f95cbb0e2465dd3c9 100644 (file)
@@ -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);
index 5fa6860c341ae1ac06f490c478bf6b15b2a82881..0d75f654d28da698c99a1b4306e6d9f4e6bcef52 100644 (file)
@@ -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);
             }
 
         }
index 3025da57e75116494c4e3dfb247567edf4252ebe..9b86b1f95e22ff77741f9afce14f8404dc1d9c5c 100644 (file)
@@ -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;
     }
 
index 88654b8ffc864fcd00cca8bb32a926f40c6276f4..e5ebef01fa2d31b405e0e176bee6b6a45559a68f 100644 (file)
@@ -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");
index b73e71bc45db2e7922e8a001d644278b23f5f919..3ec2a430aa85d6f9ae2354e9b5eb44c879266327 100644 (file)
@@ -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();
index 555ba7eaabbee96db8248882ffd507f6f2e8a05b..0807f7946bf39db0957036397265846e4db1765f 100644 (file)
@@ -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 {
index 0fd201fc9afd9bc90db61d90909e2c35368cb44b..c4df124a159f7f0fb495a779c28afc88b3756e21 100644 (file)
@@ -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();
index 14ec0e64120bdace88f2a5874f8e5d544273bc7f..4f5f088a16852b1dd20dd7869bf192028df22673 100644 (file)
@@ -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) {
index 12f677d60d170a3497101701aacdd9b15c6bcd0a..439ebf6975f189073932635e00ab3d4e54452461 100644 (file)
@@ -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();
index 185a7e3d6727e8c1a08aa4bb991ba75342b0e195..a559e8f743d591e51351d23595157f7ae236140e 100644 (file)
@@ -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) {
index 6750b152aa2fea0adeac5c0d0ed669da2688dca2..0d39d211d30f2f17d01c937ae35da2b8ed512f4a 100644 (file)
@@ -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
index 93bd94b774a135cb5218092d6830233e2baba69a..abc549e4bd51b26b63e630dc241420e4ff014a48 100644 (file)
@@ -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 {
index c83964a829dba13e77be1b77ed3faedbd3f2b697..0410b23996ef71b3de592bceaa08b29fdc08ca7d 100644 (file)
@@ -138,7 +138,7 @@ public class TableToggleVisibility extends AbstractTestCase {
 
             setCaption("- " + table.getCaption());
 
-            addListener(new ClickListener() {
+            addClickListener(new ClickListener() {
 
                 @Override
                 public void buttonClick(ClickEvent event) {
index 45890ced73751045bbbcbfec981e07cb4e4eeb05..3dd2d0cd0ae789324f4a2b93f328e14102273529 100644 (file)
@@ -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();
index ece3693bfd5217c22f360ae1d2c57032ed9484ad..3910b3a4f1ab40b968c6f80c11a5c963992bfce6 100644 (file)
@@ -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);
             }
 
         }
index 0aa10662fac4ca987406a985e6b6989e296fe089..9e469ba77c821fed6364fcf800c5bef4081ea728 100644 (file)
@@ -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;
     }
index a588e9c862744845ccc668085ea4fd3027482070..3fd15ecdccecec7c50ec6c757c972890ed30cf79 100644 (file)
@@ -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) {
index 79239da7e78ce33ce89b45acbee1a43409ffcab1..9ffc7cce38dca74a7e0620a04f3f7e3c97d6cc2b 100644 (file)
@@ -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");
index 58f542ccfb068b6795d100e6e3ecf60b6c5e941e..9967980d165cbbc8d674a280e184f9c716af8237 100644 (file)
@@ -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");
index d6167b4bfffb07f1de53611622083f5cc9f1f287..be260ef30fc15eb749abb4d1a53fdf57220e90e1 100644 (file)
@@ -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) {
index 92b14e33c4fe8597df2c239eac40d6a9adf2f712..a3e73bd40cf780ae57ddf5f580c25d754cd944bf 100644 (file)
@@ -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
index 64a7e34fcccef07be6d296d43a6c832282dca80c..8e5b30639cf270a5eafe4396d8f8b66cfb21274b 100644 (file)
@@ -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();
index 95f215b66bda42c3b93bdacc1180b205a48f70d2..e3000e8fb7e360c91f580a8a42709f7529229016 100644 (file)
@@ -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"));
index bcad8589d6041e45d3c6843aa522d1ef30e11050..55b93c609fdb85d6f7a049f7f682a41065393255 100644 (file)
@@ -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 #", ""));
index 671e46e4d7dfc71740c28e6e62c2a00b9ff9f6de..4b0b8e99c3d4cc9cd9f42c481e3722b95f48adf1 100644 (file)
@@ -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();
index de0cca500931e792cc7829ea0452dd05daf71e6e..41f4f31588278942209655f572d3c24adf91712b 100644 (file)
@@ -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): "
index 455fb2e531d36977832851a8139f2c20a5eeae69..bd0cb109b0f55d330321e6f69d67a3541200e71e 100644 (file)
@@ -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) {
index 8184d10d85627971a0ddfaa637ec8d14244e3fbf..1a54c399d8266ce5e48fcd963e7b75cd57fbd592 100644 (file)
@@ -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) {
index 70d83a466bfa430d06d60a441e492e87d323b4d8..cf9eb1b9eb286c279b70e68a0f087b8326d682ef 100644 (file)
@@ -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);
             }
         });
index f4dae2aa752e0fb4414d1affdca163e7ae1c5632..6b92a4b1eb4e88fca8c646a0a9a90488dfec2679 100644 (file)
@@ -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
index 8b705a418b308d2b96bfae7cf42db7c98d9e2fce..8ef94a24653f0933b97ed9e535347ab92ba625b8 100644 (file)
@@ -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() {
index 38cb1412a2a45254d03776fbc80e1ce3d044dd27..62443f43cd0e9f87761de108e895d14f29798515 100644 (file)
@@ -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) {
index 00cd580ed800ce2c5b8e4e1429cef7ca8f4b97bf..65a6256b897bcaa7282e26ec9512280b09f4056c 100644 (file)
@@ -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) {
index a662ee7175e60f1f104828c1150b3d7d12d6ece2..3a9b4a931566695e38f470493323eabffa9d0f4e 100644 (file)
@@ -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();
index dd78f6e154966c32cea8af351d639f4257893f09..2c3eb75244a39838d96a85bf88749a28a49b2c56 100644 (file)
@@ -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) {
index 5013c6e2208cd5eb2f5ca85af0afe8b8c401281e..9390f068cb77f69f4ce221acb4bb908cc378d204 100644 (file)
@@ -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();
index 86f47ac505da3108144011ec11eb696d0f7ba71a..502b476f3ca8d5fe168c0edcc3d1df5d292d884e 100644 (file)
@@ -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) {
index 827e3be162dd96f84ac65b00292e68d7490988e2..9795973e9340ad09d9aee06b5d71f2bdd890e289 100644 (file)
@@ -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) {
index c0ffcca0df81afdaa3ed61e7c515297a5bd78cdf..f0e3f300d7ced9bf90852783f07903ffab18ec1e 100644 (file)
@@ -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) {
index 957821a4506ed7aa52ae9d74b59b717f04334a01..82752d67d4432b5deaf9bb52305835a527d467b6 100644 (file)
@@ -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) {
index 33ccda1a4b6760eccba60e9f357b5bc913ff3f63..2c670661fc199da033aea65552111445e7dfa558 100644 (file)
@@ -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();
index 60519cf1c01ea9c319968e99752f9fc93856a893..77e49f4a8743b7a61e02551e9bc71be07949839f 100644 (file)
@@ -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;
     }
 
index ed3c5e66d3f925dd5307f91aca6090334fc62bbd..b8f898e1f306344a8f99c697baaf7be25a55939d 100644 (file)
@@ -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
index c985117ab61ecadc32654cd1b922a03fa44a64f0..0306aea7f60ebc83191de788a04d41fa3e8b54f9 100644 (file)
@@ -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) {
index 3531a4e13c577e24538e0f5886c5c8e77a6957cb..7e60b06ab0f0a92fd6fa83411f051641cd5f873e 100644 (file)
@@ -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) {
index 5e187d1f790b34886cf107ea30e43ba1181a2684..1dc63f1240fb46167ebe38ced423077d7f3f671f 100644 (file)
@@ -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) {
index 72be418a22fdfacff741ca9ee043f6f918f42c19..65550cf6514a2c1ee313d8b7fd598c82fc4ef88a 100644 (file)
@@ -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) {
index d00acf098306ab3580ccda790201c86247e84428..2a9892ad18fbc459899982fb9cb9a301a431aca0 100644 (file)
@@ -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) {
index 2c3e3360fee5720f02a214ba35107aec6ab81ed2..62fd78a06f59c39bea55465d0b8798fbaf41f448 100644 (file)
@@ -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());
index 88ca1cf5b692e49ab8a37c30753dd3f1c4e7401d..81aa197a48677e9f553c3a90a9b0a396ef94162b 100644 (file)
@@ -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) {