Class TreeDataGridImpl<E>

All Implemented Interfaces:
ActionsHolder, AttachNotifier, Component, Component.BelongToFrame, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper, DataGrid<E>, DataGridItemsEventsDelegate<E>, HasButtonsPanel, HasContextHelp, HasDebugId, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasInnerComponents, HasMinSize, HasPagination, HasSubParts, ListComponent<E>, LookupComponent<E>, LookupComponent.LookupSelectionChangeNotifier<E>, SecuredActionsHolder, TreeDataGrid<E>, org.springframework.beans.factory.InitializingBean

public class TreeDataGridImpl<E> extends AbstractDataGrid<JmixTreeGrid<E>,E> implements TreeDataGrid<E>
  • Field Details

    • itemCollapseAllowedProvider

      protected Predicate<E> itemCollapseAllowedProvider
    • expandListener

      protected com.vaadin.shared.Registration expandListener
    • collapseListener

      protected com.vaadin.shared.Registration collapseListener
    • hierarchyColumn

      protected DataGrid.Column<E> hierarchyColumn
  • Constructor Details

    • TreeDataGridImpl

      public TreeDataGridImpl()
  • Method Details

    • createComponent

      protected JmixTreeGrid<E> createComponent()
      Specified by:
      createComponent in class AbstractDataGrid<JmixTreeGrid<E>,E>
    • onColumnReorder

      protected void onColumnReorder(com.vaadin.ui.Grid.ColumnReorderEvent e)
      Overrides:
      onColumnReorder in class AbstractDataGrid<JmixTreeGrid<E>,E>
    • getLevel

      public int getLevel(E item)
      Description copied from interface: TreeDataGrid
      Returns the hierarchy level of an item.
      Specified by:
      getLevel in interface TreeDataGrid<E>
      Parameters:
      item - the item to get level
      Returns:
      the level of the given item
    • getItems

      @Nullable public TreeDataGridItems<E> getItems()
      Specified by:
      getItems in interface DataGrid<E>
      Specified by:
      getItems in interface ListComponent<E>
      Specified by:
      getItems in interface TreeDataGrid<E>
      Overrides:
      getItems in class AbstractDataGrid<JmixTreeGrid<E>,E>
      Returns:
      The DataGrid source
    • getTreeDataGridItemsNN

      protected TreeDataGridItems<E> getTreeDataGridItemsNN()
    • setItems

      public void setItems(@Nullable DataGridItems<E> dataGridItems)
      Description copied from interface: DataGrid
      Sets an instance of DataGridItems as the DataGrid data source.
      Specified by:
      setItems in interface DataGrid<E>
      Overrides:
      setItems in class AbstractDataGrid<JmixTreeGrid<E>,E>
      Parameters:
      dataGridItems - the DataGrid data source
    • createEmptyDataProvider

      protected com.vaadin.data.provider.DataProvider<E,?> createEmptyDataProvider()
      Overrides:
      createEmptyDataProvider in class AbstractDataGrid<JmixTreeGrid<E>,E>
    • initComponent

      protected void initComponent(com.vaadin.ui.Grid<E> component)
      Overrides:
      initComponent in class AbstractDataGrid<JmixTreeGrid<E>,E>
    • createDataGridDataProvider

      protected DataGridDataProvider<E> createDataGridDataProvider(DataGridItems<E> dataGridItems)
      Overrides:
      createDataGridDataProvider in class AbstractDataGrid<JmixTreeGrid<E>,E>
    • editItemInternal

      protected void editItemInternal(E itemToEdit)
      Overrides:
      editItemInternal in class AbstractDataGrid<JmixTreeGrid<E>,E>
    • getVisibleItemsConsideringHierarchy

      protected List<E> getVisibleItemsConsideringHierarchy()
    • isItemVisible

      protected boolean isItemVisible(E item)
    • getItemCollapseAllowedProvider

      public Predicate<E> getItemCollapseAllowedProvider()
      Specified by:
      getItemCollapseAllowedProvider in interface TreeDataGrid<E>
      Returns:
      the item collapse allowed provider
    • setItemCollapseAllowedProvider

      public void setItemCollapseAllowedProvider(Predicate<E> provider)
      Description copied from interface: TreeDataGrid
      Sets the item collapse allowed provider for this TreeDataGrid. The provider should return true for any item that the user can collapse.

      Note: This callback will be accessed often when sending data to the client. The callback should not do any costly operations.

      Specified by:
      setItemCollapseAllowedProvider in interface TreeDataGrid<E>
      Parameters:
      provider - the item collapse allowed provider, not null
    • getHierarchyColumn

      @Nullable public DataGrid.Column<E> getHierarchyColumn()
      Description copied from interface: TreeDataGrid
      Get the currently set hierarchy column. The hierarchy column is a column that displays the hierarchy of this DataGrid's data.
      Specified by:
      getHierarchyColumn in interface TreeDataGrid<E>
      Returns:
      the currently set hierarchy column, or null if no column has been explicitly set
    • setHierarchyColumn

      public void setHierarchyColumn(String id)
      Description copied from interface: TreeDataGrid
      Set the column that displays the hierarchy of this DataGrid's data. By default the hierarchy will be displayed in the first column.

      Setting a hierarchy column by calling this method also sets the column to be visible and not hidable.

      Note: Changing the Renderer of the hierarchy column is not supported.

      Specified by:
      setHierarchyColumn in interface TreeDataGrid<E>
      Parameters:
      id - the column id to use for displaying hierarchy
    • setHierarchyColumn

      public void setHierarchyColumn(DataGrid.Column<E> column)
      Description copied from interface: TreeDataGrid
      Set the column that displays the hierarchy of this DataGrid's data. By default the hierarchy will be displayed in the first column.

      Setting a hierarchy column by calling this method also sets the column to be visible and not hidable.

      Note: Changing the Renderer of the hierarchy column is not supported.

      Specified by:
      setHierarchyColumn in interface TreeDataGrid<E>
      Parameters:
      column - the column to use for displaying hierarchy
    • setHierarchyColumnInternal

      protected void setHierarchyColumnInternal(com.vaadin.ui.Grid.Column<E,?> newHierarchyColumn)
    • updateColumnCollapsible

      protected void updateColumnCollapsible(com.vaadin.ui.Grid.Column<E,?> vColumn)
    • expand

      public void expand(Collection<E> items)
      Description copied from interface: TreeDataGrid
      Expands the given items.

      If an item is currently expanded, does nothing. If an item does not have any children, does nothing.

      Specified by:
      expand in interface TreeDataGrid<E>
      Parameters:
      items - the items to expand
      See Also:
    • expandRecursively

      public void expandRecursively(Stream<E> items, int depth)
      Description copied from interface: TreeDataGrid
      Expands the given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that expandRecursively(items, 0) expands only the given items while expandRecursively(items, 2) expands the given items as well as their children and grandchildren.

      This method will not fire events for expanded nodes.

      Specified by:
      expandRecursively in interface TreeDataGrid<E>
      Parameters:
      items - the items to expand recursively
      depth - the maximum depth of recursion
      See Also:
    • expandAll

      public void expandAll()
      Description copied from interface: TreeDataGrid
      Expands all items.

      This method will not fire events for expanded nodes.

      Specified by:
      expandAll in interface TreeDataGrid<E>
    • collapse

      public void collapse(Collection<E> items)
      Description copied from interface: TreeDataGrid
      Collapse the given items.

      For items that are already collapsed, does nothing.

      Specified by:
      collapse in interface TreeDataGrid<E>
      Parameters:
      items - the items to collapse
      See Also:
    • collapseRecursively

      public void collapseRecursively(Stream<E> items, int depth)
      Description copied from interface: TreeDataGrid
      Collapse the given items and their children recursively until the given depth.

      depth describes the maximum distance between a given item and its descendant, meaning that collapseRecursively(items, 0) collapses only the given items while collapseRecursively(items, 2) collapses the given items as well as their children and grandchildren.

      This method will not fire events for collapsed nodes.

      Specified by:
      collapseRecursively in interface TreeDataGrid<E>
      Parameters:
      items - the items to collapse recursively
      depth - the maximum depth of recursion
      See Also:
    • collapseAll

      public void collapseAll()
      Description copied from interface: TreeDataGrid
      Collapses all items.

      This method will not fire events for expanded nodes.

      Specified by:
      collapseAll in interface TreeDataGrid<E>
    • isExpanded

      public boolean isExpanded(E item)
      Description copied from interface: TreeDataGrid
      Returns whether a given item is expanded or collapsed.
      Specified by:
      isExpanded in interface TreeDataGrid<E>
      Parameters:
      item - the item to check
      Returns:
      true if the item is expanded, false otherwise
    • addExpandListener

      public Subscription addExpandListener(Consumer<TreeDataGrid.ExpandEvent<E>> listener)
      Description copied from interface: TreeDataGrid
      Registers a new expand listener.
      Specified by:
      addExpandListener in interface TreeDataGrid<E>
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • onItemExpand

      protected void onItemExpand(com.vaadin.event.ExpandEvent<E> e)
    • addCollapseListener

      public Subscription addCollapseListener(Consumer<TreeDataGrid.CollapseEvent<E>> listener)
      Description copied from interface: TreeDataGrid
      Registers a new collapse listener.
      Specified by:
      addCollapseListener in interface TreeDataGrid<E>
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • onItemCollapse

      protected void onItemCollapse(com.vaadin.event.CollapseEvent<E> e)
    • scrollTo

      public void scrollTo(E item, DataGrid.ScrollDestination destination)
      Description copied from interface: DataGrid
      Scrolls to a certain item, using user-specified scroll destination.
      Specified by:
      scrollTo in interface DataGrid<E>
      Overrides:
      scrollTo in class AbstractDataGrid<JmixTreeGrid<E>,E>
      Parameters:
      item - item to scroll to
      destination - value specifying desired position of scrolled-to row
      See Also: