1. Domino UI
  2. Components
  3. Check tree Pro
Top Simple Nested Featured Docs

Check tree

An abstract base class for creating tree items (nodes) in a hierarchical tree structure.

Key responsibilities:

  • Maintaining and rendering a list of child nodes
  • Supporting activation (e.g., selection or highlighting) of the node
  • Managing collapse/expand behavior for child nodes (if any)
  • Customizable icon logic (which can change on expand/collapse)
  • Filtering of nodes (for searching or hiding certain items)
  • Selection event listeners (if implementing classes require selection logic)
  • Integration with a TreeConfig for configuring default behaviors (collapsing, icon strategy, etc.)

Typical usage involves subclassing to implement a specific kind of tree node (e.g., see TreeItem ).

V

the data type associated with each node

N

the type of the node itself (for fluent API use)

S

the selection type or structure, commonly the node type or a list of nodes

A specialized TreeRoot for handling CheckTreeItem nodes, allowing multiple selected items (checkbox-style) within the tree structure.

Provides methods for:

  • Gathering the current selection of items via getSelection or getFlatSelection
  • Selecting or deselecting all items in the tree
  • Tracking an active (focused) node distinct from selections
  • Registering handlers to be invoked upon item activation

Each node added to the tree is a CheckTreeItem , which can be checked or unchecked. Selecting an item doesn't automatically uncheck the previously selected items, which provides a multi-checkable behavior.

Example Usage:


 CheckTree tree = CheckTree.create("Root node", "root_value");
 CheckTreeItem child1 = CheckTreeItem.create("Child 1", "child1_value");
 CheckTreeItem child2 = CheckTreeItem.create("Child 2", "child2_value");

 tree.appendChild(child1).appendChild(child2);

 tree.selectAll(); // Checks all items

 List
               > selection = tree.getFlatSelection(); // returns all checked items throughout the tree

V

the type of data/value associated with each tree item

A specialized TreeNode that uses a CheckBox for selection rather than a simple "active" or "highlighted" state. This enables a multi-select (checkbox) style in a tree structure.

Key behaviors:

  • The CheckBox indicates whether an item is selected.
  • Supports partial selection states (indeterminate) if child items are not uniformly selected.
  • Interaction with the checkbox triggers select/deselect operations, which can cascade to descendants or bubble up to ancestors (depending on configuration).
  • Selection events may be silenced (silent) to avoid triggering listeners when needed.

Example Usage:


 CheckTreeItem item = CheckTreeItem.create("My Item", "dataValue");
 // mark as selected:
 item.select();
 

V

the type of value or data object associated with this node

Examples

Simple check tree Menu like check tree

Nested check tree Check tree with nested selection

API Docs: TreeRoot

API Docs: TreeNode

Constructors

public void TreeNode(Icon<?> icon, String title)
Constructs a new TreeNode with an icon and a title.

icon

the icon to display

title

the text label for this node

public void TreeNode(String title)
Constructs a new TreeNode with a title only (no icon).

title

the text label for this node

public void TreeNode(Icon<?> icon)
Constructs a new TreeNode with an icon only (no title).

icon

the icon to display

public void TreeNode(String title, V value)
Constructs a new TreeNode with a title and a data value.

title

the text label for this node

value

the data value associated with the node

public void TreeNode(Icon<?> icon, String title, V value)
Constructs a new TreeNode with an icon, title, and a data value.

icon

the icon to display

title

the text label

value

the data value

public void TreeNode(Icon<?> icon, V value)
Constructs a new TreeNode with an icon and a data value (no title).

icon

the icon to display

value

the data value

Public methods

public N setTitle(String title)
Sets the visible label (title) of this node.

title

the title text



Returns:

this node (for fluent API)

public String getTitle()
Retrieves the current title (visible label) for this node.

Returns:

the title string

public void deactivate()
Deactivates this node if it's currently active, removing the dui_active CSS class. If this node has child nodes, they are also deactivated, and if the tree is configured for auto collapse, the node collapses. Updates the icon accordingly.
public N appendChild(N node)
Adds a child node to this node, re-parenting the child. Also updates the icon if this node was previously a leaf. If the tree's root has an icon supplier, it's applied to new child nodes as well.

