Class JmixGroupGrid<T>

java.lang.Object
com.vaadin.flow.component.Component
io.jmix.groupgridflowui.kit.vaadin.grid.Grid<T>
io.jmix.groupgridflowui.kit.component.JmixGroupGrid<T>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<Grid<T>>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<Grid<T>>, com.vaadin.flow.component.FocusNotifier<Grid<T>>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.data.event.SortEvent.SortNotifier<Grid<T>,GridSortOrder<T>>, com.vaadin.flow.data.provider.HasDataGenerators<T>, com.vaadin.flow.data.provider.HasDataView<T,Void,GridDataView<T>>, com.vaadin.flow.data.provider.HasLazyDataView<T,Void,GridLazyDataView<T>>, com.vaadin.flow.data.provider.HasListDataView<T,GridListDataView<T>>, com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>, HasActions, HasSubParts, SelectionChangeNotifier<Grid<T>,T>, Serializable
Direct Known Subclasses:
GroupDataGrid

public class JmixGroupGrid<T> extends Grid<T> implements SelectionChangeNotifier<Grid<T>,T>, HasSubParts, HasActions, com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>
See Also:
  • Field Details

  • Constructor Details

    • JmixGroupGrid

      public JmixGroupGrid()
  • Method Details

    • addAction

      public void addAction(Action action)
      Description copied from interface: HasActions
      Add an action to the component.
      Specified by:
      addAction in interface HasActions
      Parameters:
      action - action to add
    • addAction

      public void addAction(Action action, int index)
      Description copied from interface: HasActions
      Add an action to the component at the specified index.
      Specified by:
      addAction in interface HasActions
      Parameters:
      action - action to add
      index - index at which the specified action is to be added
    • removeAction

      public void removeAction(Action action)
      Description copied from interface: HasActions
      Removes the action from the component.
      Specified by:
      removeAction in interface HasActions
      Parameters:
      action - action to remove
    • getActions

      public Collection<Action> getActions()
      Specified by:
      getActions in interface HasActions
      Returns:
      unmodifiable collection of actions
    • getAction

      public @Nullable Action getAction(String id)
      Description copied from interface: HasActions
      Returns an action with passed id.
      Specified by:
      getAction in interface HasActions
      Parameters:
      id - id of the action to find
      Returns:
      an action by its id, or null if not found
    • getActionsSupport

      public JmixGroupGridActionsSupport<JmixGroupGrid<T>,T> getActionsSupport()
      Returns:
      the actions support instance for the grid
    • getSubPart

      public @Nullable Object getSubPart(String name)
      Description copied from interface: HasSubParts
      Returns a sub part object by its name.
      Specified by:
      getSubPart in interface HasSubParts
      Parameters:
      name - sub part name, e.g. component id
      Returns:
      a sub part object by its name, or null if not found
    • getDataCommunicator

      public com.vaadin.flow.data.provider.hierarchy.HierarchicalDataCommunicator<T> getDataCommunicator()
      Description copied from class: Grid
      Returns the data communicator of this Grid.
      Overrides:
      getDataCommunicator in class Grid<T>
      Returns:
      the data communicator, not null
    • addItemClickListener

      public com.vaadin.flow.shared.Registration addItemClickListener(com.vaadin.flow.component.ComponentEventListener<ItemClickEvent<T>> listener)
      Description copied from class: Grid
      Adds an item click listener to this component.
      Overrides:
      addItemClickListener in class Grid<T>
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
      See Also:
    • addItemDoubleClickListener

      public com.vaadin.flow.shared.Registration addItemDoubleClickListener(com.vaadin.flow.component.ComponentEventListener<ItemDoubleClickEvent<T>> listener)
      Description copied from class: Grid
      Adds an item double click listener to this component.

      Note that double click event happens along with a click event. It means there is no way to get a double click event only (double click without a click): a click listener added using Grid.addItemClickListener(ComponentEventListener) (if any) will also be notified about a click event once a double click event is fired.

      Double click event type is not fully supported by the mobile browsers which means that double click event might not work (double click listeners won't be notified) for such browsers.

      Overrides:
      addItemDoubleClickListener in class Grid<T>
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
      See Also:
    • getDataProvider

      public @Nullable com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,com.vaadin.flow.function.SerializablePredicate<T>> getDataProvider()
      Returns the data provider of this grid.

      To get information and control over the items in the grid, use either Grid.getListDataView() or Grid.getLazyDataView() instead.

      Specified by:
      getDataProvider in interface com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>
      Overrides:
      getDataProvider in class Grid<T>
      Returns:
      the data provider of this grid or null if the data provider is not a subclass of HierarchicalDataProvider.
    • setDataProvider

      public void setDataProvider(com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider<T,?> hierarchicalDataProvider)
      Specified by:
      setDataProvider in interface com.vaadin.flow.data.provider.hierarchy.HasHierarchicalDataProvider<T>
    • setDataProvider

      @Deprecated public void setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Group grid only supports hierarchical data providers. Use setDataProvider(HierarchicalDataProvider) instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Overrides:
      setDataProvider in class Grid<T>
      Parameters:
      dataProvider - the data provider
    • setItems

      @Deprecated public GridLazyDataView<T> setItems(com.vaadin.flow.data.provider.BackEndDataProvider<T,Void> dataProvider)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Group grid does not support data views. Use setDataProvider(HierarchicalDataProvider) instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasLazyDataView<T,Void,GridLazyDataView<T>>
      Overrides:
      setItems in class Grid<T>
      Parameters:
      dataProvider - the data provider
      Returns:
      the data view
    • setItems

      @Deprecated public GridLazyDataView<T> setItems(com.vaadin.flow.data.provider.CallbackDataProvider.FetchCallback<T,Void> fetchCallback)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Group grid supports only hierarchical data so use another method instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasLazyDataView<T,Void,GridLazyDataView<T>>
      Parameters:
      fetchCallback - the fetch callback
      Returns:
      the data view
    • setItems

      @Deprecated public GridListDataView<T> setItems(com.vaadin.flow.data.provider.ListDataProvider<T> dataProvider)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Group grid supports only hierarchical data providers so use another method instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,GridListDataView<T>>
      Overrides:
      setItems in class Grid<T>
      Parameters:
      dataProvider - the data provider
      Returns:
      the data view
    • setItems

      @Deprecated public GridListDataView<T> setItems(T... items)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Group grid supports only hierarchical data so use another method instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,GridListDataView<T>>
      Parameters:
      items - the items to display, not null
      Returns:
      the data view
    • setItems

      @Deprecated public GridListDataView<T> setItems(Collection<T> items)
      Deprecated.
      use setDataProvider(HierarchicalDataProvider), HasHierarchicalDataProvider.setItems(Collection, ValueProvider), HasHierarchicalDataProvider.setItems(Stream, ValueProvider) or HasHierarchicalDataProvider.setTreeData(TreeData) instead.
      Group grid supports only hierarchical data, so use another method instead.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,GridListDataView<T>>
      Parameters:
      items - the items to display, not null
      Returns:
      the data view
    • getListDataView

      @Deprecated public GridListDataView<T> getListDataView()
      Deprecated.
      not supported
      Group grid does not support list data view.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      getListDataView in interface com.vaadin.flow.data.provider.HasListDataView<T,GridListDataView<T>>
      Overrides:
      getListDataView in class Grid<T>
      Returns:
      exception is thrown
    • getLazyDataView

      @Deprecated public GridLazyDataView<T> getLazyDataView()
      Deprecated.
      not supported
      Group grid does not support list data view.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      getLazyDataView in interface com.vaadin.flow.data.provider.HasLazyDataView<T,Void,GridLazyDataView<T>>
      Overrides:
      getLazyDataView in class Grid<T>
      Returns:
      an exception is thrown
    • getGenericDataView

      @Deprecated public GridDataView<T> getGenericDataView()
      Deprecated.
      not supported
      Group grid does not support list data view.

      This method is inherited from Grid and has been marked as deprecated to indicate that it is not supported. This method will throw an UnsupportedOperationException.

      Specified by:
      getGenericDataView in interface com.vaadin.flow.data.provider.HasDataView<T,Void,GridDataView<T>>
      Overrides:
      getGenericDataView in class Grid<T>
      Returns:
      an exception is thrown
      See Also:
    • scrollToIndex

      public void scrollToIndex(int index)
      Scrolls to the index of an item so that the row is shown at the start of the visible area whenever possible. The way the index parameter is interpreted depends on the hierarchy format of the current data provider:

      HierarchicalDataProvider.HierarchyFormat.NESTED: the index refers to an item in the root level. To reach items in deeper levels, use scrollToIndex(int...), which accepts a hierarchical path.

      HierarchicalDataProvider.HierarchyFormat.FLATTENED: the index refers to an item in the entire flattened tree, not only the root level, allowing items at any expanded level to be reached with this method.

      If the index exceeds the valid range, scrolling stops at the last available item.

      Overrides:
      scrollToIndex in class Grid<T>
      Parameters:
      index - zero based index of the item to scroll to
    • scrollToIndex

      public void scrollToIndex(int... path)
      Scrolls to a nested item specified by its hierarchical path.

      The hierarchical path is an array of zero-based indexes, where each index refers to a child of the item at the previous index. Scrolling continues until it reaches the last index in the array or encounters a collapsed item.

      For example, given &#123; 2, 1, ... &#125; as the path, the component will first try to scroll to the item at index 2 in the root level. If that item is expanded, it will then try to scroll to the item at index 1 among its children, and so forth.

      This method is only supported for data providers that use HierarchicalDataProvider.HierarchyFormat.NESTED. For HierarchicalDataProvider.HierarchyFormat.FLATTENED, use scrollToIndex(int) with a flat index instead.

      Parameters:
      path - an array of indexes representing the path to the target item
      Throws:
      IllegalArgumentException - if the path is empty
      UnsupportedOperationException - if the data provider uses a hierarchy format other than HierarchicalDataProvider.HierarchyFormat.NESTED
    • scrollToEnd

      public void scrollToEnd()
      Description copied from class: Grid
      Scrolls to the last data row of the grid.
      Overrides:
      scrollToEnd in class Grid<T>
    • scrollToItem

      public void scrollToItem(T item)
      Scrolls to the given item unless it is already fully visible. Before scrolling, this method automatically expands all ancestor items leading to the target item, but it does not fire any ExpandEvent while doing so.

      For this method to work, the data provider must implement two methods: HierarchicalDataProvider.getParent(Object) and HierarchicalDataProvider.getItemIndex(Object, HierarchicalQuery).

      Depending on the type of data provider, some of these methods may already be implemented. Otherwise, you have to implement them manually. The table below shows which methods are required in each case:

      DataProvider isInMemory() getItemIndex(item, query) getParent(item)
      TreeDataProvider true not required not required
      HierarchicalDataProvider true not required required
      HierarchicalDataProvider false required required
      Overrides:
      scrollToItem in class Grid<T>
      Parameters:
      item - the item to scroll to
      Throws:
      NoSuchElementException - if the item does not belong to the tree
    • setItemSelectableProvider

      public void setItemSelectableProvider(@Nullable com.vaadin.flow.function.SerializablePredicate<T> provider)
      Description copied from class: Grid
      Sets a predicate to check whether a specific item in the grid may be selected or deselected by the user. The predicate receives an item instance and should return true if a user may change the selection state of that item, or false otherwise.

      This function does not prevent programmatic selection/deselection of items. Changing the function does not modify the currently selected items.

      When using multi-selection, setting a provider will hide the select all checkbox.

      Overrides:
      setItemSelectableProvider in class Grid<T>
      Parameters:
      provider - the function to use to determine whether an item may be selected or deselected by the user, or null to allow all items to be selected or deselected
    • getDefaultHeaderRow

      public HeaderRow getDefaultHeaderRow()
      Overrides:
      getDefaultHeaderRow in class Grid<T>
      Returns:
      a default header row
    • createActionsSupport

      protected JmixGroupGridActionsSupport<JmixGroupGrid<T>,T> createActionsSupport()
    • onItemSelect

      protected boolean onItemSelect(T item)
    • createDetailsManager

      protected Grid<T>.DetailsManager createDetailsManager()
      Overrides:
      createDetailsManager in class Grid<T>
    • expand

      protected void expand(Collection<T> items, boolean userOriginated)
    • collapse

      protected void collapse(Collection<T> items, boolean userOriginated)
    • fireExpandEvent

      protected void fireExpandEvent(Collection<T> collapsedItems, boolean userOriginated)
    • fireCollapseEvent

      protected void fireCollapseEvent(Collection<T> expandedItems, boolean userOriginated)
    • refreshViewport

      protected void refreshViewport()
      Overrides:
      refreshViewport in class Grid<T>
    • initConnector

      protected void initConnector()
      Overrides:
      initConnector in class Grid<T>