diff options
12 files changed, 61 insertions, 146 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java index 7422fd8ffc..627b4cf25c 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java @@ -45,6 +45,10 @@ import org.jsoup.select.Elements; import com.vaadin.data.sort.Sort; import com.vaadin.data.sort.SortOrder; import com.vaadin.event.ContextClickEvent; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.SortEvent; import com.vaadin.event.SortEvent.SortListener; import com.vaadin.event.SortEvent.SortNotifier; @@ -60,8 +64,9 @@ import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.Registration; import com.vaadin.shared.data.sort.SortDirection; import com.vaadin.shared.util.SharedUtil; -import com.vaadin.ui.AbstractFocusable; +import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Component; +import com.vaadin.ui.Component.Focusable; import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.SelectiveRenderer; import com.vaadin.ui.UI; @@ -89,6 +94,8 @@ import com.vaadin.v7.data.fieldgroup.FieldGroupFieldFactory; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.data.util.converter.Converter; import com.vaadin.v7.data.util.converter.ConverterUtil; +import com.vaadin.v7.event.FieldEvents.BlurNotifier; +import com.vaadin.v7.event.FieldEvents.FocusNotifier; import com.vaadin.v7.event.ItemClickEvent; import com.vaadin.v7.event.ItemClickEvent.ItemClickListener; import com.vaadin.v7.event.ItemClickEvent.ItemClickNotifier; @@ -186,8 +193,9 @@ import elemental.json.JsonValue; * @author Vaadin Ltd */ @Deprecated -public class Grid extends AbstractFocusable implements SelectionNotifier, - SortNotifier, SelectiveRenderer, ItemClickNotifier { +public class Grid extends AbstractComponent + implements SelectionNotifier, SortNotifier, SelectiveRenderer, + ItemClickNotifier, Focusable, FocusNotifier, BlurNotifier { /** * An event listener for column visibility change events in the Grid. @@ -7410,6 +7418,43 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, } @Override + public void addBlurListener(BlurListener listener) { + addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, + BlurListener.blurMethod); + } + + @Override + public void removeBlurListener(BlurListener listener) { + removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); + } + + @Override + public void addFocusListener(FocusListener listener) { + addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, + FocusListener.focusMethod); + } + + @Override + public void removeFocusListener(FocusListener listener) { + removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); + } + + @Override + public void focus() { + super.focus(); + } + + @Override + public int getTabIndex() { + return getState(false).tabIndex; + } + + @Override + public void setTabIndex(int tabIndex) { + getState().tabIndex = tabIndex; + } + + @Override protected Collection<String> getCustomAttributes() { Collection<String> result = super.getCustomAttributes(); result.add("editor-enabled"); diff --git a/server/src/main/java/com/vaadin/event/FieldEvents.java b/server/src/main/java/com/vaadin/event/FieldEvents.java index b0e539961b..4673318890 100644 --- a/server/src/main/java/com/vaadin/event/FieldEvents.java +++ b/server/src/main/java/com/vaadin/event/FieldEvents.java @@ -55,19 +55,6 @@ public interface FieldEvents { */ public Registration addFocusListener(FocusListener listener); - /** - * 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); } /** @@ -94,21 +81,6 @@ public interface FieldEvents { */ public Registration addBlurListener(BlurListener listener); - /** - * Removes a <code>BlurListener</code> from the Component. - * - * @see BlurListener - * @since 6.2 - * - * @param listener - * the listener to remove - * - * @deprecated As of 8.0, replaced by {@link Registration#remove()} in - * the registration object returned from - * {@link #addFocusListener(FocusListener)}. - */ - @Deprecated - public void removeBlurListener(BlurListener listener); } /** diff --git a/server/src/main/java/com/vaadin/ui/AbstractDateField.java b/server/src/main/java/com/vaadin/ui/AbstractDateField.java index 1d3f1ee7b2..43d374c392 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractDateField.java +++ b/server/src/main/java/com/vaadin/ui/AbstractDateField.java @@ -574,24 +574,12 @@ public abstract class AbstractDateField extends AbstractField<LocalDate> } @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override public Registration addBlurListener(BlurListener listener) { return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); if (design.hasAttr("value") && !design.attr("value").isEmpty()) { diff --git a/server/src/main/java/com/vaadin/ui/AbstractFocusable.java b/server/src/main/java/com/vaadin/ui/AbstractFocusable.java index 959a18fc80..2ad0e4a9f5 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractFocusable.java +++ b/server/src/main/java/com/vaadin/ui/AbstractFocusable.java @@ -47,24 +47,12 @@ public abstract class AbstractFocusable extends AbstractComponent } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override public Registration addFocusListener(FocusListener listener) { return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override public void focus() { super.focus(); } diff --git a/server/src/main/java/com/vaadin/ui/CheckBox.java b/server/src/main/java/com/vaadin/ui/CheckBox.java index aa7cc565eb..8675332eb5 100644 --- a/server/src/main/java/com/vaadin/ui/CheckBox.java +++ b/server/src/main/java/com/vaadin/ui/CheckBox.java @@ -145,23 +145,11 @@ public class CheckBox extends AbstractField<Boolean> } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override public Registration addFocusListener(FocusListener listener) { return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } - @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - /* * (non-Javadoc) * diff --git a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java index 016b5ca392..508d4ed4cc 100644 --- a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java +++ b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java @@ -161,24 +161,12 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T> } @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override public Registration addBlurListener(BlurListener listener) { return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override protected List<T> readItems(Element design, DesignContext context) { setItemEnabledProvider(new DeclarativeItemEnabledProvider<>()); return super.readItems(design, context); diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index 093c5e9c7a..036d4bec1e 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -332,23 +332,11 @@ public class ComboBox<T> extends AbstractSingleSelect<T> } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override public Registration addFocusListener(FocusListener listener) { return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } - @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - /** * Returns the page length of the suggestion popup. * diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java index b376979678..e7678b7515 100644 --- a/server/src/main/java/com/vaadin/ui/NativeSelect.java +++ b/server/src/main/java/com/vaadin/ui/NativeSelect.java @@ -104,24 +104,12 @@ public class NativeSelect<T> extends AbstractSingleSelect<T> } @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override public Registration addBlurListener(BlurListener listener) { return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override protected NativeSelectState getState() { return getState(true); } diff --git a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java index 325efd0457..0f3bd43c98 100644 --- a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java +++ b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java @@ -230,24 +230,12 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T> } @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override public Registration addBlurListener(BlurListener listener) { return addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, BlurListener.blurMethod); } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override protected List<T> readItems(Element design, DesignContext context) { setItemEnabledProvider(new DeclarativeItemEnabledProvider<>()); return super.readItems(design, context); diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java index 396c4975c1..58d67edc16 100644 --- a/server/src/main/java/com/vaadin/ui/TabSheet.java +++ b/server/src/main/java/com/vaadin/ui/TabSheet.java @@ -1369,24 +1369,12 @@ public class TabSheet extends AbstractComponentContainer } @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override public Registration addFocusListener(FocusListener listener) { return addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, FocusListener.focusMethod); } @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override public boolean isRendered(Component childComponent) { return childComponent == getSelectedTab(); } diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java index 028c585863..c3a66a6c18 100644 --- a/server/src/main/java/com/vaadin/ui/Window.java +++ b/server/src/main/java/com/vaadin/ui/Window.java @@ -1170,12 +1170,6 @@ public class Window extends Panel FocusListener.focusMethod); } - @Override - @Deprecated - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - /* * (non-Javadoc) * @@ -1189,12 +1183,6 @@ public class Window extends Panel BlurListener.blurMethod); } - @Override - @Deprecated - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - /** * {@inheritDoc} * diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java index 6fbb489c1f..7089a2e810 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTest.java @@ -249,25 +249,31 @@ public abstract class AbstractComponentTest<T extends AbstractComponent> extends protected Command<T, Boolean> focusListenerCommand = new Command<T, Boolean>() { + private Registration focusListenerRegistration; + @Override public void execute(T c, Boolean value, Object data) { - FocusNotifier fn = (FocusNotifier) c; + FocusNotifier focusNotifier = (FocusNotifier) c; if (value) { - fn.addFocusListener(AbstractComponentTest.this); - } else { - fn.removeFocusListener(AbstractComponentTest.this); + focusListenerRegistration = focusNotifier + .addFocusListener(AbstractComponentTest.this); + } else if (focusListenerRegistration != null) { + focusListenerRegistration.remove(); } } }; protected Command<T, Boolean> blurListenerCommand = new Command<T, Boolean>() { + private Registration blurListenerRegistration; + @Override public void execute(T c, Boolean value, Object data) { BlurNotifier bn = (BlurNotifier) c; if (value) { - bn.addBlurListener(AbstractComponentTest.this); - } else { - bn.removeBlurListener(AbstractComponentTest.this); + blurListenerRegistration = bn + .addBlurListener(AbstractComponentTest.this); + } else if (blurListenerRegistration != null) { + blurListenerRegistration.remove(); } } }; |