diff options
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; } |