Class 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.
    • Constructor Detail

      • 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 Detail

      • 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)
      • 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.