@@ -153,43 +153,51 @@ private static <T> ListDataProvider<T> emptyDataProvider() {
153153
154154 /** Constructs a new TwinColGrid with an empty {@link ListDataProvider}. */
155155 public TwinColGrid () {
156- this (emptyDataProvider (), (String ) null );
156+ this (null , Grid ::new );
157+ }
158+
159+ /**
160+ * Constructs a new empty TwinColGrid with caption
161+ *
162+ * @param caption the component caption
163+ */
164+ public TwinColGrid (String caption ) {
165+ this (caption , Grid ::new );
157166 }
158167
159168 /**
160169 * Constructs a new TwinColGrid with data provider for options.
161170 *
162171 * @param dataProvider the data provider, not {@code null}
163172 * @param caption the component caption
173+ * @deprecated Use {@link #TwinColGrid(String)} and {@link #setDataProvider(ListDataProvider)}
164174 */
175+ @ Deprecated
165176 public TwinColGrid (final ListDataProvider <T > dataProvider , String caption ) {
166- this (dataProvider , caption , Grid ::new );
177+ this (caption , Grid ::new );
178+ setDataProvider (dataProvider );
167179 }
168180
169181 /**
170- * Constructs a new TwinColGrid with data provider for options, using the specified supplier for
171- * instantiating both grids.
182+ * Constructs a new empty TwinColGrid, using the specified supplier for instantiating both grids.
172183 *
173184 * @param dataProvider the data provider, not {@code null}
174185 * @param caption the component caption
175186 * @param gridSupplier a supplier for instantiating both grids
176187 */
177- public TwinColGrid (final ListDataProvider <T > dataProvider , String caption ,
178- Supplier <Grid <T >> gridSupplier ) {
179- this (dataProvider , caption , gridSupplier .get (), gridSupplier .get ());
188+ public TwinColGrid (String caption , Supplier <Grid <T >> gridSupplier ) {
189+ this (caption , gridSupplier .get (), gridSupplier .get ());
180190 }
181191
182192 /**
183- * Constructs a new TwinColGrid with data provider for options, using the specified grids for each
184- * side.
193+ * Constructs a new empty TwinColGrid, using the specified grids for each side.
185194 *
186- * @param dataProvider the data provider, not {@code null}
187195 * @param caption the component caption
188196 * @param availableGrid the grid that contains the available items
189197 * @param selectedGrid the grid that contains the selected items
190198 */
191- public TwinColGrid (final ListDataProvider <T > dataProvider , String caption ,
192- @ NonNull Grid <T > availableGrid , @ NonNull Grid < T > selectionGrid ) {
199+ public TwinColGrid (String caption , @ NonNull Grid <T > availableGrid ,
200+ @ NonNull Grid <T > selectionGrid ) {
193201 if (availableGrid == selectionGrid ) {
194202 throw new IllegalArgumentException ("Grids must be different" );
195203 }
@@ -208,11 +216,10 @@ public TwinColGrid(final ListDataProvider<T> dataProvider, String caption,
208216 add (new Label (caption ));
209217 }
210218
219+ setDataProvider (emptyDataProvider ());
211220 rightGridDataProvider = DataProvider .ofCollection (new LinkedHashSet <>());
212221 getSelectionGrid ().setDataProvider (rightGridDataProvider );
213222
214- setDataProvider (dataProvider );
215-
216223 getAvailableGrid ().setWidth ("100%" );
217224 getSelectionGrid ().setWidth ("100%" );
218225
@@ -460,7 +467,8 @@ private void setDataProvider(ListDataProvider<T> dataProvider) {
460467 * @param options the options, cannot be {@code null}
461468 */
462469 public TwinColGrid (final Collection <T > options ) {
463- this (DataProvider .ofCollection (new LinkedHashSet <>(options )), null );
470+ this ((String ) null );
471+ setDataProvider (DataProvider .ofCollection (new LinkedHashSet <>(options )));
464472 }
465473
466474 /**
@@ -470,7 +478,8 @@ public TwinColGrid(final Collection<T> options) {
470478 * @param options the options, cannot be {@code null}
471479 */
472480 public TwinColGrid (final Collection <T > options , final String caption ) {
473- this (DataProvider .ofCollection (new LinkedHashSet <>(options )), caption );
481+ this (caption );
482+ setDataProvider (DataProvider .ofCollection (new LinkedHashSet <>(options )));
474483 }
475484
476485 /**
0 commit comments