- java.lang.Object
-
- javafx.scene.control.TreeItem<T>
-
- com.iamsoft.util.ui.javafx.LazyTreeItem<T,U>
-
- Type Parameters:
T- item typeU- 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.
-
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanchildrenLoaded()Determines whether the loading of children is finished.javafx.collections.ObservableList<javafx.scene.control.TreeItem<T>>getChildren()protected booleanisGetChildrenCalled()booleanisLeaf()voidloadAllDescendants()voidloadAllDescendants(Runnable pOnFinish)voidloadAllDescendants(Runnable pOnFinish, BooleanSupplier pAbort)voidloadChildren(Runnable pOnLoadHandler)If this tree item is not a leaf and children are loaded, the specified handler is invoked immediately.voidloadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll)voidloadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll, Runnable pOnFinish)voidloadRecursively(Function<LazyTreeItem<T,U>,Boolean> pSelector, boolean pProcessAll, Runnable pOnFinish, BooleanSupplier pAbort)protected voidonFailed(Exception pException)Invoked on the JavaFX thread if failed to calculate children (before onFinished() is invoked).protected voidonFinished()Invoked on the JavaFX thread after children are calculated, no matter if the task fails.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.protected voidsubmitTask(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
-
-
-
-
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:
isLeafin classjavafx.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:
getChildrenin classjavafx.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 returnstrueif the children of the specified tree item should be loaded.pProcessAll- Iftrueall children are processed, regardless of the selector results. Otherwise, children of specific tree item are processed until the specified selector returnstruefor 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 returnstrueif the children of the specified tree item should be loaded.pProcessAll- Iftrueall children are processed, regardless of the selector results. Otherwise, children of specific tree item are processed until the specified selector returnstruefor 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 returnstrueif the children of the specified tree item should be loaded.pProcessAll- Iftrueall children are processed, regardless of the selector results. Otherwise, children of specific tree item are processed until the specified selector returnstruefor an item. For example, in case where one should ensure that tree items for a specific path are loaded.
-
-