Class TreeGroup


public class TreeGroup extends Div
A collapsible group within a FilterableTree.

A TreeGroup consists of a clickable header that expands/collapses to show/hide its child items. When the tree is filtered, groups automatically expand to show matching items and hide when they contain no matches.

Example usage:

 TreeGroup group = tree.addGroup("com.oorian.html");
 group.addItem("Element", "/docs/Element.html");
 group.addItem("HtmlPage", "/docs/HtmlPage.html");
 group.setExpanded(true);
 
  • Constructor Details

    • TreeGroup

      public TreeGroup(String label)
      Creates a new TreeGroup with the specified label.
      Parameters:
      label - The display label for the group header.
    • TreeGroup

      public TreeGroup(String label, String groupId)
      Creates a new TreeGroup with the specified label and ID.
      Parameters:
      label - The display label for the group header.
      groupId - The ID to use for the group content container.
  • Method Details

    • initialize

      protected void initialize()
      Description copied from class: Element
      Hook method called during element initialization.

      Override this method to set up the element's structure by adding child elements. This is called before Element.create() and only once during the element's lifecycle.

      Overrides:
      initialize in class StyledElement
    • setLabel

      public TreeGroup setLabel(String label)
      Sets the group label.
      Parameters:
      label - The display label for the group header.
      Returns:
      This TreeGroup for method chaining.
    • getLabel

      public String getLabel()
      Gets the group label.
      Returns:
      The display label for the group header.
    • setExpanded

      public TreeGroup setExpanded(boolean expanded)
      Sets whether the group is initially expanded.
      Parameters:
      expanded - True to expand the group, false to collapse it.
      Returns:
      This TreeGroup for method chaining.
    • isExpanded

      public boolean isExpanded()
      Gets whether the group is expanded.
      Returns:
      True if the group is expanded, false otherwise.
    • addItem

      public TreeItem addItem(String label, String url)
      Adds an item to the group.
      Parameters:
      label - The display label for the item.
      url - The URL to navigate to when the item is selected.
      Returns:
      The created TreeItem for further configuration.
    • addItem

      public TreeItem addItem(String label, String filterText, String url)
      Adds an item to the group with filter text different from the display label.
      Parameters:
      label - The display label for the item.
      filterText - The text to use for filtering (may differ from display label).
      url - The URL to navigate to when the item is selected.
      Returns:
      The created TreeItem for further configuration.
    • addItem

      public TreeGroup addItem(TreeItem item)
      Adds a pre-configured TreeItem to the group.
      Parameters:
      item - The TreeItem to add.
      Returns:
      This TreeGroup for method chaining.
    • getHeader

      public Div getHeader()
      Gets the header element for custom styling.
      Returns:
      The header Div element.
    • getExpandIcon

      public Span getExpandIcon()
      Gets the expand icon element for custom styling.
      Returns:
      The expand icon Span element.
    • getItemsContainer

      public Ul getItemsContainer()
      Gets the items container element for custom styling.
      Returns:
      The items container Ul element.
    • getGroupId

      public String getGroupId()
      Gets the group ID.
      Returns:
      The ID used for the group content container.