diff options
author | caalador <mikael.grankvist@gmail.com> | 2017-01-30 08:16:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 08:16:44 +0200 |
commit | 07814a2b556eff6bd14959cee81a9b3dcd105bb7 (patch) | |
tree | 1d7a49df4f32c301a0d41fc8598abf4a17ede846 /server/src/main/java/com/vaadin/ui/RichTextArea.java | |
parent | e7b49b4893607904bac69ca79e5ef583abfbe679 (diff) | |
download | vaadin-framework-07814a2b556eff6bd14959cee81a9b3dcd105bb7.tar.gz vaadin-framework-07814a2b556eff6bd14959cee81a9b3dcd105bb7.zip |
Add convenience constructors to new components (#598) (#8351)
Add convenience constructors (#598)
Added convenience constructors to ui components that have
been reimplemented for Vaadin 8
Diffstat (limited to 'server/src/main/java/com/vaadin/ui/RichTextArea.java')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/RichTextArea.java | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/RichTextArea.java b/server/src/main/java/com/vaadin/ui/RichTextArea.java index b54840fe32..db331c3a04 100644 --- a/server/src/main/java/com/vaadin/ui/RichTextArea.java +++ b/server/src/main/java/com/vaadin/ui/RichTextArea.java @@ -18,6 +18,7 @@ package com.vaadin.ui; import java.util.Objects; +import elemental.json.Json; import org.jsoup.nodes.Element; import com.vaadin.shared.ui.ValueChangeMode; @@ -26,8 +27,6 @@ import com.vaadin.shared.ui.richtextarea.RichTextAreaServerRpc; import com.vaadin.shared.ui.richtextarea.RichTextAreaState; import com.vaadin.ui.declarative.DesignContext; -import elemental.json.Json; - /** * A simple RichTextArea to edit HTML format text. */ @@ -74,13 +73,64 @@ public class RichTextArea extends AbstractField<String> * @param caption * the caption for the editor. * @param value - * the initial text content of the editor. + * the initial text content of the editor, not {@code null} */ public RichTextArea(String caption, String value) { this(caption); setValue(value); } + /** + * Constructs a new {@code RichTextArea} with a value change listener. + * <p> + * The listener is called when the value of this {@code TextField} is + * changed either by the user or programmatically. + * + * @param valueChangeListener + * the value change listener, not {@code null} + */ + public RichTextArea(ValueChangeListener valueChangeListener) { + addValueChangeListener(valueChangeListener); + } + + /** + * Constructs a new {@code RichTextArea} with the given caption and a value + * change listener. + * <p> + * The listener is called when the value of this {@code TextField} is + * changed either by the user or programmatically. + * + * @param caption + * the caption for the field + * @param valueChangeListener + * the value change listener, not {@code null} + */ + public RichTextArea(String caption, + ValueChangeListener valueChangeListener) { + this(valueChangeListener); + setCaption(caption); + } + + /** + * Constructs a new {@code RichTextArea} with the given caption, initial + * text contents and a value change listener. + * <p> + * The listener is called when the value of this {@code RichTextArea} is + * changed either by the user or programmatically. + * + * @param caption + * the caption for the field + * @param value + * the value for the field, not {@code null} + * @param valueChangeListener + * the value change listener, not {@code null} + */ + public RichTextArea(String caption, String value, + ValueChangeListener valueChangeListener) { + this(caption, value); + addValueChangeListener(valueChangeListener); + } + @Override public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); |