Class LazyTreeItem<T,U>

java.lang.Object
javafx.scene.control.TreeItem<T>
com.iamsoft.util.ui.javafx.LazyTreeItem<T,U>
Type Parameters:
T - item type
U - Type from which tree items are created.
All Implemented Interfaces:
javafx.event.EventTarget

public class LazyTreeItem<T,U> extends javafx.scene.control.TreeItem<T>
Tree item whose children are calculated lazily.
  • Property Summary

    Properties inherited from class javafx.scene.control.TreeItem

    expanded, graphic, leaf, parent, value
  • Nested Class Summary

    Nested classes/interfaces inherited from class javafx.scene.control.TreeItem

    javafx.scene.control.TreeItem.TreeModificationEvent<T extends Object>
  • Constructor Summary

    Constructors
    Constructor
    Description
    LazyTreeItem(T pItem, Callable<Collection<U>> pChildElementsCallable, Function<U,javafx.scene.control.TreeItem<T>> pElementToTreeItemFunction)
    If callable is null, node is considered a leaf.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether the loading of children is finished.
    javafx.collections.ObservableList<javafx.scene.control.TreeItem<T>>
     
    protected boolean
     
    boolean
     
    void
     
    void
     
    void
     
    void
    loadChildren(Runnable pOnLoadHandler)
    If this tree item is not a leaf and children are loaded, the specified handler is invoked immediately.
    void
    loadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll)
     
    void
    loadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll, Runnable pOnFinish)
     
    void
    loadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll, Runnable pOnFinish, BooleanSupplier pAbort)
     
    protected void
    onFailed(Exception pException)
    Invoked on the JavaFX thread if failed to calculate children (before onFinished() is invoked).
    protected void
    Invoked on the JavaFX thread after children are calculated, no matter if the task fails.
    javafx.collections.ObservableList<javafx.scene.control.TreeItem<T>>
    Provides access to children without triggering child elements loading in case they are not loaded, yet.
    protected void
    submitTask(javafx.concurrent.Task<Collection<U>> pTask)
     

    Methods inherited from class javafx.scene.control.TreeItem

    addEventHandler, branchCollapsedEvent, branchExpandedEvent, buildEventDispatchChain, childrenModificationEvent, expandedItemCountChangeEvent, expandedProperty, getGraphic, getParent, getValue, graphicChangedEvent, graphicProperty, isExpanded, leafProperty, nextSibling, nextSibling, parentProperty, previousSibling, previousSibling, removeEventHandler, setExpanded, setGraphic, setValue, toString, treeNotificationEvent, valueChangedEvent, valueProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LazyTreeItem

      public LazyTreeItem(T pItem, Callable<Collection<U>> pChildElementsCallable, Function<U,javafx.scene.control.TreeItem<T>> pElementToTreeItemFunction)
      If callable is null, node is considered a leaf.
      Parameters:
      pItem - Tree item.
      pChildElementsCallable - Callable, which will be invoked on a background thread to provide list of child elements. Note that elements must be immutable, or effectively immutable.
      pElementToTreeItemFunction - Function, which will be invoked on the JavaFX thread to create children.
  • Method Details

    • isGetChildrenCalled

      protected boolean isGetChildrenCalled()
    • isLeaf

      public boolean isLeaf()
      Overrides:
      isLeaf in class javafx.scene.control.TreeItem<T>
    • childrenLoaded

      public boolean childrenLoaded()
      Determines whether the loading of children is finished.
    • loadChildren

      public void loadChildren(Runnable pOnLoadHandler)
      If this tree item is not a leaf and children are loaded, the specified handler is invoked immediately.
    • getChildren

      public javafx.collections.ObservableList<javafx.scene.control.TreeItem<T>> getChildren()
      Overrides:
      getChildren in class javafx.scene.control.TreeItem<T>
    • peekChildren

      public javafx.collections.ObservableList<javafx.scene.control.TreeItem<T>> peekChildren()
      Provides access to children without triggering child elements loading in case they are not loaded, yet.
    • submitTask

      protected void submitTask(javafx.concurrent.Task<Collection<U>> pTask)
    • onFailed

      protected void onFailed(Exception pException)
      Invoked on the JavaFX thread if failed to calculate children (before onFinished() is invoked).
    • onFinished

      protected void onFinished()
      Invoked on the JavaFX thread after children are calculated, no matter if the task fails.
    • loadAllDescendants

      public void loadAllDescendants()
    • loadAllDescendants

      public void loadAllDescendants(Runnable pOnFinish)
    • loadAllDescendants

      public void loadAllDescendants(Runnable pOnFinish, BooleanSupplier pAbort)
    • loadRecursively

      public void loadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll)
      Parameters:
      pSelector - The selector returns true if the children of the specified tree item should be loaded.
      pProcessAll - If true all children are processed, regardless of the selector results. Otherwise, children of specific tree item are processed until the specified selector returns true for an item. For example, in case where one should ensure that tree items for a specific path are loaded.
    • loadRecursively

      public void loadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll, Runnable pOnFinish)
      Parameters:
      pSelector - The selector returns true if the children of the specified tree item should be loaded.
      pProcessAll - If true all children are processed, regardless of the selector results. Otherwise, children of specific tree item are processed until the specified selector returns true for an item. For example, in case where one should ensure that tree items for a specific path are loaded.
    • loadRecursively

      public void loadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll, Runnable pOnFinish, BooleanSupplier pAbort)
      Parameters:
      pSelector - The selector returns true if the children of the specified tree item should be loaded.
      pProcessAll - If true all children are processed, regardless of the selector results. Otherwise, children of specific tree item are processed until the specified selector returns true for an item. For example, in case where one should ensure that tree items for a specific path are loaded.