All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.flow.component.select.data.SelectListDataView Maven / Gradle / Ivy

There is a newer version: 24.4.12
Show newest version
package com.vaadin.flow.component.select.data;

import com.vaadin.flow.component.select.Select;
import com.vaadin.flow.data.provider.AbstractListDataView;
import com.vaadin.flow.data.provider.DataProvider;
import com.vaadin.flow.data.provider.IdentifierProvider;
import com.vaadin.flow.function.SerializableBiConsumer;
import com.vaadin.flow.function.SerializableComparator;
import com.vaadin.flow.function.SerializableConsumer;
import com.vaadin.flow.function.SerializablePredicate;
import com.vaadin.flow.function.SerializableSupplier;

/**
 * Data view implementation for {@link Select} with in-memory list data.
 * Provides information on the data and allows operations on it.
 *
 * @param 
 *            item type
 */
public class SelectListDataView extends AbstractListDataView {

    private SerializableConsumer> identifierChangedCallback;

    /**
     * Creates a new in-memory data view for Select and verifies the passed data
     * provider is compatible with this data view implementation.
     *
     * @param dataProviderSupplier
     *            supplier from which the DataProvider can be gotten
     * @param select
     *            select component that the dataView is bound to
     * @param filterOrSortingChangedCallback
     *            callback, which is being invoked when the Select's filtering
     *            or sorting changes, not null
     */
    public SelectListDataView(
            SerializableSupplier> dataProviderSupplier,
            Select select,
            SerializableBiConsumer, SerializableComparator> filterOrSortingChangedCallback) {
        super(dataProviderSupplier, select, filterOrSortingChangedCallback);
    }

    /**
     * Creates a new in-memory data view for Select and verifies the passed data
     * provider is compatible with this data view implementation.
     *
     * @param dataProviderSupplier
     *            supplier from which the DataProvider can be gotten
     * @param select
     *            select component that the dataView is bound to
     * @param identifierChangedCallback
     *            callback method which should be called when identifierProvider
     *            is changed
     * @param filterOrSortingChangedCallback
     *            callback, which is being invoked when the Select's filtering
     *            or sorting changes, not null
     */
    public SelectListDataView(
            SerializableSupplier> dataProviderSupplier,
            Select select,
            SerializableConsumer> identifierChangedCallback,
            SerializableBiConsumer, SerializableComparator> filterOrSortingChangedCallback) {
        super(dataProviderSupplier, select, filterOrSortingChangedCallback);
        this.identifierChangedCallback = identifierChangedCallback;
    }

    @Override
    public void setIdentifierProvider(
            IdentifierProvider identifierProvider) {
        super.setIdentifierProvider(identifierProvider);

        if (identifierChangedCallback != null) {
            identifierChangedCallback.accept(identifierProvider);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy