Class ContainerDataGridItems<T>

java.lang.Object
com.vaadin.flow.data.provider.AbstractDataProvider<T,Void>
io.jmix.flowui.data.grid.ContainerDataGridItems<T>
Type Parameters:
T - the type of entity contained in the associated CollectionContainer
All Implemented Interfaces:
com.vaadin.flow.data.provider.DataProvider<T,Void>, ContainerDataUnit<T>, DataUnit, EntityDataUnit, DataGridItems<T>, DataGridItems.Sortable<T>, EntityDataGridItems<T>, HasType<T>, Serializable
Direct Known Subclasses:
ContainerGroupDataGridItems, ContainerTreeDataGridItems

public class ContainerDataGridItems<T> extends com.vaadin.flow.data.provider.AbstractDataProvider<T,Void> implements ContainerDataUnit<T>, EntityDataGridItems<T>, DataGridItems.Sortable<T>
Implementation of DataProvider that connects a CollectionContainer to a DataGrid. This class allows seamless synchronization between the container and the grid, supporting selection, sorting, and event listeners.
See Also:
  • Field Details

    • container

      protected CollectionContainer<T> container
    • suppressSorting

      protected boolean suppressSorting
  • Constructor Details

  • Method Details

    • initContainer

      protected void initContainer(CollectionContainer<T> container)
    • containerItemChanged

      protected void containerItemChanged(InstanceContainer.ItemChangeEvent<T> event)
    • containerCollectionChanged

      protected void containerCollectionChanged(CollectionContainer.CollectionChangeEvent<T> event)
    • containerItemPropertyChanged

      protected void containerItemPropertyChanged(InstanceContainer.ItemPropertyChangeEvent<T> event)
    • getItems

      public Collection<T> getItems()
      Specified by:
      getItems in interface DataGridItems<T>
      Returns:
      unmodifiable collection of items
    • getSelectedItem

      @Nullable public T getSelectedItem()
      Specified by:
      getSelectedItem in interface DataGridItems<T>
      Returns:
      the current item contained in the source
    • setSelectedItem

      public void setSelectedItem(@Nullable T item)
      Description copied from interface: DataGridItems
      Set current item in the source.
      Specified by:
      setSelectedItem in interface DataGridItems<T>
      Parameters:
      item - the item to set
    • containsItem

      public boolean containsItem(T item)
      Specified by:
      containsItem in interface DataGridItems<T>
      Parameters:
      item - an item to check
      Returns:
      true if the underlying collection contains an item, false otherwise
    • sort

      public void sort(Object[] propertyId, boolean[] ascending)
      Description copied from interface: DataGridItems.Sortable
      Sorts the items based on the specified property IDs and sort order.
      Specified by:
      sort in interface DataGridItems.Sortable<T>
      Parameters:
      propertyId - an array of property IDs by which the items should be sorted
      ascending - an array indicating the sort order for each property ID, where true represents ascending order and false represents descending order
    • createSort

      protected Sort createSort(Object[] propertyId, boolean[] ascending)
    • resetSortOrder

      public void resetSortOrder()
      Description copied from interface: DataGridItems.Sortable
      Resets the sort order of the items to the default state or removes any applied sorting.
      Specified by:
      resetSortOrder in interface DataGridItems.Sortable<T>
    • suppressSorting

      public void suppressSorting()
      Description copied from interface: DataGridItems.Sortable
      Suppresses the automatic sorting functionality for the data grid items.
      Specified by:
      suppressSorting in interface DataGridItems.Sortable<T>
    • enableSorting

      public void enableSorting()
      Description copied from interface: DataGridItems.Sortable
      Enables the sorting functionality for the data grid items.
      Specified by:
      enableSorting in interface DataGridItems.Sortable<T>
    • addValueChangeListener

      public com.vaadin.flow.shared.Registration addValueChangeListener(Consumer<DataGridItems.ValueChangeEvent<T>> listener)
      Description copied from interface: DataGridItems
      Registers a new value change listener.
      Specified by:
      addValueChangeListener in interface DataGridItems<T>
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addItemSetChangeListener

      public com.vaadin.flow.shared.Registration addItemSetChangeListener(Consumer<DataGridItems.ItemSetChangeEvent<T>> listener)
      Description copied from interface: DataGridItems
      Registers a new item set change listener.
      Specified by:
      addItemSetChangeListener in interface DataGridItems<T>
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addSelectedItemChangeListener

      public com.vaadin.flow.shared.Registration addSelectedItemChangeListener(Consumer<DataGridItems.SelectedItemChangeEvent<T>> listener)
      Description copied from interface: DataGridItems
      Registers a new selected item change listener.
      Specified by:
      addSelectedItemChangeListener in interface DataGridItems<T>
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • isInMemory

      public boolean isInMemory()
      Specified by:
      isInMemory in interface com.vaadin.flow.data.provider.DataProvider<T,Void>
    • size

      public int size(com.vaadin.flow.data.provider.Query<T,Void> query)
      Specified by:
      size in interface com.vaadin.flow.data.provider.DataProvider<T,Void>
    • fetch

      public Stream<T> fetch(com.vaadin.flow.data.provider.Query<T,Void> query)
      Specified by:
      fetch in interface com.vaadin.flow.data.provider.DataProvider<T,Void>
    • getItem

      @Nullable public T getItem(Object entityId)
      Specified by:
      getItem in interface DataGridItems<T>
      Parameters:
      entityId - the item id
      Returns:
      the item by the given id
    • getItemValue

      @Nullable public Object getItemValue(Object itemId, MetaPropertyPath propertyId)
      Specified by:
      getItemValue in interface DataGridItems<T>
      Parameters:
      itemId - the item id
      propertyId - the property id
      Returns:
      the item value
    • getContainer

      public CollectionContainer<T> getContainer()
      Description copied from interface: ContainerDataUnit
      Returns the CollectionContainer associated with this data unit.
      Specified by:
      getContainer in interface ContainerDataUnit<T>
      Returns:
      the container that holds a collection of entity instances
    • getState

      public BindingState getState()
      Specified by:
      getState in interface DataUnit
      Returns:
      a state of this source
    • getEntityMetaClass

      public MetaClass getEntityMetaClass()
      Specified by:
      getEntityMetaClass in interface EntityDataUnit
      Returns:
      MetaClass of an entity contained in the source
    • addStateChangeListener

      public com.vaadin.flow.shared.Registration addStateChangeListener(Consumer<DataUnit.StateChangeEvent> listener)
      Description copied from interface: DataUnit
      Registers a new state change listener.
      Specified by:
      addStateChangeListener in interface DataUnit
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • getType

      public Class<T> getType()
      Specified by:
      getType in interface HasType<T>
      Returns:
      type of value
    • getEventBus

      protected EventBus getEventBus()