From 3e15c61ac505a28d1cfbc4aabb83dbd5297dab43 Mon Sep 17 00:00:00 2001 From: Mikhail Buzuverov Date: Fri, 26 May 2017 11:01:35 +0500 Subject: Added constructors which takes DataCommunicator instance to Grid (#9206) (#9208) Constructors are backported from master (8.1) --- server/src/main/java/com/vaadin/ui/Grid.java | 56 +++++++++++++++++++++++++++- 1 file 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 extends AbstractListing 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 dataCommunicator) { this(new PropertySet() { @Override public Stream> getProperties() { @@ -2064,7 +2078,7 @@ public class Grid extends AbstractListing 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 extends AbstractListing implements HasComponents, * @see #withPropertySet(PropertySet) */ public Grid(Class 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 null + * @param dataCommunicator + * the data communicator to use, notnull + * @since 8.0.6 + */ + protected Grid(Class beanType, DataCommunicator dataCommunicator) { + this(BeanPropertySet.get(beanType), dataCommunicator); this.beanType = beanType; } @@ -2095,6 +2126,27 @@ public class Grid extends AbstractListing implements HasComponents, * the property set implementation to use, not null. */ protected Grid(PropertySet propertySet) { + this(propertySet, new DataCommunicator<>()); + } + + /** + * Creates a grid using a custom {@link PropertySet} implementation and + * custom data communicator. + *

+ * 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 null. + * @param dataCommunicator + * the data communicator to use, notnull + * @since 8.0.6 + */ + protected Grid(PropertySet propertySet, DataCommunicator dataCommunicator) { + super(dataCommunicator); registerRpc(new GridServerRpcImpl()); setDefaultHeaderRow(appendHeaderRow()); setSelectionModel(new SingleSelectionModelImpl<>()); -- cgit v1.2.3