summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-08-25 10:32:41 +0300
committerArtur Signell <artur@vaadin.com>2016-08-25 10:46:06 +0300
commit848b877d479b704280814509335b1bd0814af2df (patch)
tree15609274db8ee2334609850525c247b03e59a5dc /client
parent082929fbdf06374fd6208284be7cc144a75f1cd9 (diff)
downloadvaadin-framework-848b877d479b704280814509335b1bd0814af2df.tar.gz
vaadin-framework-848b877d479b704280814509335b1bd0814af2df.zip
Cleanup of TextField
Change-Id: Ia596f58bb0c44e2d70ccf2c0add95d86b33afdcb
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/textfield/TextFieldConnector.java55
1 files changed, 22 insertions, 33 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/textfield/TextFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/textfield/TextFieldConnector.java
index 794160beec..aec7b0f3d5 100644
--- a/client/src/main/java/com/vaadin/client/ui/textfield/TextFieldConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/textfield/TextFieldConnector.java
@@ -17,59 +17,44 @@
package com.vaadin.client.ui.textfield;
import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Timer;
import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.event.InputEvent;
-import com.vaadin.client.event.InputHandler;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.ConnectorFocusAndBlurHandler;
import com.vaadin.client.ui.VTextField;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
-import com.vaadin.shared.ui.textfield.TextFieldServerRpc;
+import com.vaadin.shared.ui.textfield.AbstractTextFieldServerRpc;
import com.vaadin.shared.ui.textfield.TextFieldState;
import com.vaadin.shared.ui.textfield.ValueChangeMode;
import com.vaadin.ui.TextField;
+/**
+ * Connector class for TextField.
+ */
@Connect(value = TextField.class, loadStyle = LoadStyle.EAGER)
public class TextFieldConnector extends AbstractComponentConnector {
+ private Timer valueChangeTrigger = new Timer() {
+ @Override
+ public void run() {
+ Scheduler.get().scheduleDeferred(() -> sendValueChange());
+ }
+ };
+
@Override
protected void init() {
ConnectorFocusAndBlurHandler.addHandlers(this);
- getWidget().addChangeHandler(new ChangeHandler() {
-
- @Override
- public void onChange(ChangeEvent event) {
- sendValueChange();
- }
- });
- getWidget().addDomHandler(new InputHandler() {
-
- @Override
- public void onInput(InputEvent event) {
- if (getState().valueChangeMode != ValueChangeMode.BLUR) {
- scheduleValueChange();
- }
+ getWidget().addChangeHandler(event -> sendValueChange());
+ getWidget().addDomHandler(event -> {
+ if (getState().valueChangeMode != ValueChangeMode.BLUR) {
+ scheduleValueChange();
}
}, InputEvent.getType());
}
- private Timer valueChangeTrigger = new Timer() {
- @Override
- public void run() {
- Scheduler.get().scheduleDeferred(new Command() {
- @Override
- public void execute() {
- sendValueChange();
- }
- });
- }
- };
-
private void scheduleValueChange() {
switch (getState().valueChangeMode) {
case LAZY:
@@ -81,6 +66,9 @@ public class TextFieldConnector extends AbstractComponentConnector {
case EAGER:
eagerTextChange();
break;
+ case BLUR:
+ // Nothing to schedule for this mode
+ break;
}
}
@@ -89,8 +77,9 @@ public class TextFieldConnector extends AbstractComponentConnector {
}
private void timeoutTextChange() {
- if (valueChangeTrigger.isRunning())
+ if (valueChangeTrigger.isRunning()) {
return;
+ }
valueChangeTrigger.schedule(getState().valueChangeTimeout);
}
@@ -147,8 +136,8 @@ public class TextFieldConnector extends AbstractComponentConnector {
if (!hasStateChanged()) {
return;
}
- getRpcProxy(TextFieldServerRpc.class).setText(getWidget().getValue(),
- getWidget().getCursorPos());
+ getRpcProxy(AbstractTextFieldServerRpc.class)
+ .setText(getWidget().getValue(), getWidget().getCursorPos());
getState().text = getWidget().getValue();
getState().cursorPosition = getWidget().getCursorPos();
}