Class ContainerGroupDataGridItems<T>

java.lang.Object
com.vaadin.flow.data.provider.AbstractDataProvider<T,Void>
io.jmix.flowui.data.grid.ContainerDataGridItems<T>
io.jmix.groupgridflowui.data.ContainerGroupDataGridItems<T>
All Implemented Interfaces:
com.vaadin.flow.data.provider.DataProvider<T,Void>, com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,Void>, GroupDataGridItems<T>, ContainerDataUnit<T>, DataUnit, EntityDataUnit, DataGridItems<T>, DataGridItems.Sortable<T>, EntityDataGridItems<T>, HasType<T>, Serializable, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class ContainerGroupDataGridItems<T> extends ContainerDataGridItems<T> implements GroupDataGridItems<T>, org.springframework.context.ApplicationContextAware
See Also:
  • Field Details

  • Constructor Details

    • ContainerGroupDataGridItems

      public ContainerGroupDataGridItems(CollectionContainer<T> container)
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • containerCollectionChanged

      protected void containerCollectionChanged(CollectionContainer.CollectionChangeEvent<T> event)
      Overrides:
      containerCollectionChanged in class ContainerDataGridItems<T>
    • 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>
      Overrides:
      sort in class ContainerDataGridItems<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
    • groupBy

      public void groupBy(List<GroupProperty> properties)
      Description copied from interface: GroupDataGridItems
      Perform grouping by the list of properties. The available values for properties are:
      • MetaPropertyPath can be a property of current or a reference entity.
      • Column key (String) of a generated value.
      Specified by:
      groupBy in interface GroupDataGridItems<T>
    • doGroup

      protected void doGroup()
    • groupItems

      @Nullable protected GroupInfo groupItems(int propertyIndex, @Nullable GroupInfo parent, Collection<GroupInfo> children, T item, org.apache.commons.collections4.map.LinkedMap<GroupProperty,Object> groupValues)
    • getValueByProperty

      @Nullable protected Object getValueByProperty(T item, GroupProperty property)
    • getRootGroups

      public List<GroupInfo> getRootGroups()
      Specified by:
      getRootGroups in interface GroupDataGridItems<T>
      Returns:
      the list of root groups
    • hasChildren

      public boolean hasChildren(GroupInfo groupInfo)
      Description copied from interface: GroupDataGridItems
      Indicates that the group has nested groups
      Specified by:
      hasChildren in interface GroupDataGridItems<T>
      Parameters:
      groupInfo - group info
    • hasChildren

      public boolean hasChildren(T item)
      Specified by:
      hasChildren in interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,Void>
    • getChildren

      public List<GroupInfo> getChildren(GroupInfo group)
      Specified by:
      getChildren in interface GroupDataGridItems<T>
      Returns:
      the list of own nested groups
    • getOwnChildItems

      public List<T> getOwnChildItems(GroupInfo group)
      Specified by:
      getOwnChildItems in interface GroupDataGridItems<T>
      Returns:
      the list of nested items
    • getChildItems

      public List<T> getChildItems(GroupInfo group)
      Specified by:
      getChildItems in interface GroupDataGridItems<T>
      Returns:
      the list of items from all nested group levels
    • getChildrenInternal

      protected Set<GroupInfo> getChildrenInternal(GroupInfo group)
    • getGroup

      @Nullable public GroupInfo getGroup(T item)
      Specified by:
      getGroup in interface GroupDataGridItems<T>
      Returns:
      a group that the passed item belongs to
    • getGroupPath

      public List<GroupInfo> getGroupPath(T item)
      Specified by:
      getGroupPath in interface GroupDataGridItems<T>
      Parameters:
      item - item (leaf) to get all parent groups for
      Returns:
      the path through all parent groups
    • getGroupItems

      public Collection<T> getGroupItems(GroupInfo group)
      Specified by:
      getGroupItems in interface GroupDataGridItems<T>
      Returns:
      items that are contained in the selected group
    • getGroupItemsCount

      public int getGroupItemsCount(GroupInfo group)
      Specified by:
      getGroupItemsCount in interface GroupDataGridItems<T>
      Returns:
      a count of items that are contained in the selected group
    • hasGroups

      public boolean hasGroups()
      Description copied from interface: GroupDataGridItems
      Indicates that items have groups
      Specified by:
      hasGroups in interface GroupDataGridItems<T>
    • getGroupProperties

      public Collection<GroupProperty> getGroupProperties()
      Specified by:
      getGroupProperties in interface GroupDataGridItems<T>
      Returns:
      group properties
    • containsGroup

      public boolean containsGroup(GroupInfo group)
      Description copied from interface: GroupDataGridItems
      Indicates that a group is contained in the group tree
      Specified by:
      containsGroup in interface GroupDataGridItems<T>
    • addGroupPropertyDescriptor

      public void addGroupPropertyDescriptor(GroupPropertyDescriptor<T> groupPropertyDescriptor)
      Description copied from interface: GroupDataGridItems
      Adds a group property descriptor for a custom grouping property. This method enables defining custom logic for computing property values during data grouping.

      For instance:

       customersDataGrid.getItems().addGroupPropertyDescriptor(
               new BaseGroupPropertyDescriptor<Customer>("fullName", context -> {
                   Customer item = context.getItem();
                   return item.getFirstName() + " " + item.getLastName();
               }).withSortProperties(List.of("firstName", "lastName")));
       
      Specified by:
      addGroupPropertyDescriptor in interface GroupDataGridItems<T>
      Parameters:
      groupPropertyDescriptor - implementation of GroupPropertyDescriptor
    • removeGroupPropertyDescriptor

      public void removeGroupPropertyDescriptor(GroupProperty property)
      Description copied from interface: GroupDataGridItems
      Removes a group property descriptor for a custom property that was previously added for grouping.
      Specified by:
      removeGroupPropertyDescriptor in interface GroupDataGridItems<T>
      Parameters:
      property - the custom property
    • getGroupPropertyDescriptor

      @Nullable public GroupPropertyDescriptor<T> getGroupPropertyDescriptor(GroupProperty property)
      Specified by:
      getGroupPropertyDescriptor in interface GroupDataGridItems<T>
      Parameters:
      property - the custom property
      Returns:
      a group property descriptor for a custom property
    • removeAllGroupPropertyProviders

      public void removeAllGroupPropertyProviders()
      Description copied from interface: GroupDataGridItems
      Removes all group property descriptors previously added for grouping.
      Specified by:
      removeAllGroupPropertyProviders in interface GroupDataGridItems<T>
    • getGroupByItem

      @Nullable public GroupInfo getGroupByItem(T groupItem)
      Description copied from interface: GroupDataGridItems
      Returns GroupInfo by a group item.

      Group item is an empty entity object that represents a grouping row in a GroupListDataComponent. It does not exist in the data container.

      Specified by:
      getGroupByItem in interface GroupDataGridItems<T>
      Parameters:
      groupItem - a group item
      Returns:
      group info or null if there is no group info for the given item
    • getItemByGroup

      @Nullable public T getItemByGroup(GroupInfo group)
      Description copied from interface: GroupDataGridItems
      Returns a group item that corresponds to the provided GroupInfo.

      Group item is an empty entity object that represents a grouping row in a GroupListDataComponent. It does not exist in the data container.

      Specified by:
      getItemByGroup in interface GroupDataGridItems<T>
      Parameters:
      group - group info
      Returns:
      group item or null if there is no item for the given group info
    • getChildCount

      public int getChildCount(com.vaadin.flow.data.provider.hierarchy.HierarchicalQuery<T,Void> query)
      Specified by:
      getChildCount in interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,Void>
    • fetchChildren

      public Stream<T> fetchChildren(com.vaadin.flow.data.provider.hierarchy.HierarchicalQuery<T,Void> query)
      Specified by:
      fetchChildren in interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,Void>
    • addGroupPropertyDescriptorsChangedListener

      public com.vaadin.flow.shared.Registration addGroupPropertyDescriptorsChangedListener(Consumer<GroupDataGridItems.GroupPropertyDescriptorsChangedEvent<T>> listener)
      Description copied from interface: GroupDataGridItems
      Adds a listener to be notified when the group property descriptors are changed.
      Specified by:
      addGroupPropertyDescriptorsChangedListener in interface GroupDataGridItems<T>
      Parameters:
      listener - the listener to add
      Returns:
      a registration object for removing the listener
    • isGroupRow

      public boolean isGroupRow(T item)
    • updateGroupRows

      protected void updateGroupRows()
    • collectOwnChildren

      protected Stream<T> collectOwnChildren(@Nullable T parent)
    • collectGroupRowsRecursively

      protected void collectGroupRowsRecursively(GroupInfo group, com.google.common.collect.BiMap<T,GroupInfo> childGroupRows)
    • createGroupItem

      @Nullable protected T createGroupItem()
    • refreshGroups

      protected void refreshGroups()
    • afterGroupBy

      protected void afterGroupBy()
    • checkForUnsupportedProperties

      protected void checkForUnsupportedProperties(List<GroupProperty> properties)
    • createGroupInfo

      protected GroupInfo createGroupInfo(@Nullable GroupInfo parent, org.apache.commons.collections4.map.LinkedMap<GroupProperty,Object> groupValues)