diff options
author | Mikhail Buzuverov <star.guardian.mgn@gmail.com> | 2017-05-26 11:01:35 +0500 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-26 09:01:35 +0300 |
commit | 3e15c61ac505a28d1cfbc4aabb83dbd5297dab43 (patch) | |
tree | b20d94ea1ca5a6e2d146df06ec441adbc1790dbc | |
parent | f961ea1d766996a551b5f2bf2aa7929ead0f0466 (diff) | |
download | vaadin-framework-3e15c61ac505a28d1cfbc4aabb83dbd5297dab43.tar.gz vaadin-framework-3e15c61ac505a28d1cfbc4aabb83dbd5297dab43.zip |
Added constructors which takes DataCommunicator instance to Grid (#9206) (#9208)
Constructors are backported from master (8.1)
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index a945543ee3..080c2fb4f1 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -2051,6 +2051,20 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, * @see #withPropertySet(PropertySet) */ public Grid() { + this(new DataCommunicator<>()); + } + + /** + * Creates a new grid with the given data communicator and without support + * for creating columns based on property names. + * + * @param dataCommunicator + * the custom data communicator to set + * @see #Grid() + * @see #Grid(PropertySet, DataCommunicator) + * @since 8.0.6 + */ + protected Grid(DataCommunicator<T> dataCommunicator) { this(new PropertySet<T>() { @Override public Stream<PropertyDefinition<T, ?>> getProperties() { @@ -2064,7 +2078,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, "A Grid created without a bean type class literal or a custom property set" + " doesn't support finding properties by name."); } - }); + }, dataCommunicator); } /** @@ -2079,7 +2093,24 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, * @see #withPropertySet(PropertySet) */ public Grid(Class<T> beanType) { - this(BeanPropertySet.get(beanType)); + this(beanType, new DataCommunicator<>()); + } + + /** + * Creates a new grid that uses custom data communicator and provided bean type + * + * It uses reflection of the provided bean type to automatically set up an initial set of columns. + * All columns will be configured using the same {@link Object#toString()} renderer that is used + * by {@link #addColumn(ValueProvider)}. + * + * @param beanType + * the bean type to use, not <code>null</code> + * @param dataCommunicator + * the data communicator to use, not<code>null</code> + * @since 8.0.6 + */ + protected Grid(Class<T> beanType, DataCommunicator<T> dataCommunicator) { + this(BeanPropertySet.get(beanType), dataCommunicator); this.beanType = beanType; } @@ -2095,6 +2126,27 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, * the property set implementation to use, not <code>null</code>. */ protected Grid(PropertySet<T> propertySet) { + this(propertySet, new DataCommunicator<>()); + } + + /** + * Creates a grid using a custom {@link PropertySet} implementation and + * custom data communicator. + * <p> + * Property set is used for configuring the initial columns and resolving + * property names for {@link #addColumn(String)} and + * {@link Column#setEditorComponent(HasValue)}. + * + * @see #withPropertySet(PropertySet) + * + * @param propertySet + * the property set implementation to use, not <code>null</code>. + * @param dataCommunicator + * the data communicator to use, not<code>null</code> + * @since 8.0.6 + */ + protected Grid(PropertySet<T> propertySet, DataCommunicator<T> dataCommunicator) { + super(dataCommunicator); registerRpc(new GridServerRpcImpl()); setDefaultHeaderRow(appendHeaderRow()); setSelectionModel(new SingleSelectionModelImpl<>()); |