From 78a5468279ddc442ac64d045f5fe4aa79ed9ef6e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 1 Sep 2016 14:56:41 +0300 Subject: Implement new RichTextArea Change-Id: I6f430c77caaad6d610133f340eba960f2268897e --- .../java/com/vaadin/shared/ui/ValueChangeMode.java | 51 +++++++++++++++++++++ .../ui/richtextarea/RichTextAreaClientRpc.java | 29 ++++++++++++ .../ui/richtextarea/RichTextAreaServerRpc.java | 33 ++++++++++++++ .../shared/ui/richtextarea/RichTextAreaState.java | 52 ++++++++++++++++++++++ .../ui/textfield/AbstractTextFieldState.java | 1 + .../shared/ui/textfield/ValueChangeMode.java | 51 --------------------- 6 files changed, 166 insertions(+), 51 deletions(-) create mode 100644 shared/src/main/java/com/vaadin/shared/ui/ValueChangeMode.java create mode 100644 shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaClientRpc.java create mode 100644 shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaServerRpc.java create mode 100644 shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaState.java delete mode 100644 shared/src/main/java/com/vaadin/shared/ui/textfield/ValueChangeMode.java (limited to 'shared') diff --git a/shared/src/main/java/com/vaadin/shared/ui/ValueChangeMode.java b/shared/src/main/java/com/vaadin/shared/ui/ValueChangeMode.java new file mode 100644 index 0000000000..00c7f2c548 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/ValueChangeMode.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2016 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; + +/** + * 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 +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaClientRpc.java b/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaClientRpc.java new file mode 100644 index 0000000000..34c7e750db --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaClientRpc.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2016 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.richtextarea; + +import com.vaadin.shared.communication.ClientRpc; + +/** + * Server to client RPC interface for RichTextArea. + */ +public interface RichTextAreaClientRpc extends ClientRpc { + + /** + * Selects everything in the field. + */ + void selectAll(); +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaServerRpc.java b/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaServerRpc.java new file mode 100644 index 0000000000..f8d6d9121d --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaServerRpc.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2016 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.richtextarea; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * Client to server RPC interface for RichTextArea. + * + */ +public interface RichTextAreaServerRpc extends ServerRpc { + + /** + * Sends the updated text to the server. + * + * @param text + * the text in the field + */ + void setText(String text); +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaState.java b/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaState.java new file mode 100644 index 0000000000..75ce561ec3 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/richtextarea/RichTextAreaState.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2016 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.richtextarea; + +import com.vaadin.shared.AbstractFieldState; +import com.vaadin.shared.annotations.DelegateToWidget; +import com.vaadin.shared.annotations.NoLayout; +import com.vaadin.shared.ui.ValueChangeMode; + +/** + * State for RichTextArea. + * + */ +public class RichTextAreaState extends AbstractFieldState { + { + primaryStyleName = "v-richtextarea"; + } + + /** + * Maximum character count in text field. + */ + @DelegateToWidget + @NoLayout + public int maxLength = -1; + + /** + * The text in the field. + */ + @DelegateToWidget + @NoLayout + public String value = ""; + + @NoLayout + public ValueChangeMode valueChangeMode = ValueChangeMode.LAZY; + + @NoLayout + public int valueChangeTimeout = 400; + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java index 2eac070b5e..2e7b60d463 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java @@ -18,6 +18,7 @@ package com.vaadin.shared.ui.textfield; import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.annotations.NoLayout; +import com.vaadin.shared.ui.ValueChangeMode; /** * State class for AbstractTextField. 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 deleted file mode 100644 index 39b1bb668a..0000000000 --- a/shared/src/main/java/com/vaadin/shared/ui/textfield/ValueChangeMode.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2000-2016 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 -} -- cgit v1.2.3