Class Finder

All Implemented Interfaces:
Iterable<FinderColumn>, Attachable, ElementAttributeMethods<HTMLElement, Finder>, ElementClassListMethods<HTMLElement, Finder>, ElementConsumerMethods<HTMLElement, Finder>, ElementContainerMethods<HTMLElement, Finder>, ElementEventMethods<HTMLElement, Finder>, ElementIdMethods<HTMLElement, Finder>, ElementQueryMethods<HTMLElement>, HTMLElementAttributeMethods<HTMLElement, Finder>, HTMLElementDataMethods<HTMLElement, Finder>, HTMLElementStyleMethods<HTMLElement, Finder>, HTMLElementVisibilityMethods<HTMLElement, Finder>, IsElement<HTMLElement>, TypedBuilder<HTMLElement, Finder>, Component, HasItems<HTMLElement, Finder, FinderColumn>, OuiaSupport<HTMLElement, Finder>, Modifiers.Bordered<HTMLElement, Finder>

A finder provides column-based hierarchical navigation inspired by the macOS Finder. Each column displays a list of items, and selecting an item populates the next column with its children or shows a preview.
  • Method Details

    • finder

      public static Finder finder()
    • attach

      public void attach(MutationRecord mutationRecord)
      Specified by:
      attach in interface Attachable
    • detach

      public void detach(MutationRecord mutationRecord)
      Specified by:
      detach in interface Attachable
    • addColumns

      public <T> Finder addColumns(Iterable<T> items, Function<T, FinderColumn> display)
    • addColumn

      public Finder addColumn(FinderColumn column)
    • add

      public Finder add(FinderColumn item)
      Description copied from interface: HasItems
      Adds an item to the component.
      Specified by:
      add in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      item - the item to be added to the component
      Returns:
      the builder instance after the item has been added
    • addPreview

      public Finder addPreview(FinderPreview preview)
      Adds the specified FinderPreview instance to the finder. This method ensures that any previously added preview is safely removed before adding the new one.
      Parameters:
      preview - the FinderPreview instance to add. Represents the preview component to be added to the finder.
      Returns:
      the current Finder instance, allowing for method chaining.
    • add

      public Finder add(FinderPreview preview)
      Adds the specified FinderPreview instance to the finder. This method ensures that any previously added preview is safely removed before adding the new one.

      Preview can be managed on a column basis by using FinderColumn.onPreview(PreviewHandler) or on an item basis by using FinderItem.onPreview(PreviewHandler).

      Parameters:
      preview - the FinderPreview instance to add. Represents the preview component to be added to the finder.
      Returns:
      the current Finder instance, allowing for method chaining.
    • that

      public Finder that()
      Specified by:
      that in interface TypedBuilder<HTMLElement, Finder>
    • onAdd

      public Finder onAdd(AddItemHandler<Finder, FinderColumn> onAdd)
      Description copied from interface: HasItems
      Registers a callback to be invoked whenever a new item is added to the component.
      Specified by:
      onAdd in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      onAdd - a AddItemHandler that takes the builder instance and the item being added as arguments
      Returns:
      the builder instance after adding the callback
    • onUpdate

      public Finder onUpdate(UpdateItemHandler<Finder, FinderColumn> onUpdate)
      Description copied from interface: HasItems
      Registers a callback to be invoked whenever an item is updated in the component.
      Specified by:
      onUpdate in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      onUpdate - a UpdateItemHandler that takes the component, the previous state of the item, and the updated state of the item as arguments
      Returns:
      the builder instance after adding the callback
    • onRemove

      public Finder onRemove(RemoveItemHandler<Finder, FinderColumn> onRemove)
      Description copied from interface: HasItems
      Registers a callback to be invoked whenever an item is removed from the component.
      Specified by:
      onRemove in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      onRemove - a RemoveItemHandler that takes the component and the item being removed as arguments
      Returns:
      the builder instance after adding the callback
    • path

      public ResolvedFinderPath path()
      Returns the full selection path across all columns, regardless of which column is currently active. The path includes a segment for every column that has a selected item, stopping at the first column without a selection.

      Use this method when you need the complete selection state of the finder. If you need the path only up to the currently active (focused) column — for example to synchronise the browser URL during keyboard navigation — use activePath() instead.

      See Also:
    • activePath

      public ResolvedFinderPath activePath()
      Returns the selection path up to and including the currently active (focused) column. Columns to the right of the active column are excluded even if they still have selected items. This is useful for synchronising the browser URL during arrow-left keyboard navigation, where columns to the right are preserved in the DOM but should no longer be reflected in the URL.

      When no arrow-left navigation has occurred, the active column is the deepest column with a selection, so this method returns the same result as path().

      See Also:
    • select

      public Promise<ResolvedFinderPath> select(String path)
      Parses and selects items along the given finder path string, handling async column loading at each level. The path must use the format produced by FinderPath.toString(): col1=item1/col2=item2/col3. The last segment may omit the item identifier to represent a column with no selected item.
      Parameters:
      path - the encoded finder path string
      Returns:
      a Promise that resolves with the ResolvedFinderPath of successfully selected items
      See Also:
    • select

      public Promise<ResolvedFinderPath> select(FinderPath path)
      Selects items along the given finder path, handling async column loading at each level. The first column in the path must already be present in this finder. Each item selection may trigger creation and async loading of the next column (via FinderItem.nextColumn(java.util.function.Supplier)).

      Select and preview events are fired only for the deepest successfully resolved item, not for intermediate segments. If a segment cannot be resolved (column not found, item not found after loading), the promise resolves with a partial ResolvedFinderPath containing only the successfully selected segments, and events are fired for the last resolved item.

      Parameters:
      path - the finder path to select
      Returns:
      a Promise that resolves with the ResolvedFinderPath of successfully selected items
    • iterator

      public Iterator<FinderColumn> iterator()
      Specified by:
      iterator in interface Iterable<FinderColumn>
    • size

      public int size()
      Description copied from interface: HasItems
      Retrieves the total number of items currently contained in the component.
      Specified by:
      size in interface HasItems<HTMLElement, Finder, FinderColumn>
      Returns:
      the number of items contained in the component
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: HasItems
      Checks whether the collection of items in the component is empty.
      Specified by:
      isEmpty in interface HasItems<HTMLElement, Finder, FinderColumn>
      Returns:
      true if the component contains no items; false otherwise
    • contains

      public boolean contains(String identifier)
      Description copied from interface: HasItems
      Checks whether the component contains an item associated with the given identifier.
      Specified by:
      contains in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      identifier - the identifier of the item to be checked
      Returns:
      true if the component contains an item associated with the provided identifier, false otherwise
    • item

      public FinderColumn item(String identifier)
      Description copied from interface: HasItems
      Retrieves the item associated with the specified identifier from the component.
      Specified by:
      item in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      identifier - the identifier of the item to be retrieved
      Returns:
      the item associated with the given identifier, or null if no item is found
    • updateItem

      public void updateItem(FinderColumn item)
      Description copied from interface: HasItems
      Updates an existing item in the component.
      Specified by:
      updateItem in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      item - the item to be updated
    • removeItem

      public void removeItem(String identifier)
      Description copied from interface: HasItems
      Removes an item from the component based on the provided identifier.
      Specified by:
      removeItem in interface HasItems<HTMLElement, Finder, FinderColumn>
      Parameters:
      identifier - the identifier of the item to be removed
    • clear

      public void clear()
      Description copied from interface: HasItems
      Clears all items from the component. This method removes any existing items within the component, leaving it empty. Any associated or registered callbacks related to the removal of items may be invoked as part of this operation.
      Specified by:
      clear in interface HasItems<HTMLElement, Finder, FinderColumn>