Search in sources :

Example 11 with DataProvider

use of com.vaadin.flow.data.provider.DataProvider in project flow-components by vaadin.

the class Select method reset.

@SuppressWarnings("unchecked")
private void reset() {
    keyMapper.removeAll();
    listBox.removeAll();
    clear();
    requestClientSideContentUpdateIfNotPending();
    if (isEmptySelectionAllowed()) {
        addEmptySelectionItem();
    }
    synchronized (dataProvider) {
        final AtomicInteger itemCounter = new AtomicInteger(0);
        getDataProvider().fetch(DataViewUtils.getQuery(this)).map(item -> createItem((T) item)).forEach(component -> {
            add((Component) component);
            itemCounter.incrementAndGet();
        });
        lastFetchedDataSize = itemCounter.get();
        // so as to avoid multiple beforeClientResponses.
        if (sizeRequest == null) {
            sizeRequest = ui -> {
                fireSizeEvent();
                sizeRequest = null;
            };
            // Size event is fired before client response so as to avoid
            // multiple size change events during server round trips
            runBeforeClientResponse(sizeRequest);
        }
    }
}
Also used : DataViewUtils(com.vaadin.flow.data.provider.DataViewUtils) KeyMapper(com.vaadin.flow.data.provider.KeyMapper) ListDataProvider(com.vaadin.flow.data.provider.ListDataProvider) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Component(com.vaadin.flow.component.Component) ItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator) NpmPackage(com.vaadin.flow.component.dependency.NpmPackage) ComponentUtil(com.vaadin.flow.component.ComponentUtil) Registration(com.vaadin.flow.shared.Registration) HasListDataView(com.vaadin.flow.data.provider.HasListDataView) SerializableConsumer(com.vaadin.flow.function.SerializableConsumer) HasDataView(com.vaadin.flow.data.provider.HasDataView) SingleSelect(com.vaadin.flow.data.selection.SingleSelect) AtomicReference(java.util.concurrent.atomic.AtomicReference) HasLabel(com.vaadin.flow.component.HasLabel) ItemCountChangeEvent(com.vaadin.flow.data.provider.ItemCountChangeEvent) Tag(com.vaadin.flow.component.Tag) HasValidation(com.vaadin.flow.component.HasValidation) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataProvider(com.vaadin.flow.data.provider.DataProvider) IdentifierProvider(com.vaadin.flow.data.provider.IdentifierProvider) SelectDataView(com.vaadin.flow.component.select.data.SelectDataView) PropertyChangeEvent(com.vaadin.flow.dom.PropertyChangeEvent) UI(com.vaadin.flow.component.UI) SerializablePredicate(com.vaadin.flow.function.SerializablePredicate) HasComponents(com.vaadin.flow.component.HasComponents) AttachEvent(com.vaadin.flow.component.AttachEvent) HasSize(com.vaadin.flow.component.HasSize) Query(com.vaadin.flow.data.provider.Query) DataChangeEvent(com.vaadin.flow.data.provider.DataChangeEvent) GeneratedVaadinSelect(com.vaadin.flow.component.select.generated.GeneratedVaadinSelect) PropertyChangeListener(com.vaadin.flow.dom.PropertyChangeListener) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) Objects(java.util.Objects) HasTheme(com.vaadin.flow.component.HasTheme) Stream(java.util.stream.Stream) HasItemComponents(com.vaadin.flow.data.binder.HasItemComponents) DataProviderWrapper(com.vaadin.flow.data.provider.DataProviderWrapper) Optional(java.util.Optional) HasHelper(com.vaadin.flow.component.HasHelper) TextRenderer(com.vaadin.flow.data.renderer.TextRenderer) JsModule(com.vaadin.flow.component.dependency.JsModule) SelectListDataView(com.vaadin.flow.component.select.data.SelectListDataView) InMemoryDataProvider(com.vaadin.flow.data.provider.InMemoryDataProvider) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

DataProvider (com.vaadin.flow.data.provider.DataProvider)11 Query (com.vaadin.flow.data.provider.Query)9 Div (com.vaadin.flow.component.html.Div)8 NativeButton (com.vaadin.flow.component.html.NativeButton)8 Route (com.vaadin.flow.router.Route)8 List (java.util.List)8 Stream (java.util.stream.Stream)8 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)7 Arrays (java.util.Arrays)7 ListDataProvider (com.vaadin.flow.data.provider.ListDataProvider)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 Component (com.vaadin.flow.component.Component)4 Serializable (java.io.Serializable)4 Collections (java.util.Collections)4 ComponentUtil (com.vaadin.flow.component.ComponentUtil)3 HasHelper (com.vaadin.flow.component.HasHelper)3 HasLabel (com.vaadin.flow.component.HasLabel)3