Interface Tree<E>

Type Parameters:
E - an entity type
All Superinterfaces:
ActionsHolder, Component, Component.BelongToFrame, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, HasButtonsPanel, HasContextHelp, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasItemCaptionProvider<E>, HasSubParts, ListComponent<E>, LookupComponent<E>
All Known Implementing Classes:
TreeImpl

@StudioComponent(caption="Tree", category="Components", xmlElement="tree", icon="io/jmix/ui/icon/component/tree.svg", canvasBehaviour=TREE, documentationURL="https://docs.jmix.io/jmix/%VERSION%/ui/vcl/components/tree.html") public interface Tree<E> extends ListComponent<E>, HasButtonsPanel, Component.HasCaption, Component.HasIcon, LookupComponent<E>, Component.Focusable, HasContextHelp, HasItemCaptionProvider<E>, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer
A component is intended to display hierarchical structures represented by entities referencing themselves.
  • Field Details

  • Method Details

    • of

      static <T> org.springframework.core.ParameterizedTypeReference<Tree<T>> of(Class<T> itemClass)
    • expandTree

      void expandTree()
      Expands all tree nodes.
    • expand

      void expand(E item)
      Expands all tree nodes that are higher in level that a given item.
      Parameters:
      item - an item
    • collapseTree

      void collapseTree()
      Collapses tree nodes.
    • collapse

      void collapse(E item)
      Collapses all tree nodes that are lower in level than a given item.
      Parameters:
      item - an item
    • expandUpTo

      void expandUpTo(int level)
      Expands tree including specified level
      Parameters:
      level - level of Tree nodes to expand, if passed level = 1 then root items will be expanded
      Throws:
      IllegalArgumentException - if level < 1
    • isExpanded

      boolean isExpanded(Object itemId)
      Returns whether an item with given itemId is expanded or collapsed.
      Parameters:
      itemId - item id to check
      Returns:
      true if the item with itemId is expanded, false if collapsed
    • getHierarchyProperty

      String getHierarchyProperty()
      Returns:
      the name of the property which forms the hierarchy
    • getItems

      @Nullable TreeItems<E> getItems()
      Specified by:
      getItems in interface ListComponent<E>
      Returns:
      a DataUnit supported by the Tree
    • setItems

      void setItems(@Nullable TreeItems<E> treeItems)
      Sets a DataUnit supported by the Tree.
      Parameters:
      treeItems - DataUnit supported by the Tree
    • setItemClickAction

      void setItemClickAction(@Nullable Action action)
      Sets the action to be executed when double-clicking inside a tree node.
      Parameters:
      action - a new action
    • getItemClickAction

      @Nullable Action getItemClickAction()
      Returns:
      an item double-click action
    • setStyleProvider

      void setStyleProvider(@Nullable Function<? super E,String> styleProvider)
      Sets a single style provider for tree items.
      Parameters:
      styleProvider - a style provider to set
    • addStyleProvider

      void addStyleProvider(Function<? super E,String> styleProvider)
      Adds a style provider for tree items.
      Parameters:
      styleProvider - a style provider to add
    • removeStyleProvider

      void removeStyleProvider(Function<? super E,String> styleProvider)
      Removes a previously added style provider.
      Parameters:
      styleProvider - a style provider to remove
    • setIconProvider

      void setIconProvider(@Nullable Function<? super E,String> iconProvider)
      Sets the icon provider for the tree.
      Parameters:
      iconProvider - an icon provider to set
    • repaint

      void repaint()
      Repaints UI representation of the tree including style providers and icon providers without refreshing the tree data.
    • setEnterPressAction

      void setEnterPressAction(@Nullable Action action)
      Sets the action to be executed on Enter key press.
      Parameters:
      action - a new action
    • getEnterPressAction

      @Nullable Action getEnterPressAction()
      Returns:
      an Enter key press action
    • getSelectionMode

      Tree.SelectionMode getSelectionMode()
      Returns:
      the currently used Tree.SelectionMode
    • setSelectionMode

      @StudioProperty(type=ENUMERATION, defaultValue="SINGLE", options={"SINGLE","MULTI","NONE"}) void setSelectionMode(Tree.SelectionMode selectionMode)
      Sets the Tree's selection mode.
      Parameters:
      selectionMode - the selection mode to use
    • isContextMenuEnabled

      boolean isContextMenuEnabled()
      Returns:
      true if context menu is enabled, false otherwise
    • setContextMenuEnabled

      void setContextMenuEnabled(boolean contextMenuEnabled)
      Sets whether or not context menu is enabled. Default value is true.
      Parameters:
      contextMenuEnabled - specifies whether context menu is enabled
    • setDescriptionProvider

      void setDescriptionProvider(@Nullable Function<? super E,String> provider)
      Sets the description generator that is used for generating tooltip descriptions for items.
      Parameters:
      provider - the description generator to use or null to remove a previously set provider if any
    • setDescriptionProvider

      void setDescriptionProvider(@Nullable Function<? super E,String> provider, ContentMode contentMode)
      Sets the description generator that is used for generating HTML tooltip descriptions for items.
      Parameters:
      provider - the description generator to use or null to remove a previously set provider if any
      contentMode - the content mode for row tooltips
    • getDescriptionProvider

      @Nullable Function<E,String> getDescriptionProvider()
      Gets the item description generator.
      Returns:
      the item description generator
    • getDetailsGenerator

      @Nullable Function<E,Component> getDetailsGenerator()
      Returns:
      the current details generator for item details or null if not set
    • setDetailsGenerator

      void setDetailsGenerator(@Nullable Function<E,Component> generator)
      Sets a new details generator for item details.

      The currently opened item details will be re-rendered.

      Parameters:
      generator - the details generator to set
    • isDetailsVisible

      boolean isDetailsVisible(E entity)
      Checks whether details are visible for the given item.
      Parameters:
      entity - the item for which to check details visibility
      Returns:
      true if the details are visible
    • setDetailsVisible

      void setDetailsVisible(E entity, boolean visible)
      Shows or hides the details for a specific item.
      Parameters:
      entity - the item for which to set details visibility
      visible - true to show the details, or false to hide them
    • addExpandListener

      Subscription addExpandListener(Consumer<Tree.ExpandEvent<E>> listener)
      Registers a new expand listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addCollapseListener

      Subscription addCollapseListener(Consumer<Tree.CollapseEvent<E>> listener)
      Registers a new collapse listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • setRowHeight

      @StudioProperty(defaultValue="-1.0") @Min(-1L) void setRowHeight(double rowHeight)
      Sets the height of a row. If -1 (default), the row height is calculated based on the theme for an empty row before the Tree is displayed.
      Parameters:
      rowHeight - The height of a row in pixels or -1 for automatic calculation
    • getContentMode

      ContentMode getContentMode()
      Returns:
      the content mode of the item captions
    • setContentMode

      @StudioProperty(type=ENUMERATION, defaultValue="TEXT", options={"TEXT","PREFORMATTED","HTML"}) void setContentMode(ContentMode contentMode)
      Sets the content mode of the item captions.
      Parameters:
      contentMode - the content mode
    • addSelectionListener

      Subscription addSelectionListener(Consumer<Tree.SelectionEvent<E>> listener)
      Registers a new selection listener.
      Parameters:
      listener - the listener to register