@Override public <C> void setDataProvider(final DataProvider<T, C> dataProvider, final SerializableFunction<String, C> filterConverter) { Objects.requireNonNull(dataProvider, "dataProvider cannot be null"); Objects.requireNonNull(filterConverter, "filterConverter cannot be null"); final SerializableFunction<String, C> convertOrNull = filterText -> { if (filterText == null || filterText.isEmpty()) { return null; } return filterConverter.apply(filterText); }; final SerializableConsumer<C> providerFilterSlot = internalSetDataProvider(dataProvider, convertOrNull.apply(this.currentFilterText)); this.filterSlot = filter -> providerFilterSlot.accept(convertOrNull.apply(filter)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void setDataProvider(DataProvider<ITEM, ?> dataProvider, SerializableFunction<String, ?> filterConverter) { if (filterConverter != null && getInternalField() instanceof ComboBox) { ((ComboBox) getInternalField()).setDataProvider(dataProvider, filterConverter); } else { setDataProvider(dataProvider); } }
@Override public B dataSource(ItemDataProvider<T> dataProvider, SerializableFunction<String, QueryFilter> filterProvider) { this.itemDataProvider = dataProvider; this.filterProvider = filterProvider; return builder(); }
@Override public <F> B dataSource(DataProvider<T, F> dataProvider, SerializableFunction<String, F> filterProvider) { this.dataProvider = dataProvider; this.filterProvider = filterProvider; return builder(); }
@Override public SelectModeSinglePropertySelectInputBuilder<T> captionQueryFilter( SerializableFunction<String, QueryFilter> filterProvider) { this.filterProvider = filterProvider; return this; }
@Override public void setDataProvider(DataProvider<ITEM, ?> dataProvider, SerializableFunction<String, ?> filterConverter) { setDataProvider(dataProvider); }
/** * Set the data source {@link DataProvider}. * @param dataProvider The data provider to set * @param filterConverter Optional caption filter converter */ public abstract void setDataProvider(DataProvider<ITEM, ?> dataProvider, SerializableFunction<String, ?> filterConverter);
/** * Set the function to provide the {@link QueryFilter} to use with the data provider when user types a caption * filter String. * @param filterProvider caption {@link QueryFilter} provider * @return this */ SelectModeSinglePropertySelectInputBuilder<T> captionQueryFilter( SerializableFunction<String, QueryFilter> filterProvider);
/** * Set the selection items data provider. * @param dataProvider Items data provider (not null) * @param filterProvider Optional caption {@link QueryFilter} provider for {@link RenderingMode#SELECT} type inputs * @return this */ B dataSource(ItemDataProvider<T> dataProvider, SerializableFunction<String, QueryFilter> filterProvider);
/** * Set the selection items data provider. * @param <F> Caption filter type * @param dataProvider Items data provider (not null) * @param filterProvider Optional caption {@link QueryFilter} provider for {@link RenderingMode#SELECT} type inputs * @return this */ <F> B dataSource(DataProvider<T, F> dataProvider, SerializableFunction<String, F> filterProvider);
/** * Sets the data provider and filter converter for this listing. The data * provider is queried for displayed items as needed. * @param <C> the listing type to convert to FILTER type * * @param dataProvider * the data provider, not <code>null</code> * @param filterConverter * a function that converts filter values produced by this * listing into filter values expected by the provided data * provider, not <code>null</code> * @return this for method chaining * @see HasFilterableDataProvider#setDataProvider(DataProvider, SerializableFunction) */ @SuppressWarnings("unchecked") public default <C> THIS withDataProvider(DataProvider<ITEM, C> dataProvider, SerializableFunction<FILTER, C> filterConverter) { this.setDataProvider(dataProvider, filterConverter); return (THIS) this; }