summaryrefslogtreecommitdiffstats
path: root/shared
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-08-08 13:41:56 +0300
committerVaadin Code Review <review@vaadin.com>2016-08-17 07:31:03 +0000
commita5575a9252f4e502624079c65c7080e741846692 (patch)
tree739061425eef0a9ce3e1de714b5590300b1eb4fd /shared
parent93d7a0d962d100ee807089a76d57d0621a238108 (diff)
downloadvaadin-framework-a5575a9252f4e502624079c65c7080e741846692.tar.gz
vaadin-framework-a5575a9252f4e502624079c65c7080e741846692.zip
Update TextField to extend AbstractFieldNew (#51)
- Changes input prompt to be based on the placeholder attribute. - Unifies TextChangeEvents with ValueChangeEvents. - add*Listener methods now return Registration objects, remove*Listener methods removed. Change-Id: Ie92506ae9db205bb0010ae9126c608c62ad023ff
Diffstat (limited to 'shared')
-rw-r--r--shared/src/main/java/com/vaadin/shared/legacy/ui/textfield/LegacyAbstractTextFieldState.java (renamed from shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java)5
-rw-r--r--shared/src/main/java/com/vaadin/shared/legacy/ui/textfield/LegacyTextFieldConstants.java (renamed from shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldConstants.java)5
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/textarea/RichTextAreaState.java4
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaState.java4
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldServerRpc.java24
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldState.java67
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/textfield/ValueChangeMode.java51
7 files changed, 152 insertions, 8 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java b/shared/src/main/java/com/vaadin/shared/legacy/ui/textfield/LegacyAbstractTextFieldState.java
index 9d4272c22f..a91873edf4 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java
+++ b/shared/src/main/java/com/vaadin/shared/legacy/ui/textfield/LegacyAbstractTextFieldState.java
@@ -13,12 +13,13 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.shared.ui.textfield;
+package com.vaadin.shared.legacy.ui.textfield;
import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.annotations.NoLayout;
-public class AbstractTextFieldState extends AbstractFieldState {
+@Deprecated
+public class LegacyAbstractTextFieldState extends AbstractFieldState {
{
primaryStyleName = "v-textfield";
}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldConstants.java b/shared/src/main/java/com/vaadin/shared/legacy/ui/textfield/LegacyTextFieldConstants.java
index 242e53682b..1b08cf8814 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldConstants.java
+++ b/shared/src/main/java/com/vaadin/shared/legacy/ui/textfield/LegacyTextFieldConstants.java
@@ -13,11 +13,12 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.shared.ui.textfield;
+package com.vaadin.shared.legacy.ui.textfield;
import java.io.Serializable;
-public class TextFieldConstants implements Serializable {
+@Deprecated
+public class LegacyTextFieldConstants implements Serializable {
public static final String VAR_CUR_TEXT = "curText";
public static final String ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS = "nvc";
public static final String ATTR_TEXTCHANGE_TIMEOUT = "iet";
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textarea/RichTextAreaState.java b/shared/src/main/java/com/vaadin/shared/ui/textarea/RichTextAreaState.java
index 51c386ddfc..35a0945939 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/textarea/RichTextAreaState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/textarea/RichTextAreaState.java
@@ -15,7 +15,7 @@
*/
package com.vaadin.shared.ui.textarea;
-import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
+import com.vaadin.shared.legacy.ui.textfield.LegacyAbstractTextFieldState;
/**
*
@@ -23,7 +23,7 @@ import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
*
* @since 7.6
*/
-public class RichTextAreaState extends AbstractTextFieldState {
+public class RichTextAreaState extends LegacyAbstractTextFieldState {
{
primaryStyleName = "v-richtextarea";
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaState.java b/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaState.java
index c1f9536278..c2cd2ce7aa 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaState.java
@@ -17,9 +17,9 @@ package com.vaadin.shared.ui.textarea;
import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.annotations.NoLayout;
-import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
+import com.vaadin.shared.legacy.ui.textfield.LegacyAbstractTextFieldState;
-public class TextAreaState extends AbstractTextFieldState {
+public class TextAreaState extends LegacyAbstractTextFieldState {
{
primaryStyleName = "v-textarea";
}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldServerRpc.java b/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldServerRpc.java
new file mode 100644
index 0000000000..d723004fd4
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldServerRpc.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.shared.ui.textfield;
+
+import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
+
+public interface TextFieldServerRpc extends FocusAndBlurServerRpc {
+
+ public void setText(String text, int cursorPosition);
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldState.java
new file mode 100644
index 0000000000..186bda366c
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/textfield/TextFieldState.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.shared.ui.textfield;
+
+import com.vaadin.shared.AbstractFieldState;
+import com.vaadin.shared.annotations.DelegateToWidget;
+import com.vaadin.shared.annotations.NoLayout;
+
+public class TextFieldState extends AbstractFieldState {
+ {
+ primaryStyleName = "v-textfield";
+ }
+
+ /**
+ * Maximum character count in text field.
+ */
+ @DelegateToWidget
+ @NoLayout
+ public int maxLength = -1;
+
+ /**
+ * Number of visible columns in the TextField.
+ */
+ public int columns = 0;
+
+ /**
+ * The prompt to display in an empty field. Null when disabled.
+ */
+ @DelegateToWidget
+ @NoLayout
+ public String placeholder = null;
+
+ /**
+ * The text in the field
+ */
+ @DelegateToWidget
+ @NoLayout
+ public String text = "";
+
+ @NoLayout
+ public int selectionStart = -1;
+
+ @NoLayout
+ public int selectionLength = 0;
+
+ @NoLayout
+ public int cursorPosition = 0;
+
+ @NoLayout
+ public ValueChangeMode valueChangeMode = ValueChangeMode.LAZY;
+
+ @NoLayout
+ public int valueChangeTimeout = 400;
+}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/ValueChangeMode.java b/shared/src/main/java/com/vaadin/shared/ui/textfield/ValueChangeMode.java
new file mode 100644
index 0000000000..c6e0e26592
--- /dev/null
+++ b/shared/src/main/java/com/vaadin/shared/ui/textfield/ValueChangeMode.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.shared.ui.textfield;
+
+/**
+ * Different modes for when and how often field value changes are transmitted
+ * from the client to the server.
+ */
+public enum ValueChangeMode {
+
+ /**
+ * Fires a server-side event when the field loses focus.
+ */
+ BLUR,
+
+ /**
+ * Fires a server-side event every time the client-side value changes. This
+ * gives the least latency but may cause unnecessary traffic.
+ */
+ EAGER,
+
+ /**
+ * Fires a server-side event at defined intervals as long as the value
+ * changes from one event to the next. For instance, you can use this mode
+ * to transmit a snapshot of the contents of a text area every second as
+ * long as the user keeps typing.
+ */
+ TIMEOUT,
+
+ /**
+ * On every user event, schedule a server-side event after a defined
+ * interval, cancelling the currently-scheduled event if any. This is a good
+ * choice if you want to, for instance, wait for a small break in the user's
+ * typing before sending the event.
+ */
+ LAZY
+}