aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com
diff options
context:
space:
mode:
authorcaalador <mikael.grankvist@gmail.com>2017-01-30 08:16:44 +0200
committerGitHub <noreply@github.com>2017-01-30 08:16:44 +0200
commit07814a2b556eff6bd14959cee81a9b3dcd105bb7 (patch)
tree1d7a49df4f32c301a0d41fc8598abf4a17ede846 /server/src/main/java/com
parente7b49b4893607904bac69ca79e5ef583abfbe679 (diff)
downloadvaadin-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')
-rw-r--r--server/src/main/java/com/vaadin/ui/DateField.java54
-rw-r--r--server/src/main/java/com/vaadin/ui/DateTimeField.java54
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java49
-rw-r--r--server/src/main/java/com/vaadin/ui/InlineDateField.java52
-rw-r--r--server/src/main/java/com/vaadin/ui/InlineDateTimeField.java52
-rw-r--r--server/src/main/java/com/vaadin/ui/PasswordField.java53
-rw-r--r--server/src/main/java/com/vaadin/ui/RichTextArea.java56
-rw-r--r--server/src/main/java/com/vaadin/ui/TextArea.java51
8 files changed, 414 insertions, 7 deletions
diff --git a/server/src/main/java/com/vaadin/ui/DateField.java b/server/src/main/java/com/vaadin/ui/DateField.java
index 2ee1c478d9..87da572795 100644
--- a/server/src/main/java/com/vaadin/ui/DateField.java
+++ b/server/src/main/java/com/vaadin/ui/DateField.java
@@ -60,6 +60,58 @@ public class DateField extends AbstractLocalDateField {
}
/**
+ * Constructs a new {@code DateField} with a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code DateField} is
+ * changed either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public DateField(ValueChangeListener valueChangeListener) {
+ super();
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code DateField} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code DateField} 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 DateField(String caption,
+ ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new {@code DateField} with the given caption, initial
+ * text contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code DateField} 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 DateField(String caption, LocalDate value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
* Returns the current placeholder text.
*
* @see #setPlaceholder(String)
@@ -106,7 +158,7 @@ public class DateField extends AbstractLocalDateField {
* Disabling it causes only the button for date selection to be active, thus
* preventing the user from entering invalid dates.
*
- * See {@link http://dev.vaadin.com/ticket/6790}.
+ * See <a href="http://dev.vaadin.com/ticket/6790">issue 6790</a>.
*
* @param state
* <b>true</b> to enable text field, <b>false</b> to disable it.
diff --git a/server/src/main/java/com/vaadin/ui/DateTimeField.java b/server/src/main/java/com/vaadin/ui/DateTimeField.java
index cde5633846..c07e5dce0b 100644
--- a/server/src/main/java/com/vaadin/ui/DateTimeField.java
+++ b/server/src/main/java/com/vaadin/ui/DateTimeField.java
@@ -61,6 +61,58 @@ public class DateTimeField extends AbstractLocalDateTimeField {
}
/**
+ * Constructs a new {@code DateTimeField} with a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code DateTimeField} is
+ * changed either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public DateTimeField(ValueChangeListener valueChangeListener) {
+ super();
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code DateTimeField} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code DateTimeField} 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 DateTimeField(String caption,
+ ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new {@code DateTimeField} with the given caption, initial
+ * text contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code DateTimeField} 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 DateTimeField(String caption, LocalDateTime value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
* Returns the current placeholder text.
*
* @see #setPlaceholder(String)
@@ -107,7 +159,7 @@ public class DateTimeField extends AbstractLocalDateTimeField {
* Disabling it causes only the button for date selection to be active, thus
* preventing the user from entering invalid dates.
*
- * See {@link http://dev.vaadin.com/ticket/6790}.
+ * See <a href="http://dev.vaadin.com/ticket/6790">issue 6790</a>.
*
* @param state
* <b>true</b> to enable text field, <b>false</b> to disable it.
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 16e452fbea..9a09ab3e7a 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -1839,6 +1839,55 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
});
}
+ /**
+ * Creates a new {@code Grid} using the given caption
+ *
+ * @param caption
+ * the caption of the grid
+ */
+ public Grid(String caption) {
+ this();
+ setCaption(caption);
+ }
+
+ /**
+ * Creates a new {@code Grid} using the given caption and
+ * {@code DataProvider}
+ *
+ * @param caption
+ * the caption of the grid
+ * @param dataProvider
+ * the data provider, not {@code null}
+ */
+ public Grid(String caption, DataProvider<T, ?> dataProvider) {
+ this(caption);
+ setDataProvider(dataProvider);
+ }
+
+ /**
+ * Creates a new {@code Grid} using the given {@code DataProvider}
+ *
+ * @param dataProvider
+ * the data provider, not {@code null}
+ */
+ public Grid(DataProvider<T, ?> dataProvider) {
+ this();
+ setDataProvider(dataProvider);
+ }
+
+ /**
+ * Creates a new {@code Grid} using the given caption and collection of
+ * items
+ *
+ * @param caption
+ * the caption of the grid
+ * @param items
+ * the data items to use, not {@çode null}
+ */
+ public Grid(String caption, Collection<T> items) {
+ this(caption, DataProvider.ofCollection(items));
+ }
+
public <V> void fireColumnVisibilityChangeEvent(Column<T, V> column,
boolean hidden, boolean userOriginated) {
fireEvent(new ColumnVisibilityChangeEvent(this, column, hidden,
diff --git a/server/src/main/java/com/vaadin/ui/InlineDateField.java b/server/src/main/java/com/vaadin/ui/InlineDateField.java
index 2db9d7f1db..3b63545710 100644
--- a/server/src/main/java/com/vaadin/ui/InlineDateField.java
+++ b/server/src/main/java/com/vaadin/ui/InlineDateField.java
@@ -59,6 +59,58 @@ public class InlineDateField extends AbstractLocalDateField {
super(caption);
}
+ /**
+ * Constructs a new {@code InlineDateField} with a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code InlineDateField} is
+ * changed either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public InlineDateField(ValueChangeListener valueChangeListener) {
+ super();
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code InlineDateField} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code InlineDateField} 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 InlineDateField(String caption,
+ ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new {@code InlineDateField} with the given caption, initial
+ * text contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code InlineDateField} 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 InlineDateField(String caption, LocalDate value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
+ }
+
@Override
protected InlineDateFieldState getState() {
return (InlineDateFieldState) super.getState();
diff --git a/server/src/main/java/com/vaadin/ui/InlineDateTimeField.java b/server/src/main/java/com/vaadin/ui/InlineDateTimeField.java
index 2c4cf290b3..fecfd346e4 100644
--- a/server/src/main/java/com/vaadin/ui/InlineDateTimeField.java
+++ b/server/src/main/java/com/vaadin/ui/InlineDateTimeField.java
@@ -59,6 +59,58 @@ public class InlineDateTimeField extends AbstractLocalDateTimeField {
super(caption);
}
+ /**
+ * Constructs a new {@code InlineDateTimeField} with a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code InlineDateTimeField} is
+ * changed either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public InlineDateTimeField(ValueChangeListener valueChangeListener) {
+ super();
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code InlineDateTimeField} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code InlineDateTimeField} 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 InlineDateTimeField(String caption,
+ ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new {@code InlineDateTimeField} with the given caption, initial
+ * text contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code InlineDateTimeField} 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 InlineDateTimeField(String caption, LocalDateTime value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
+ }
+
@Override
protected InlineDateTimeFieldState getState() {
return (InlineDateTimeFieldState) super.getState();
diff --git a/server/src/main/java/com/vaadin/ui/PasswordField.java b/server/src/main/java/com/vaadin/ui/PasswordField.java
index 661d848730..0f87912e9d 100644
--- a/server/src/main/java/com/vaadin/ui/PasswordField.java
+++ b/server/src/main/java/com/vaadin/ui/PasswordField.java
@@ -42,7 +42,7 @@ public class PasswordField extends TextField {
* @param caption
* the caption for the field
* @param value
- * the value for the field
+ * the value for the field, not {@code null}
*/
public PasswordField(String caption, String value) {
setValue(value);
@@ -60,6 +60,57 @@ public class PasswordField extends TextField {
setCaption(caption);
}
+ /**
+ * Constructs a new {@code PasswordField} with a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code PasswordField} is
+ * changed either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public PasswordField(ValueChangeListener valueChangeListener) {
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code PasswordField} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code PasswordField} 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 PasswordField(String caption,
+ ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+
+ /**
+ * Constructs a new {@code PasswordField} with the given caption, initial
+ * text contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code PasswordField} 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 PasswordField(String caption, String value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
+ }
+
@Override
public void readDesign(Element design, DesignContext designContext) {
super.readDesign(design, designContext);
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);
diff --git a/server/src/main/java/com/vaadin/ui/TextArea.java b/server/src/main/java/com/vaadin/ui/TextArea.java
index e1b939d1c8..a8047bfb9b 100644
--- a/server/src/main/java/com/vaadin/ui/TextArea.java
+++ b/server/src/main/java/com/vaadin/ui/TextArea.java
@@ -63,12 +63,61 @@ public class TextArea extends AbstractTextField {
* @param caption
* the caption for the field
* @param value
- * the value for the field
+ * the value for the field, not {@code null}
*/
public TextArea(String caption, String value) {
this(caption);
setValue(value);
+ }
+
+ /**
+ * Constructs a new {@code TextArea} with a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code TextArea} is changed
+ * either by the user or programmatically.
+ *
+ * @param valueChangeListener
+ * the value change listener, not {@code null}
+ */
+ public TextArea(ValueChangeListener valueChangeListener) {
+ addValueChangeListener(valueChangeListener);
+ }
+
+ /**
+ * Constructs a new {@code TextArea} with the given caption and a value
+ * change listener.
+ * <p>
+ * The listener is called when the value of this {@code TextArea} 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 TextArea(String caption, ValueChangeListener valueChangeListener) {
+ this(valueChangeListener);
+ setCaption(caption);
+ }
+ /**
+ * Constructs a new {@code TextArea} with the given caption, initial text
+ * contents and a value change listener.
+ * <p>
+ * The listener is called when the value of this {@code TextArea} 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 TextArea(String caption, String value,
+ ValueChangeListener valueChangeListener) {
+ this(caption, value);
+ addValueChangeListener(valueChangeListener);
}
@Override