diff options
author | Artur Signell <artur@vaadin.com> | 2016-08-25 10:32:41 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-08-25 10:46:06 +0300 |
commit | 848b877d479b704280814509335b1bd0814af2df (patch) | |
tree | 15609274db8ee2334609850525c247b03e59a5dc /server/src/main/java/com/vaadin/ui/AbstractTextField.java | |
parent | 082929fbdf06374fd6208284be7cc144a75f1cd9 (diff) | |
download | vaadin-framework-848b877d479b704280814509335b1bd0814af2df.tar.gz vaadin-framework-848b877d479b704280814509335b1bd0814af2df.zip |
Cleanup of TextField
Change-Id: Ia596f58bb0c44e2d70ccf2c0add95d86b33afdcb
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/AbstractTextField.java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/AbstractTextField.java | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractTextField.java b/server/src/main/java/com/vaadin/ui/AbstractTextField.java index d265ddf89e..f6e31d6da3 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractTextField.java +++ b/server/src/main/java/com/vaadin/ui/AbstractTextField.java @@ -26,7 +26,7 @@ import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.shared.Registration; -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.declarative.DesignAttributeHandler; @@ -40,30 +40,31 @@ import com.vaadin.ui.declarative.DesignContext; */ public abstract class AbstractTextField extends AbstractField<String> { + private final class TextFieldServerRpcImpl + implements AbstractTextFieldServerRpc { + @Override + public void blur() { + fireEvent(new BlurEvent(AbstractTextField.this)); + } + + @Override + public void focus() { + fireEvent(new FocusEvent(AbstractTextField.this)); + } + + @Override + public void setText(String text, int cursorPosition) { + getUI().getConnectorTracker().getDiffState(AbstractTextField.this) + .put("text", text); + getUI().getConnectorTracker().getDiffState(AbstractTextField.this) + .put("cursorPosition", cursorPosition); + getState(false).cursorPosition = cursorPosition; + setValue(text, true); + } + } + protected AbstractTextField() { - registerRpc(new TextFieldServerRpc() { - - @Override - public void blur() { - fireEvent(new BlurEvent(AbstractTextField.this)); - } - - @Override - public void focus() { - fireEvent(new FocusEvent(AbstractTextField.this)); - } - - @Override - public void setText(String text, int cursorPosition) { - getUI().getConnectorTracker() - .getDiffState(AbstractTextField.this).put("text", text); - getUI().getConnectorTracker() - .getDiffState(AbstractTextField.this) - .put("cursorPosition", cursorPosition); - getState(false).cursorPosition = cursorPosition; - setValue(text, true); - } - }); + registerRpc(new TextFieldServerRpcImpl()); } @Override @@ -261,9 +262,10 @@ public abstract class AbstractTextField extends AbstractField<String> { * @see ValueChangeMode */ public void setValueChangeTimeout(int timeout) { - if (timeout < 0) + if (timeout < 0) { throw new IllegalArgumentException( "Timeout must be greater than 0"); + } getState().valueChangeTimeout = timeout; } |