node

the child node to add



Returns:

this node (for fluent API)

public N appendChild(N[] treeItems)
Adds multiple child nodes at once.

treeItems

the child nodes to add



Returns:

this node (for fluent API)

public void removeNode(N item)
Removes a specified child node from this node. If no children remain after removal, the node is collapsed.

item

the child node to remove

public N clear()
Removes all child nodes from this node.

Returns:

this node (for fluent API)

public N remove()
Removes this node from its parent, if it has one.

Returns:

this node (for fluent API)

public PrefixElement getPrefixElement()
Check super implementation documentation.

Returns a PrefixElement that wraps the node's content area, allowing insertion of custom elements (e.g., icons) before the text.

public PostfixElement getPostfixElement()
Check super implementation documentation.

Returns a PostfixElement that wraps the node's content area, allowing insertion of custom elements (e.g., badges) after the text.

public N appendChild(Separator separator)
Inserts a separator (e.g., a horizontal line or spacing) into the subtree of this node.

separator

a Separator object



Returns:

this node (for fluent API)

public RootNode<V, N, S> getRootNode()
Check super implementation documentation.

Returns the root of the entire tree structure. Typically used for configuration or top-level behaviors.

public Optional<IsParentNode<V, N, S>> getParent()
Retrieves this node's optional parent. If the parent is a TreeNode , returns a non-empty Optional ; otherwise, it may be empty if this node is top-level.

Returns:

an Optional containing the parent node if it exists

public void setActiveNode(N activeNode)
Sets the currently active (selected) tree item within the tree structure.

activeNode

The TreeItem to set as the active item.

public List<N> getPath()
Retrieves a list of nodes forming the path from the root to this node, including this node.

Returns:

an ordered list of nodes from the tree root to this node

public List<V> getPathValues()
Retrieves a list of values from the root to this node, including this node's value.

Returns:

an ordered list of values from the tree root to this node

public List<N> getSubNodes()
Returns the direct children of this node (sub-nodes).

Returns:

a list of child nodes

public void doActivate()
Activates (selects) this tree item without activating its parent items. This method returns void.
public N activate()
Activates this node, showing it if necessary and performing the default "onActivation" logic.

Returns:

this node (for fluent API)

public N getActiveNode()
Retrieves the currently active (or highlighted) child node of this node, or null if none is active.

Returns:

the active node, or null

public TreeNode<V, N, S> setToggleTarget(ToggleTarget toggleTarget)
Sets the target that toggles expand/collapse behavior. If ICON is chosen, wave effects are removed from the anchor area, and the node icon becomes clickable instead.

toggleTarget

the new toggle target



Returns:

this node (for fluent API)

public boolean isLeaf()
Checks if this node is a leaf, meaning it has no children.

Returns:

true if no children, false otherwise

public N setIcon(Icon<?> icon)
Sets (or replaces) this node's icon. If an icon was previously set, it is removed. The new icon is appended to the content element, and click logic is updated based on the current toggle target.

icon

the new icon to display



Returns:

this node (for fluent API)

public HTMLAnchorElement getClickableElement()
Check super implementation documentation.

Returns the anchor element for the node, which is used for wave effects (unless toggle target is icon-only).

public void collapseAll()
Recursively collapses this node and all child sub-nodes.
public void expandAll()
Recursively expands this node and all child sub-nodes.
public N expandNode()
Expands this node (shows children if any) by calling expand from Collapsible .

Returns:

this node (for fluent API)

public N collapseNode()
Collapses this node (hiding children if any) by calling collapse from Collapsible .

Returns:

this node (for fluent API)

public N expandNode(boolean expandParent)
Expands this node. If expandParent is true , also expands all ancestors.

expandParent

whether to expand parent nodes too



Returns:

this node (for fluent API)

public N collapseNode(boolean collapseParent)
Collapse this node. If collapseParent is true , also collapse all ancestors.

