diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2016-08-10 14:18:47 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-08-26 07:49:25 +0000 |
commit | 4a6a632b1f57a1ddbb437036cb5d17f98f827b47 (patch) | |
tree | 0a2091302a829adcfe86fd4d77545a271fa5c0b6 | |
parent | 24a888a2d1dc198d1d88c9e0dbdde1cfe8b0a7f1 (diff) | |
download | vaadin-framework-4a6a632b1f57a1ddbb437036cb5d17f98f827b47.tar.gz vaadin-framework-4a6a632b1f57a1ddbb437036cb5d17f98f827b47.zip |
Update TextArea to extend AbstractFieldNew (#53)
Change-Id: I72400695f3b015add07be9709e48b5f99ce619cf
37 files changed, 713 insertions, 174 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VTextArea.java b/client/src/main/java/com/vaadin/client/ui/VTextArea.java new file mode 100644 index 0000000000..c63fbda38c --- /dev/null +++ b/client/src/main/java/com/vaadin/client/ui/VTextArea.java @@ -0,0 +1,107 @@ +/* + * 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.client.ui; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Style.Overflow; +import com.google.gwt.dom.client.Style.WhiteSpace; +import com.google.gwt.dom.client.TextAreaElement; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.user.client.DOM; +import com.vaadin.client.BrowserInfo; +import com.vaadin.client.WidgetUtil; +import com.vaadin.client.ui.dd.DragImageModifier; + +/** + * This class represents a multiline textfield (textarea). + * + * @author Vaadin Ltd. + * + */ +public class VTextArea extends VTextField implements DragImageModifier { + + public static final String CLASSNAME = "v-textarea"; + + private EnterDownHandler enterDownHandler = new EnterDownHandler(); + private boolean wordWrap = true; + + private class EnterDownHandler implements KeyDownHandler { + @Override + public void onKeyDown(KeyDownEvent event) { + // Fix for #12424/13811 - if the key being pressed is enter, we stop + // propagation of the KeyDownEvents if there were no modifier keys + // also pressed. This prevents shortcuts that are bound to only the + // enter key from being processed but allows usage of e.g. + // shift-enter or ctrl-enter. + if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER + && !event.isAnyModifierKeyDown()) { + event.stopPropagation(); + } + } + } + + public VTextArea() { + super(DOM.createTextArea()); + setStyleName(CLASSNAME); + addKeyDownHandler(enterDownHandler); + } + + public TextAreaElement getTextAreaElement() { + return super.getElement().cast(); + } + + public void setRows(int rows) { + getTextAreaElement().setRows(rows); + } + + public void setWordWrap(boolean wordWrap) { + if (wordWrap == this.wordWrap) { + return; + } + if (wordWrap) { + getElement().removeAttribute("wrap"); + getElement().getStyle().clearOverflow(); + getElement().getStyle().clearWhiteSpace(); + } else { + getElement().setAttribute("wrap", "off"); + getElement().getStyle().setOverflow(Overflow.AUTO); + getElement().getStyle().setWhiteSpace(WhiteSpace.PRE); + } + if (BrowserInfo.get().isOpera() + || (BrowserInfo.get().isWebkit() && wordWrap)) { + // Opera fails to dynamically update the wrap attribute so we detach + // and reattach the whole TextArea. + // Webkit fails to properly reflow the text when enabling wrapping, + // same workaround + WidgetUtil.detachAttach(getElement()); + } + this.wordWrap = wordWrap; + } + + @Override + public void modifyDragImage(Element element) { + // Fix for #13557 - drag image doesn't show original text area text. + // It happens because "value" property is not copied into the cloned + // element + String value = getElement().getPropertyString("value"); + if (value != null) { + element.setPropertyString("value", value); + } + } +} diff --git a/client/src/main/java/com/vaadin/client/ui/textarea/TextAreaConnector.java b/client/src/main/java/com/vaadin/client/ui/textarea/TextAreaConnector.java new file mode 100644 index 0000000000..9ad4c8b277 --- /dev/null +++ b/client/src/main/java/com/vaadin/client/ui/textarea/TextAreaConnector.java @@ -0,0 +1,75 @@ +/* + * 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.client.ui.textarea; + +import com.google.gwt.dom.client.Style; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.vaadin.client.ui.VTextArea; +import com.vaadin.client.ui.textfield.TextFieldConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.textarea.TextAreaServerRpc; +import com.vaadin.shared.ui.textarea.TextAreaState; +import com.vaadin.ui.TextArea; + +@Connect(TextArea.class) +public class TextAreaConnector extends TextFieldConnector { + + @Override + public TextAreaState getState() { + return (TextAreaState) super.getState(); + } + + @Override + public VTextArea getWidget() { + return (VTextArea) super.getWidget(); + } + + @Override + protected void init() { + super.init(); + getWidget().addMouseUpHandler(new ResizeMouseUpHandler()); + } + + /* + * Workaround to handle the resize on the mouse up. + */ + private class ResizeMouseUpHandler implements MouseUpHandler { + + @Override + public void onMouseUp(MouseUpEvent event) { + Style elementStyle = getWidget().getElement().getStyle(); + + String newHeight = elementStyle.getHeight(); + String newWidth = elementStyle.getWidth(); + + if (newHeight == null) { + newHeight = ""; + } + if (newWidth == null) { + newWidth = ""; + } + + if (!newHeight.equals(getState().height)) { + getRpcProxy(TextAreaServerRpc.class).setHeight(newHeight); + } + if (!newWidth.equals(getState().width)) { + getRpcProxy(TextAreaServerRpc.class).setWidth(newWidth); + } + } + } +} 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 2c1c64b633..46e02c18ee 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 @@ -13,7 +13,6 @@ * License for the specific language governing permissions and limitations under * the License. */ - package com.vaadin.client.ui.textfield; import com.google.gwt.core.client.Scheduler; diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java index bb79a852cf..38f538fbdf 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java @@ -13,7 +13,6 @@ * License for the specific language governing permissions and limitations under * the License. */ - package com.vaadin.v7.client.ui; import com.google.gwt.core.client.Scheduler; @@ -45,6 +44,7 @@ import com.vaadin.client.v7.ui.VLegacyTextField; * @author Vaadin Ltd. * */ +@Deprecated public class VTextArea extends VLegacyTextField implements DragImageModifier { public static final String CLASSNAME = "v-textarea"; @@ -335,4 +335,3 @@ public class VTextArea extends VLegacyTextField implements DragImageModifier { } } } - diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textarea/TextAreaConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textarea/TextAreaConnector.java index 81c9949af9..61d86dee14 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textarea/TextAreaConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/textarea/TextAreaConnector.java @@ -22,8 +22,8 @@ import com.google.gwt.event.dom.client.MouseUpHandler; import com.vaadin.client.WidgetUtil.CssSize; import com.vaadin.client.v7.ui.textfield.LegacyTextFieldConnector; import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.textarea.TextAreaState; import com.vaadin.v7.client.ui.VTextArea; +import com.vaadin.v7.shared.ui.textarea.TextAreaState; import com.vaadin.v7.ui.TextArea; @Connect(TextArea.class) diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TextArea.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TextArea.java index e4cd20a59b..852dd76c2c 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TextArea.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TextArea.java @@ -18,7 +18,7 @@ package com.vaadin.v7.ui; import org.jsoup.nodes.Element; -import com.vaadin.shared.ui.textarea.TextAreaState; +import com.vaadin.shared.v7.ui.textarea.LegacyTextAreaState; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.DesignFormatter; import com.vaadin.v7.data.Property; @@ -85,13 +85,13 @@ public class TextArea extends AbstractTextField { } @Override - protected TextAreaState getState() { - return (TextAreaState) super.getState(); + protected LegacyTextAreaState getState() { + return (LegacyTextAreaState) super.getState(); } @Override - protected TextAreaState getState(boolean markAsDirty) { - return (TextAreaState) super.getState(markAsDirty); + protected LegacyTextAreaState getState(boolean markAsDirty) { + return (LegacyTextAreaState) super.getState(markAsDirty); } /** diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/textarea/TextAreaState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/textarea/TextAreaState.java new file mode 100644 index 0000000000..8735136085 --- /dev/null +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/textarea/TextAreaState.java @@ -0,0 +1,41 @@ +/* + * 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.v7.shared.ui.textarea; + +import com.vaadin.shared.annotations.DelegateToWidget; +import com.vaadin.shared.annotations.NoLayout; +import com.vaadin.shared.v7.ui.textfield.LegacyAbstractTextFieldState; + +@Deprecated +public class TextAreaState extends LegacyAbstractTextFieldState { + { + primaryStyleName = "v-textarea"; + } + + /** + * Number of visible rows in the text area. The default is 5. + */ + @DelegateToWidget + public int rows = 5; + + /** + * Tells if word-wrapping should be used in the text area. + */ + @DelegateToWidget + @NoLayout + public boolean wordwrap = true; + +} diff --git a/server/src/main/java/com/vaadin/ui/AbstractTextField.java b/server/src/main/java/com/vaadin/ui/AbstractTextField.java index 8043766a11..75c2067759 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractTextField.java +++ b/server/src/main/java/com/vaadin/ui/AbstractTextField.java @@ -26,6 +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.communication.FieldRpc.FocusAndBlurServerRpc; import com.vaadin.shared.ui.textfield.AbstractTextFieldClientRpc; import com.vaadin.shared.ui.textfield.AbstractTextFieldServerRpc; import com.vaadin.shared.ui.textfield.TextFieldState; @@ -43,6 +44,18 @@ public abstract class AbstractTextField extends AbstractField<String> { private final class TextFieldServerRpcImpl implements AbstractTextFieldServerRpc { + + @Override + public void setText(String text, int cursorPosition) { + getUI().getConnectorTracker().getDiffState(AbstractTextField.this) + .put("text", text); + lastKnownCursorPosition = cursorPosition; + setValue(text, true); + } + } + + private final class TextFieldFocusAndBlurRpcImpl + implements FocusAndBlurServerRpc { @Override public void blur() { fireEvent(new BlurEvent(AbstractTextField.this)); @@ -52,14 +65,6 @@ public abstract class AbstractTextField extends AbstractField<String> { public void focus() { fireEvent(new FocusEvent(AbstractTextField.this)); } - - @Override - public void setText(String text, int cursorPosition) { - getUI().getConnectorTracker().getDiffState(AbstractTextField.this) - .put("text", text); - lastKnownCursorPosition = cursorPosition; - setValue(text, true); - } } private int lastKnownCursorPosition = -1; @@ -69,6 +74,7 @@ public abstract class AbstractTextField extends AbstractField<String> { */ protected AbstractTextField() { registerRpc(new TextFieldServerRpcImpl()); + registerRpc(new TextFieldFocusAndBlurRpcImpl()); } @Override diff --git a/server/src/main/java/com/vaadin/ui/TextArea.java b/server/src/main/java/com/vaadin/ui/TextArea.java new file mode 100644 index 0000000000..e1b939d1c8 --- /dev/null +++ b/server/src/main/java/com/vaadin/ui/TextArea.java @@ -0,0 +1,138 @@ +/* + * 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.ui; + +import org.jsoup.nodes.Element; + +import com.vaadin.shared.ui.textarea.TextAreaServerRpc; +import com.vaadin.shared.ui.textarea.TextAreaState; +import com.vaadin.ui.declarative.DesignContext; +import com.vaadin.ui.declarative.DesignFormatter; + +/** + * A text field that supports multi line editing. + */ +public class TextArea extends AbstractTextField { + + /** + * Constructs an empty TextArea. + */ + public TextArea() { + registerRpc(new TextAreaServerRpc() { + + @Override + public void setHeight(String height) { + TextArea.this.setHeight(height); + } + + @Override + public void setWidth(String width) { + TextArea.this.setWidth(width); + } + }); + clear(); + } + + /** + * Constructs an empty TextArea with given caption. + * + * @param caption + * the caption for the field. + */ + public TextArea(String caption) { + this(); + setCaption(caption); + } + + /** + * Constructs a TextArea with given caption and value. + * + * @param caption + * the caption for the field + * @param value + * the value for the field + */ + public TextArea(String caption, String value) { + this(caption); + setValue(value); + + } + + @Override + protected TextAreaState getState() { + return (TextAreaState) super.getState(); + } + + @Override + protected TextAreaState getState(boolean markAsDirty) { + return (TextAreaState) super.getState(markAsDirty); + } + + /** + * Sets the number of rows in the text area. + * + * @param rows + * the number of rows for this text area. + */ + public void setRows(int rows) { + if (rows < 0) { + rows = 0; + } + getState().rows = rows; + } + + /** + * Gets the number of rows in the text area. + * + * @return number of explicitly set rows. + */ + public int getRows() { + return getState(false).rows; + } + + /** + * Sets the text area's word-wrap mode on or off. + * + * @param wordWrap + * <code>true</code> to use word-wrap mode <code>false</code> + * otherwise. + */ + public void setWordWrap(boolean wordWrap) { + getState().wordWrap = wordWrap; + } + + /** + * Tests if the text area is in word-wrap mode. + * + * @return <code>true</code> if the component is in word-wrap mode, + * <code>false</code> if not. + */ + public boolean isWordWrap() { + return getState(false).wordWrap; + } + + @Override + public void readDesign(Element design, DesignContext designContext) { + super.readDesign(design, designContext); + doSetValue(DesignFormatter.decodeFromTextNode(design.html())); + } + + @Override + public void writeDesign(Element design, DesignContext designContext) { + super.writeDesign(design, designContext); + design.html(DesignFormatter.encodeForTextNode(getValue())); + } +} diff --git a/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java new file mode 100644 index 0000000000..1b6df09c19 --- /dev/null +++ b/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java @@ -0,0 +1,74 @@ +/* + * 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.tests.server.component.textarea; + +import java.io.IOException; + +import org.jsoup.nodes.Element; +import org.jsoup.parser.Tag; +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.declarative.DesignContext; + +/** + * Tests declarative support for implementations of {@link TextArea}. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> { + + @Test + public void testTextArea() { + String design = "<vaadin-text-area rows=6 word-wrap=false>Hello World!</vaadin-text-area>"; + TextArea ta = new TextArea(); + ta.setRows(6); + ta.setWordWrap(false); + ta.setValue("Hello World!"); + testRead(design, ta); + testWrite(design, ta); + } + + @Test + public void testHtmlEntities() throws IOException { + String design = "<vaadin-text-area>& Test</vaadin-text-area>"; + TextArea read = read(design); + Assert.assertEquals("& Test", read.getValue()); + + read.setValue("& Test"); + + DesignContext dc = new DesignContext(); + Element root = new Element(Tag.valueOf("vaadin-text-area"), ""); + read.writeDesign(root, dc); + + Assert.assertEquals("&amp; Test", root.html()); + } + + @Test + public void testReadOnlyValue() { + String design = "<vaadin-text-area readonly rows=6 word-wrap=false>Hello World!</vaadin-text-area>"; + TextArea ta = new TextArea(); + ta.setRows(6); + ta.setWordWrap(false); + ta.setValue("Hello World!"); + ta.setReadOnly(true); + testRead(design, ta); + testWrite(design, ta); + } +} diff --git a/server/src/test/java/com/vaadin/ui/TextAreaTest.java b/server/src/test/java/com/vaadin/ui/TextAreaTest.java new file mode 100644 index 0000000000..6c3d5fecd5 --- /dev/null +++ b/server/src/test/java/com/vaadin/ui/TextAreaTest.java @@ -0,0 +1,37 @@ +/* + * 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.ui; + +import org.junit.Assert; +import org.junit.Test; + +public class TextAreaTest { + @Test + public void initiallyEmpty() { + TextArea textArea = new TextArea(); + Assert.assertTrue(textArea.isEmpty()); + } + + @Test + public void emptyAfterClear() { + TextArea textArea = new TextArea(); + textArea.setValue("foobar"); + Assert.assertFalse(textArea.isEmpty()); + textArea.clear(); + Assert.assertTrue(textArea.isEmpty()); + } + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaServerRpc.java b/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaServerRpc.java new file mode 100644 index 0000000000..d7a1388ef8 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/textarea/TextAreaServerRpc.java @@ -0,0 +1,25 @@ +/* + * 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.textarea; + +import com.vaadin.shared.communication.ServerRpc; + +public interface TextAreaServerRpc extends ServerRpc { + + public void setHeight(String height); + + public void setWidth(String width); +} 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 cd4ea10519..a56b45ea7e 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.v7.ui.textfield.LegacyAbstractTextFieldState; +import com.vaadin.shared.ui.textfield.TextFieldState; -public class TextAreaState extends LegacyAbstractTextFieldState { +public class TextAreaState extends TextFieldState { { primaryStyleName = "v-textarea"; } @@ -35,6 +35,5 @@ public class TextAreaState extends LegacyAbstractTextFieldState { */ @DelegateToWidget @NoLayout - public boolean wordwrap = true; - + public boolean wordWrap = true; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldServerRpc.java b/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldServerRpc.java index 3c1e77fa30..e11d4cedec 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldServerRpc.java +++ b/shared/src/main/java/com/vaadin/shared/ui/textfield/AbstractTextFieldServerRpc.java @@ -13,12 +13,11 @@ * 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; +import com.vaadin.shared.communication.ServerRpc; -public interface AbstractTextFieldServerRpc extends FocusAndBlurServerRpc { +public interface AbstractTextFieldServerRpc extends ServerRpc { void setText(String text, int cursorPosition); } diff --git a/shared/src/main/java/com/vaadin/shared/v7/ui/textarea/LegacyTextAreaState.java b/shared/src/main/java/com/vaadin/shared/v7/ui/textarea/LegacyTextAreaState.java new file mode 100644 index 0000000000..a3aa758499 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/v7/ui/textarea/LegacyTextAreaState.java @@ -0,0 +1,41 @@ +/* + * 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.v7.ui.textarea; + +import com.vaadin.shared.annotations.DelegateToWidget; +import com.vaadin.shared.annotations.NoLayout; +import com.vaadin.shared.v7.ui.textfield.LegacyAbstractTextFieldState; + +@Deprecated +public class LegacyTextAreaState extends LegacyAbstractTextFieldState { + { + primaryStyleName = "v-textarea"; + } + + /** + * Number of visible rows in the text area. The default is 5. + */ + @DelegateToWidget + public int rows = 5; + + /** + * Tells if word-wrapping should be used in the text area. + */ + @DelegateToWidget + @NoLayout + public boolean wordwrap = true; + +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtain.java b/uitest/src/main/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtain.java index fd0c372da7..bb51bc4d64 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtain.java +++ b/uitest/src/main/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtain.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.components.draganddropwrapper; +import com.vaadin.data.HasValue.ValueChangeListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.dd.DragAndDropEvent; @@ -23,15 +24,13 @@ import com.vaadin.event.dd.acceptcriteria.AcceptAll; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.AbstractTextField; import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper.DragStartMode; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.ui.AbstractField; -import com.vaadin.v7.ui.TextArea; -import com.vaadin.v7.ui.TextField; /** * Test UI for text area inside {@link DragAndDropWrapper}: text area should @@ -47,16 +46,12 @@ public class DragAndDropFocusObtain extends AbstractTestUIWithLog { @Override public void focus(FocusEvent event) { log("Field '" + event.getComponent().getCaption() + "' focused"); - } }; - private ValueChangeListener listener = new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - AbstractField f = (AbstractField) event.getProperty(); - log("Value of " + f.getCaption() + " changed to " + f.getValue()); - } + private ValueChangeListener<String> listener = event -> { + log("Value of " + ((AbstractTextField) event.getSource()).getCaption() + + " changed to " + event.getValue()); }; @Override @@ -89,29 +84,29 @@ public class DragAndDropFocusObtain extends AbstractTestUIWithLog { private VerticalLayout createLayout() { VerticalLayout dndLayout = new VerticalLayout(); - TextArea area = new TextArea("Text area 1"); + final TextArea area = new TextArea("Text area 1"); area.setValue("text"); area.addValueChangeListener(listener); area.addFocusListener(focusListener); dndLayout.addComponent(area); - area = new TextArea("Text area 2"); - area.setValue("text"); - area.addValueChangeListener(listener); - area.addFocusListener(focusListener); - dndLayout.addComponent(area); + final TextArea area2 = new TextArea("Text area 2"); + area2.setValue("text"); + area2.addValueChangeListener(listener); + area2.addFocusListener(focusListener); + dndLayout.addComponent(area2); - TextField field = new TextField("Text field 1"); + final TextField field = new TextField("Text field 1"); field.setValue("text"); field.addValueChangeListener(listener); field.addFocusListener(focusListener); dndLayout.addComponent(field); - field = new TextField("Text field 2"); - field.setValue("text"); - field.addValueChangeListener(listener); - field.addFocusListener(focusListener); - dndLayout.addComponent(field); + final TextField field2 = new TextField("Text field 2"); + field2.setValue("text"); + field2.addValueChangeListener(listener); + field2.addFocusListener(focusListener); + dndLayout.addComponent(field2); return dndLayout; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java index f61dbb303b..a588e9c862 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/ScrollCursor.java @@ -4,7 +4,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.v7.ui.TextArea; +import com.vaadin.ui.TextArea; /** * @author denis @@ -37,7 +37,7 @@ public class ScrollCursor extends TestBase { @Override public void buttonClick(ClickEvent event) { - textArea.setWordwrap(false); + textArea.setWordWrap(false); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java index ef7a13befe..9eeab8905e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java @@ -1,20 +1,17 @@ package com.vaadin.tests.components.textarea; -import com.vaadin.event.FieldEvents.TextChangeEvent; -import com.vaadin.event.FieldEvents.TextChangeListener; +import com.vaadin.shared.ui.textfield.ValueChangeMode; import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.AbstractTextField; import com.vaadin.ui.Button; import com.vaadin.ui.Label; -import com.vaadin.v7.ui.AbstractField; -import com.vaadin.v7.ui.AbstractTextField; -import com.vaadin.v7.ui.AbstractTextField.TextChangeEventMode; -import com.vaadin.v7.ui.TextArea; -import com.vaadin.v7.ui.TextField; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; public class TextAreaCursorPosition extends TestBase { - private TextField cursorPosition = new TextField( - "Cursor position"); + private TextField cursorPosition = new TextField("Cursor position"); @Override public void setup() { @@ -31,16 +28,11 @@ public class TextAreaCursorPosition extends TestBase { public void addListener(AbstractField newField) { AbstractTextField newTextField = (AbstractTextField) newField; - newTextField.setTextChangeEventMode(TextChangeEventMode.EAGER); - - newTextField.addTextChangeListener(new TextChangeListener() { - @Override - public void textChange(TextChangeEvent event) { - AbstractTextField component = (AbstractTextField) event - .getComponent(); - cursorPosition.setValue( - String.valueOf(component.getCursorPosition())); - } + newTextField.setValueChangeMode(ValueChangeMode.EAGER); + newTextField.addValueChangeListener(event -> { + AbstractTextField component = (AbstractTextField) event.getSource(); + cursorPosition + .setValue(String.valueOf(component.getCursorPosition())); }); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java index 5fe4a4bfa6..ca858ffaeb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/TextAreaSizeResetted.java @@ -24,8 +24,8 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; +import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; -import com.vaadin.v7.ui.TextArea; /** * Ticket #14080 @@ -73,6 +73,17 @@ public class TextAreaSizeResetted extends AbstractTestUI { textArea.setWidth(TEXTAREAWIDTH + "px"); textArea.setValue("This is a text."); + Label serverHeight = new Label(); + Label text = new Label(); + textArea.addValueChangeListener( + event -> text.setValue(event.getValue())); + Button hbutton = new Button("check height", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + serverHeight.setValue(textArea.getHeight() + " "); + } + }); Button button = new Button("Change Height", new ClickListener() { @Override @@ -88,6 +99,9 @@ public class TextAreaSizeResetted extends AbstractTestUI { layout.addComponent(textField); layout.addComponent(button); layout.addComponent(pollIndicator); + layout.addComponent(hbutton); + layout.addComponent(serverHeight); + layout.addComponent(text); addPollListener(new UIEvents.PollListener() { @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/textarea/Wordwrap.java b/uitest/src/main/java/com/vaadin/tests/components/textarea/Wordwrap.java index 905e07191e..b393ff3105 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textarea/Wordwrap.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textarea/Wordwrap.java @@ -4,7 +4,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.v7.ui.TextArea; +import com.vaadin.ui.TextArea; public class Wordwrap extends TestBase { @@ -13,11 +13,11 @@ public class Wordwrap extends TestBase { HorizontalLayout layout = new HorizontalLayout(); TextArea area1 = new TextArea("Wrapping"); - area1.setWordwrap(true); // The default + area1.setWordWrap(true); // The default area1.setValue(LoremIpsum.get(50) + "\n" + "Another row"); final TextArea area2 = new TextArea("Nonwrapping"); - area2.setWordwrap(false); + area2.setWordWrap(false); area2.setValue(LoremIpsum.get(50) + "\n" + "Another row"); layout.addComponent(area1); @@ -30,7 +30,7 @@ public class Wordwrap extends TestBase { onoff.setValue(false); onoff.addValueChangeListener(event -> { boolean wrap = event.getValue(); - area2.setWordwrap(wrap); + area2.setWordWrap(wrap); if (wrap) { area2.setCaption("Wrapping"); } else { diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java index 087d9d8273..961c88374c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java @@ -6,8 +6,8 @@ import com.vaadin.shared.ui.textfield.ValueChangeMode; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.tests.util.TestUtils; +import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; -import com.vaadin.v7.ui.TextArea; public class TextChangeEvents extends TestBase { Log l = new Log(10); @@ -56,7 +56,11 @@ public class TextChangeEvents extends TestBase { getLayout().addComponent(to); TextArea ta = new TextArea("Default text area"); - ta.addTextChangeListener(inputEventListener); + ta.addValueChangeListener(listener -> { + l.log("Text change event for " + ta.getCaption() + + ", text content currently:'" + listener.getValue() + + "' Cursor at index:" + ta.getCursorPosition()); + }); getLayout().addComponent(ta); VaadinDeveloperNameField vd = new VaadinDeveloperNameField(); diff --git a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java index ad0d9b7137..e0862415f0 100644 --- a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java +++ b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeEditor.java @@ -22,13 +22,12 @@ import java.io.IOException; import org.apache.commons.io.IOUtils; import com.vaadin.annotations.Theme; -import com.vaadin.event.FieldEvents.TextChangeEvent; -import com.vaadin.event.FieldEvents.TextChangeListener; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Component; import com.vaadin.ui.HasComponents; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Panel; +import com.vaadin.ui.TextArea; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; @@ -37,7 +36,6 @@ import com.vaadin.v7.data.Property.ReadOnlyException; import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; import com.vaadin.v7.data.Property.ValueChangeNotifier; -import com.vaadin.v7.ui.TextArea; @Theme("valo") public class DeclarativeEditor extends UI { @@ -61,13 +59,9 @@ public class DeclarativeEditor extends UI { } catch (IOException e) { e.printStackTrace(); } - editor.addTextChangeListener(new TextChangeListener() { - - @Override - public void textChange(TextChangeEvent event) { - editor.setComponentError(null); - updateTree(event.getText()); - } + editor.addValueChangeListener(listener -> { + editor.setComponentError(null); + updateTree(listener.getValue()); }); Panel editorPanel = new Panel(editor); diff --git a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java index edb2188c5c..5c580b5f3d 100644 --- a/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java +++ b/uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java @@ -162,8 +162,8 @@ public class BasicPersonForm extends AbstractTestUIWithLog { addComponent(discardButton); addComponent(showBean); email.addValidator(new EmailValidator("Must be a valid address")); - lastName.addValidator(new StringLengthValidator( - "Must be min 5 chars", 5, null, true)); + lastName.addValidator(new StringLengthValidator("Must be min 5 chars", + 5, null, true)); age.addValidator(new IntegerRangeValidator( "Must be between 0 and 150, {0} is not", 0, 150)); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java b/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java index 149519ba3c..76a3dba08f 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java @@ -3,7 +3,7 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.CheckBox; import com.vaadin.ui.FormLayout; -import com.vaadin.v7.ui.TextArea; +import com.vaadin.ui.TextArea; public class FormLayoutWithInvisibleComponent extends TestBase { diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java index e8e7c2ea99..0c0670c54d 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java @@ -17,10 +17,10 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.ui.ListSelect; -import com.vaadin.v7.ui.TextArea; -import com.vaadin.v7.ui.TextField; public class OrderedLayoutBasics extends TestBase { @@ -140,8 +140,7 @@ public class OrderedLayoutBasics extends TestBase { ol.setWidth(""); ol.setCaption("Fixed height (200px) and dynamic width"); - TextField tf = new TextField( - "100px high TextField, valign: bottom"); + TextField tf = new TextField("100px high TextField, valign: bottom"); tf.setHeight("100px"); tf.setWidth(""); ol.addComponent(tf); @@ -243,8 +242,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.TOP_LEFT); - tf = new TextField( - "100% high, 50px wide TextField, valign: bottom"); + tf = new TextField("100% high, 50px wide TextField, valign: bottom"); tf.setHeight("100%"); tf.setWidth("50px"); ol.addComponent(tf); @@ -299,8 +297,7 @@ public class OrderedLayoutBasics extends TestBase { ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.TOP_LEFT); - tf = new TextField( - "100% high, 50px wide TextField, valign: bottom"); + tf = new TextField("100% high, 50px wide TextField, valign: bottom"); tf.setHeight("100%"); tf.setWidth("50px"); ol.addComponent(tf); @@ -399,6 +396,7 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth(""); ol.setCaption("Fixed width (" + ol.getWidth() + "px) and fixed height (" + ol.getHeight() + "px) / layout_field_100pct_button_field"); + TextArea tf; tf = new TextArea("300px x 300px Field"); @@ -440,6 +438,7 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth(""); ol.setCaption("Fixed width (" + ol.getWidth() + "px) and fixed height (" + ol.getHeight() + "px) / layout_basic_test"); + TextArea tf; tf = new TextArea("300px x 300px Field"); @@ -481,6 +480,7 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth(""); ol.setCaption("Fixed width (" + ol.getWidth() + "px) and fixed height (" + ol.getHeight() + "px) / layout_symmetric_fields"); + TextArea tf; tf = new TextArea("300px x 300px Field"); @@ -519,6 +519,7 @@ public class OrderedLayoutBasics extends TestBase { // ol.setWidth(""); ol.setCaption("Fixed width (" + ol.getWidth() + "px) and fixed height (" + ol.getHeight() + "px) / layout_leftAndRight"); + TextArea tf; // tf = new TextField("100%x100% Field"); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java index 0daa8a23a0..97f9d29226 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java @@ -43,15 +43,13 @@ import com.vaadin.ui.Panel; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Window.CloseEvent; import com.vaadin.ui.Window.CloseListener; import com.vaadin.ui.themes.ValoTheme; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.ui.TextArea; -import com.vaadin.v7.ui.TextField; public class CommonParts extends VerticalLayout implements View { public CommonParts() { @@ -156,33 +154,27 @@ public class CommonParts extends VerticalLayout implements View { setSpacing(true); setMargin(true); - title.setInputPrompt("Title for the notification"); - title.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (title.getValue() == null - || title.getValue().length() == 0) { - notification.setCaption(null); - } else { - notification.setCaption(title.getValue()); - } + title.setPlaceholder("Title for the notification"); + title.addValueChangeListener(event -> { + if (title.getValue() == null + || title.getValue().length() == 0) { + notification.setCaption(null); + } else { + notification.setCaption(title.getValue()); } }); title.setValue("Notification Title"); title.setWidth("100%"); addComponent(title); - description.setInputPrompt("Description for the notification"); + description.setPlaceholder("Description for the notification"); description.addStyleName(ValoTheme.TEXTAREA_SMALL); - description.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (description.getValue() == null - || description.getValue().length() == 0) { - notification.setDescription(null); - } else { - notification.setDescription(description.getValue()); - } + description.addValueChangeListener(listener -> { + if (description.getValue() == null + || description.getValue().length() == 0) { + notification.setDescription(null); + } else { + notification.setDescription(description.getValue()); } }); description.setValue( @@ -257,21 +249,17 @@ public class CommonParts extends VerticalLayout implements View { group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); addComponent(group); - delay.setInputPrompt("Infinite"); + delay.setPlaceholder("Infinite"); delay.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT); delay.addStyleName(ValoTheme.TEXTFIELD_SMALL); delay.setWidth("7em"); - delay.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - try { - notification.setDelayMsec( - Integer.parseInt(delay.getValue())); - } catch (Exception e) { - notification.setDelayMsec(-1); - delay.setValue(""); - } - + delay.addValueChangeListener(event -> { + try { + notification.setDelayMsec( + Integer.parseInt(delay.getValue())); + } catch (Exception e) { + notification.setDelayMsec(-1); + delay.setValue(""); } }); delay.setValue("1000"); diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/TextFields.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/TextFields.java index 7d924c876d..4daf6f90e0 100644 --- a/uitest/src/main/java/com/vaadin/tests/themes/valo/TextFields.java +++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/TextFields.java @@ -24,11 +24,11 @@ import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.ValoTheme; import com.vaadin.v7.ui.RichTextArea; -import com.vaadin.v7.ui.TextArea; -import com.vaadin.v7.ui.TextField; public class TextFields extends VerticalLayout implements View { private TestIcon testIcon = new TestIcon(140); @@ -46,22 +46,22 @@ public class TextFields extends VerticalLayout implements View { addComponent(row); TextField tf = new TextField("Normal"); - tf.setInputPrompt("First name"); + tf.setPlaceholder("First name"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Custom color"); - tf.setInputPrompt("Email"); + tf.setPlaceholder("Email"); tf.addStyleName("color1"); row.addComponent(tf); tf = new TextField("User Color"); - tf.setInputPrompt("Gender"); + tf.setPlaceholder("Gender"); tf.addStyleName("color2"); row.addComponent(tf); tf = new TextField("Themed"); - tf.setInputPrompt("Age"); + tf.setPlaceholder("Age"); tf.addStyleName("color3"); row.addComponent(tf); @@ -77,7 +77,7 @@ public class TextFields extends VerticalLayout implements View { row.addComponent(tf); tf = new TextField("Read-only"); - tf.setInputPrompt("Nationality"); + tf.setPlaceholder("Nationality"); tf.setValue("Finnish"); tf.setReadOnly(true); row.addComponent(tf); @@ -94,27 +94,27 @@ public class TextFields extends VerticalLayout implements View { row.addComponent(tf); tf = new TextField("Icon inside"); - tf.setInputPrompt("Ooh, an icon"); + tf.setPlaceholder("Ooh, an icon"); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Large, Icon inside"); - tf.setInputPrompt("Ooh, an icon"); + tf.setPlaceholder("Ooh, an icon"); tf.addStyleName(ValoTheme.TEXTFIELD_LARGE); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Small, Icon inside"); - tf.setInputPrompt("Ooh, an icon"); + tf.setPlaceholder("Ooh, an icon"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("16px supported by default"); - tf.setInputPrompt("Image icon"); + tf.setPlaceholder("Image icon"); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); @@ -136,7 +136,7 @@ public class TextFields extends VerticalLayout implements View { row.addComponent(group); tf = new TextField(); - tf.setInputPrompt("Grouped with a button"); + tf.setPlaceholder("Grouped with a button"); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.setIcon(testIcon.get()); tf.setWidth("260px"); @@ -147,7 +147,7 @@ public class TextFields extends VerticalLayout implements View { group.addComponent(button); tf = new TextField("Borderless"); - tf.setInputPrompt("Write here…"); + tf.setPlaceholder("Write here…"); tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); tf.setIcon(testIcon.get()); @@ -159,7 +159,7 @@ public class TextFields extends VerticalLayout implements View { row.addComponent(tf); tf = new TextField("Centered"); - tf.setInputPrompt("Guess what?"); + tf.setPlaceholder("Guess what?"); tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_CENTER); row.addComponent(tf); @@ -203,18 +203,18 @@ public class TextFields extends VerticalLayout implements View { addComponent(row); TextArea ta = new TextArea("Normal"); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); ta = new TextArea("Inline icon"); - ta.setInputPrompt("Inline icon not really working"); + ta.setPlaceholder("Inline icon not really working"); ta.addStyleName("inline-icon"); ta.setIcon(testIcon.get()); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color1"); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); ta = new TextArea("Custom color, read-only"); @@ -230,17 +230,17 @@ public class TextFields extends VerticalLayout implements View { ta = new TextArea("Small"); ta.addStyleName(ValoTheme.TEXTAREA_SMALL); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); ta = new TextArea("Large"); ta.addStyleName(ValoTheme.TEXTAREA_LARGE); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); ta = new TextArea("Borderless"); ta.addStyleName(ValoTheme.TEXTAREA_BORDERLESS); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); ta = new TextArea("Right-aligned"); @@ -255,12 +255,12 @@ public class TextFields extends VerticalLayout implements View { ta = new TextArea("Tiny"); ta.addStyleName(ValoTheme.TEXTAREA_TINY); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); ta = new TextArea("Huge"); ta.addStyleName(ValoTheme.TEXTAREA_HUGE); - ta.setInputPrompt("Write your comment…"); + ta.setPlaceholder("Write your comment…"); row.addComponent(ta); RichTextArea rta = new RichTextArea(); diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java index 20c849389d..b9037208f9 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java @@ -1,8 +1,8 @@ package com.vaadin.tests.widgetset.client.superText; +import com.vaadin.client.ui.textarea.TextAreaConnector; import com.vaadin.shared.ui.Connect; import com.vaadin.tests.widgetset.server.ExtraSuperTextArea; -import com.vaadin.v7.client.ui.textarea.TextAreaConnector; @Connect(ExtraSuperTextArea.class) public class ExtraSuperTextAreaConnector extends TextAreaConnector { diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java index c114fcc7fb..fda1fc6f0a 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java @@ -1,8 +1,8 @@ package com.vaadin.tests.widgetset.client.superText; +import com.vaadin.client.ui.textarea.TextAreaConnector; import com.vaadin.shared.ui.Connect; import com.vaadin.tests.widgetset.server.SuperTextArea; -import com.vaadin.v7.client.ui.textarea.TextAreaConnector; /** * @author artamonov diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java b/uitest/src/main/java/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java index 5470a4ba12..b741c099b5 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java @@ -1,7 +1,7 @@ package com.vaadin.tests.widgetset.server; import com.vaadin.tests.widgetset.client.superText.SuperTextAreaState; -import com.vaadin.v7.ui.TextArea; +import com.vaadin.ui.TextArea; /** * @author artamonov diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/server/OverriddenDecendants.java b/uitest/src/main/java/com/vaadin/tests/widgetset/server/OverriddenDecendants.java index f7201aa670..5fdbdd4105 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/server/OverriddenDecendants.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/server/OverriddenDecendants.java @@ -19,7 +19,7 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; -import com.vaadin.v7.ui.TextArea; +import com.vaadin.ui.TextArea; /** * UI for testing that @DelegateToWidget works on derived widget states. @@ -35,21 +35,21 @@ public class OverriddenDecendants extends AbstractTestUI { TextArea normalTextArea = new TextArea(); normalTextArea.setRows(10); - normalTextArea.setWordwrap(true); + normalTextArea.setWordWrap(true); getLayout().addComponent(normalTextArea); // @DelegateToWidget will not work with overridden state in connector SuperTextArea superTextArea = new SuperTextArea(); superTextArea.setRows(10); - superTextArea.setWordwrap(true); + superTextArea.setWordWrap(true); getLayout().addComponent(superTextArea); // @DelegateToWidget will not work with overridden state in connector ExtraSuperTextArea extraSuperTextArea = new ExtraSuperTextArea(); extraSuperTextArea.setRows(10); - extraSuperTextArea.setWordwrap(true); + extraSuperTextArea.setWordWrap(true); getLayout().addComponent(extraSuperTextArea); } diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/server/SuperTextArea.java b/uitest/src/main/java/com/vaadin/tests/widgetset/server/SuperTextArea.java index ab5a8bcec2..6e73915e44 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/server/SuperTextArea.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/server/SuperTextArea.java @@ -1,7 +1,7 @@ package com.vaadin.tests.widgetset.server; import com.vaadin.tests.widgetset.client.superText.SuperTextAreaState; -import com.vaadin.v7.ui.TextArea; +import com.vaadin.ui.TextArea; /** * @author artamonov diff --git a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java index f73206863e..d0aa567e20 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java @@ -44,9 +44,8 @@ public class DragAndDropFocusObtainTest extends MultiBrowserTest { index++; } - // FIXME when old TextArea has been replaced with Vaadin 8 TextArea // Make sure we checked all fields - // Assert.assertEquals(8 + 1, index); + Assert.assertEquals(8 + 1, index); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java b/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java index fc4b4205cc..2850b3cf26 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java @@ -16,7 +16,7 @@ import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.v7.testbench.customelements.TextAreaElement; +import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.MultiBrowserTest; diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java index 9b7ebd8016..c00fda6f91 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java @@ -21,11 +21,11 @@ import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.customelements.FixedNotificationElement; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.CheckBoxElement; -import com.vaadin.v7.testbench.customelements.TableElement; import com.vaadin.testbench.elements.TableRowElement; -import com.vaadin.v7.testbench.customelements.TextAreaElement; import com.vaadin.tests.data.bean.Sex; import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.v7.testbench.customelements.TableElement; +import com.vaadin.v7.testbench.customelements.TextAreaElement; import com.vaadin.v7.testbench.customelements.TextFieldElement; public abstract class BasicPersonFormTest extends MultiBrowserTest { diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/ValoThemeUITest.java index 4ed6e10a52..974e5ecdaa 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/ValoThemeUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/ValoThemeUITest.java @@ -15,16 +15,20 @@ */ package com.vaadin.tests.themes.valo; +import java.util.List; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.CssLayoutElement; import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.v7.testbench.customelements.TreeElement; +import com.vaadin.testbench.parallel.Browser; import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.v7.testbench.customelements.TreeElement; public class ValoThemeUITest extends MultiBrowserTest { @@ -118,9 +122,10 @@ public class ValoThemeUITest extends MultiBrowserTest { } private void selectTreeNodeByCaption(String string) { - WebElement e = $(TreeElement.class).first().findElement( - By.xpath("//div[@class='v-tree-node-caption']//span[text()='" - + string + "']")); + WebElement e = $(TreeElement.class).first() + .findElement(By + .xpath("//div[@class='v-tree-node-caption']//span[text()='" + + string + "']")); e.click(); } @@ -312,4 +317,12 @@ public class ValoThemeUITest extends MultiBrowserTest { return false; } + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsersToTest = getBrowserCapabilities( + Browser.IE11, Browser.FIREFOX, Browser.CHROME); + browsersToTest.add(PHANTOMJS2()); + return browsersToTest; + } + } diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java index 1fd3ecc01e..78a11a1ff1 100644 --- a/uitest/src/test/java/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java @@ -21,7 +21,7 @@ import java.util.List; import org.junit.Test; -import com.vaadin.v7.testbench.customelements.TextAreaElement; +import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -45,6 +45,5 @@ public class OverriddenDecendantsTest extends MultiBrowserTest { assertEquals("Text area was missing rows", "10", area.getAttribute("rows")); } - } } |