aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/ui
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2016-10-26 16:22:00 +0300
committerDenis Anisimov <denis@vaadin.com>2016-10-31 14:53:57 +0200
commit25013128a7e2eb80b565d28abcc0af26219098db (patch)
tree5995aebdf009bae579caf37845d5f8018bffdd98 /server/src/main/java/com/vaadin/ui
parentc276c9d02ef96162d4076045ba56ed342375f4ed (diff)
downloadvaadin-framework-25013128a7e2eb80b565d28abcc0af26219098db.tar.gz
vaadin-framework-25013128a7e2eb80b565d28abcc0af26219098db.zip
Implement focus/blur listeners for NativeSelect.
Fixes vaadin/framework8-issues#332 Change-Id: I19996ea83ed1fbe2b115d92d6be5e6a5e158f283
Diffstat (limited to 'server/src/main/java/com/vaadin/ui')
-rw-r--r--server/src/main/java/com/vaadin/ui/NativeSelect.java44
1 files changed, 41 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java
index be4cbc5e12..bb3ae41df4 100644
--- a/server/src/main/java/com/vaadin/ui/NativeSelect.java
+++ b/server/src/main/java/com/vaadin/ui/NativeSelect.java
@@ -18,7 +18,15 @@ package com.vaadin.ui;
import java.util.Collection;
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.BlurNotifier;
+import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcDecorator;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.server.data.DataSource;
+import com.vaadin.shared.Registration;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.ui.nativeselect.NativeSelectState;
@@ -34,14 +42,16 @@ import com.vaadin.shared.ui.nativeselect.NativeSelectState;
*
* @see com.vaadin.ui.ComboBox
*/
-public class NativeSelect<T> extends AbstractSingleSelect<T> {
+public class NativeSelect<T> extends AbstractSingleSelect<T>
+ implements FocusNotifier, BlurNotifier {
/**
* Creates a new {@code NativeSelect} with an empty caption and no items.
*/
public NativeSelect() {
- addDataGenerator((item, json) -> json.put(
- DataCommunicatorConstants.DATA, String.valueOf(item)));
+ registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
+ addDataGenerator((item, json) -> json
+ .put(DataCommunicatorConstants.DATA, String.valueOf(item)));
setSelectionModel(new SimpleSingleSelection());
}
@@ -86,6 +96,34 @@ public class NativeSelect<T> extends AbstractSingleSelect<T> {
}
@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);
+ }
+
+ @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);
+ }
+
+ @Override
protected NativeSelectState getState() {
return getState(true);
}