collapseParent

whether to collapse parent nodes too



Returns:

this node (for fluent API)

public N show(boolean expandParent)
Ensures this node is shown (expanded) in the tree. Optionally expands the parent chain, then calls expand if this node has children.

expandParent

if true, parent nodes are also expanded



Returns:

this node (for fluent API)

public N hide(boolean collapseParent)
Ensures this node is shown (collapsed) in the tree. Optionally collapses the parent chain, then calls collapse if this node has children.

collapseParent

if true, parent nodes are also expanded



Returns:

this node (for fluent API)

public void clearFilter()
Clears any previously applied filter state (restoring collapsed/expanded state and visibility) for this node and its children.
public boolean filter(String searchToken)
Filters this node (and possibly its children) against a search token, showing nodes that match or have matching descendants. If a match is found, the node is revealed, otherwise hidden.

searchToken

the token to search for



Returns:

true if this node or any child matches the search token, false otherwise

public boolean filterChildren(String searchToken)
Filters child nodes recursively, returning true if any child node matches.

searchToken

the token to filter by



Returns:

true if any child matches, false otherwise

public boolean isAutoExpandFound()
Indicates whether matching nodes should automatically be expanded (when found by a filter).

Returns:

true if auto-expand is enabled for found nodes

public TreeItemFilter<N> getFilter()
Retrieves the filter logic from the parent or root node.

Returns:

a TreeItemFilter used to evaluate matches

public V getValue()
Gets the data value associated with this node.

Returns:

the node's value

public void setValue(V value)
Sets a data value for this node.

value

the new value

public Element getWavesElement()
Check super implementation documentation.

By default, wave effects apply to the anchor, unless ICON is selected.

public SpanElement getTextElement()
Gets the SpanElement holding the text content (the "label") of this node.

Returns:

the text element

public UListElement getSubTree()
Retrieves the unordered list element that holds this node's children.

Returns:

the sub-tree element

public N pauseSelectionListeners()
Pauses any selection (activation) listeners for this node, so changes do not trigger events.

Returns:

this node

public N resumeSelectionListeners()
Resumes any selection (activation) listeners previously paused.

Returns:

this node

public N togglePauseSelectionListeners(boolean toggle)
Toggles the paused state of selection listeners.

toggle

if true, listeners are paused; if false, they are resumed



Returns:

this node

public Set<SelectionListener<? super N, ? super S>> getSelectionListeners()
Check super implementation documentation.

Returns the set of selection listeners associated with this node.

public Set<SelectionListener<? super N, ? super S>> getDeselectionListeners()
Check super implementation documentation.

Returns the set of deselection listeners associated with this node.

public boolean isSelectionListenersPaused()
Check super implementation documentation.

Indicates whether selection listeners are currently paused.

public N triggerSelectionListeners(N source, S selection)
Check super implementation documentation.

Notifies all registered selection listeners of a selection event, unless listeners are paused.

public N triggerDeselectionListeners(N source, S selection)
Check super implementation documentation.

Notifies all registered deselection listeners of a deselection event, unless listeners are paused.

public boolean isActive()
Checks if the object is currently active based on the applied status.

Returns:

true if the object is active, false otherwise.

public HTMLLIElement element()
Check super implementation documentation.

