Class TreeItem


public class TreeItem extends Li
A selectable item within a TreeGroup.

TreeItems are filterable entries that can be selected to navigate an iframe or trigger server-side events. When selected, items receive the "selected" CSS class.

Example usage:

 TreeItem item = group.addItem("HtmlPage", "/docs/HtmlPage.html");
 item.setTypeIndicator("C", "class");  // Shows type indicator
 
  • Constructor Details

    • TreeItem

      public TreeItem(String label, String url)
      Creates a new TreeItem with the specified label and URL.
      Parameters:
      label - The display label for the item.
      url - The URL to navigate to when the item is selected.
    • TreeItem

      public TreeItem(String label, String filterText, String url)
      Creates a new TreeItem with the specified label, filter text, and URL.
      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.
  • 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 TreeItem setLabel(String label)
      Sets the display label for the item.
      Parameters:
      label - The display label.
      Returns:
      This TreeItem for method chaining.
    • getLabel

      public String getLabel()
      Gets the display label for the item.
      Returns:
      The display label.
    • setFilterText

      public TreeItem setFilterText(String filterText)
      Sets the filter text for the item.
      Parameters:
      filterText - The text to use for filtering.
      Returns:
      This TreeItem for method chaining.
    • getFilterText

      public String getFilterText()
      Gets the filter text for the item.
      Returns:
      The text used for filtering.
    • setUrl

      public TreeItem setUrl(String url)
      Sets the URL to navigate to when the item is selected.
      Parameters:
      url - The URL to navigate to.
      Returns:
      This TreeItem for method chaining.
    • getUrl

      public String getUrl()
      Gets the URL to navigate to when the item is selected.
      Returns:
      The URL to navigate to.
    • setTypeIndicator

      public TreeItem setTypeIndicator(String indicator, String cssClass)
      Sets a type indicator to display before the label.

      This is useful for showing the type of item, such as "C" for class, "I" for interface, "E" for enum, etc.

      Parameters:
      indicator - The indicator text (e.g., "C", "I", "E").
      cssClass - The CSS class for styling the indicator.
      Returns:
      This TreeItem for method chaining.
    • getTypeIndicator

      public Span getTypeIndicator()
      Gets the type indicator element for custom styling.
      Returns:
      The type indicator Span element, or null if not set.
    • getLabelSpan

      public Span getLabelSpan()
      Gets the label element for custom styling.
      Returns:
      The label Span element.