Returns the underlying

  • element for this node.
  • API Docs: CheckTree

    Constructors

    public void CheckTree()
    Constructs an empty CheckTree with no title or associated value.
    public void CheckTree(String treeTitle)
    Constructs a CheckTree with the given title.

    treeTitle

    the title of the tree

    public void CheckTree(String treeTitle, V value)
    Constructs a CheckTree with the given title and associated data value.

    treeTitle

    the title of the tree

    value

    the data value associated with the root item

    Static methods

    public static CheckTree<V> create(String title, V value)
    Creates a new CheckTree with the specified title and associated data value.

    title

    the title of the root item

    value

    the data value associated with the root item

    V

    the type of data



    Returns:

    a new CheckTree instance

    public static CheckTree<V> create(String title)
    Creates a new CheckTree with the specified title and no associated data value.

    title

    the title of the root item

    V

    the type of data



    Returns:

    a new CheckTree instance

    public static CheckTree<V> create()
    Creates a new empty CheckTree (no title or value).

    V

    the type of data



    Returns:

    a new CheckTree instance

    Public methods

    public List<CheckTreeItem<V>> getSelection()
    Retrieves the currently selected root-level items in this check tree. That is, only items directly under this tree (not nested children) that are checked.

    Returns:

    a list of checked root-level items

    public List<CheckTreeItem<V>> getFlatSelection()
    Retrieves all items in the entire tree (including nested children) that are currently checked.

    Returns:

    a list of all checked items in this tree

    public void onSelectionChanged(CheckTreeItem<V> source, List<CheckTreeItem<V>> selection, boolean silent)
    Check super implementation documentation.

    When the selection changes (an item is checked or unchecked), notifies any registered listeners.

    source

    the item that triggered the selection change

    selection

    the new selection

    silent

    true to suppress event notifications

    public void setActiveNode(CheckTreeItem<V> node, boolean silent)
    Activates a specified node in this tree, optionally silent. An active node is conceptually "focused" but not necessarily "selected" (checked).

    The previously active node (if any) will be deactivated.

    node

    the node to activate

    silent

    true to suppress event notifications

    public CheckTree<V> selectAll()
    Selects (checks) all items in this tree.

    Returns:

    this CheckTree (for method chaining)

    public CheckTree<V> selectAll(boolean silent)
    Selects (checks) all items in this tree, optionally suppressing selection event notifications.

    silent

    if true , no selection listeners are triggered



    Returns:

    this CheckTree (for method chaining)

    public CheckTree<V> deselectAll()
    Deselects (unchecks) all items in this tree.

    Returns:

    this CheckTree (for method chaining)

    public CheckTree<V> deselectAll(boolean silent)
    Deselects (unchecks) all items in this tree, optionally suppressing selection event notifications.

    silent

    if true , no selection listeners are triggered



    Returns:

    this CheckTree (for method chaining)

    public CheckTree<V> addNodeActivationListener(ChildHandler<CheckTree<V>, CheckTreeItem<V>> handler)
    Registers a ChildHandler to be called whenever a node is activated. This allows custom logic (e.g., expansions, UI changes) when items become active in the tree.

    handler

    a functional interface that receives this tree and the newly activated item



    Returns:

    this CheckTree (for method chaining)

    public CheckTree<V> addNodeActivationListener(RegistryRecord<ChildHandler<CheckTree<V>, CheckTreeItem<V>>> record)
    Registers a handler (wrapped in a RegistryRecord ) for node activation events.

    record

    the registry record containing the handler



    Returns:

    this CheckTree (for method chaining)

    public CheckTree<V> removeNodeActivationListener(ChildHandler<CheckTree<V>, CheckTreeItem<V>> handler)
    Removes a previously registered node activation handler.

    handler

    the ChildHandler to remove



    Returns:

    this CheckTree (for method chaining)

    public void onActiveNodeChanged(CheckTreeItem<V> source, List<CheckTreeItem<V>> selection, boolean silent)
    Check super implementation documentation.

    Notifies all registered activation handlers when the active node changes.

    source

    the newly active node

    selection

    the current selection (checked items)

    silent

    true to suppress notifications

    API Docs: CheckTreeItem

    Constructors

    public void CheckTreeItem(Icon<?> icon, String title)
    Constructs a CheckTreeItem with an icon and a title.

    icon

    the Icon to display

    title

    the text label

    public void CheckTreeItem(String title)
    Constructs a CheckTreeItem with only a title (no icon).

    title

    the text label

    public void CheckTreeItem(Icon<?> icon)
    Constructs a CheckTreeItem with only an icon (no text label).

    icon

    the Icon to display

    public void CheckTreeItem(String title, V value)
    Constructs a CheckTreeItem with a title and a data value.

    title

    the text label

    value

    the data value

    public void CheckTreeItem(Icon<?> icon, String title, V value)
    Constructs a CheckTreeItem with an icon, a title, and a data value.

    icon

    the Icon to display

    title

    the text label

    value

    the data value

    public void CheckTreeItem(Icon<?> icon, V value)
    Constructs a CheckTreeItem with an icon and a data value (no text label).

    icon

    the Icon to display

    value

    the data value

    Static methods

    public static CheckTreeItem<String> create(String title)
    Creates a new CheckTreeItem with the specified title, using the title string as both the label and the data value.

    title

    the text label and value for the node



    Returns:

    a new CheckTreeItem

    public static CheckTreeItem<String> create(Icon<?> icon, String title)
    Creates a new CheckTreeItem with an icon and a title string, using the title as both label and data value.

    icon

    the Icon to display beside the title

    title

    the text label and value for the node



    Returns:

    a new CheckTreeItem

    public static CheckTreeItem<String> create(Icon<?> icon)
    Creates a new CheckTreeItem with only an icon. The data value is set to an empty string.

    icon

    the Icon to display



    Returns:

    a new CheckTreeItem with an empty string value

    public static CheckTreeItem<T> create(String title, T value)
    Creates a new CheckTreeItem with the specified title and value.

    title

    the text label for this node

    value

    the data value

    T

    the value type



    Returns:

    a new CheckTreeItem

    public static CheckTreeItem<T> create(Icon<?> icon, String title, T value)
    Creates a new CheckTreeItem with the specified icon, title, and value.

    icon

    the Icon to display

    title

    the text label

    value

    the data value

    T

    the value type



    Returns:

    a new CheckTreeItem

    public static CheckTreeItem<T> create(Icon<?> icon, T value)
    Creates a new CheckTreeItem with an icon and a data value (no text label).

    icon

    the Icon to display

    value

    the data value

    T

    the value type



    Returns:

    a new CheckTreeItem

    Public methods

    public List<CheckTreeItem<V>> getRootSelection()
    Retrieves the selection of the entire root node if it's a CheckTree , otherwise returns an empty list. This is used to know which items are selected at the top level.

    Returns:

    a list of selected items at the root level

    public List<CheckTreeItem<V>> getSelection()
    Check super implementation documentation.

    Returns a list of this node's immediate children that are currently selected (checked).

    public List<CheckTreeItem<V>> getFlatSelection()
    Retrieves all items in the subtree rooted at this node (including grandchildren, etc.) that are currently selected.

    Returns:

    a list of selected items in the entire subtree

    public void setActiveNode(CheckTreeItem<V> activeItem, boolean silent)
    Check super implementation documentation.

    Sets the active node for this item's subtree, optionally silent. Deactivates the previously active node and then notifies the root node's onActiveNodeChanged method if silent is false .

    public CheckTreeItem<V> deselect()
    Check super implementation documentation.
    public CheckTreeItem<V> select()
    Check super implementation documentation.
    public CheckTreeItem<V> select(boolean silent)
    Check super implementation documentation.
    public CheckTreeItem<V> deselect(boolean silent)
    Check super implementation documentation.
    public boolean isSelected()
    Indicates whether this node's CheckBox is currently checked.

    Returns:

    true if the item is selected

    public boolean isSelectable()
    Check super implementation documentation.
    public CheckTreeItem<V> setSelectable(boolean selectable)
    Check super implementation documentation.
    public CheckTreeItem<V> setSelected(boolean selected)
    Check super implementation documentation.
    public CheckTreeItem<V> setSelected(boolean selected, boolean silent)
    Check super implementation documentation.
    public void onSelectionChanged(CheckTreeItem<V> source, List<CheckTreeItem<V>> selection, boolean silent)
    Check super implementation documentation.

    Called when selection changes in a child node. Adjusts this node's own checkbox state to reflect partial (indeterminate) or uniform (checked/unchecked) selection among its children, and propagates selection change up to the parent if applicable.

    We are a group of passionate people who love what we do

    Donate & Support Us