- java.lang.Object
-
- javafx.scene.control.TreeItem<T>
-
- javafx.scene.control.CheckBoxTreeItem<T>
-
- eu.ess.xaos.ui.control.tree.FilterableTreeItem<T>
-
- Type Parameters:
T
- The type of the value returned byTreeItem.getValue()
.
- All Implemented Interfaces:
EventTarget
public class FilterableTreeItem<T> extends CheckBoxTreeItem<T>
An extension ofTreeItem
with the possibility to filter its children. To enable filtering it is necessary to set theTreeItemPredicate
. If a predicate is set, then the tree item will also use this predicate to filter its children (if they are of the type FilterableTreeItem). A tree item that has children will not be filtered. The predicate will only be evaluated, if the tree item is a leaf. Since the predicate is also set for the child tree items, the tree item in question can turn into a leaf if all its children are filtered. This class extendsCheckBoxTreeItem
so it can, but does not need to be, used in conjunction withCheckBoxTreeCell
cells.- Author:
- claudio.rosati@esss.se
- See Also:
- Filtering a JavaFX TreeView
-
-
Property Summary
Properties Type Property Description ObjectProperty<TreeItemPredicate<T>>
predicate
-
Properties inherited from class javafx.scene.control.CheckBoxTreeItem
independent, indeterminate, selected
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javafx.scene.control.CheckBoxTreeItem
CheckBoxTreeItem.TreeModificationEvent<T extends Object>
-
-
Constructor Summary
Constructors Constructor Description FilterableTreeItem()
Creates a newFilterableTreeItem
with filtered children.FilterableTreeItem(T value)
Creates a newFilterableTreeItem
with filtered children.FilterableTreeItem(T value, Node graphic)
Creates a newFilterableTreeItem
with filtered children.To enable filtering sorting it is necessary to set theTreeItemPredicate
.If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.FilterableTreeItem(T value, Node graphic, boolean selected)
Creates a newFilterableTreeItem
with filtered children.To enable filtering sorting it is necessary to set theTreeItemPredicate
.If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.FilterableTreeItem(T value, Node graphic, boolean selected, boolean independent)
Creates a newFilterableTreeItem
with filtered children.To enable filtering sorting it is necessary to set theTreeItemPredicate
.If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TreeItemPredicate<T>
getPredicate()
Gets the value of the property predicate.ObservableList<TreeItem<T>>
getUnfilteredChildren()
Returns the list of children that is backing the filtered list.ObjectProperty<TreeItemPredicate<T>>
predicateProperty()
protected void
setHiddenFieldChildren(ObservableList<TreeItem<T>> list)
Set the hidden private fieldTreeItem.children
through reflection and hook the hiddenListChangeListener
inTreeItem.childrenListener
to the list.void
setPredicate(TreeItemPredicate<T> predicate)
Sets the value of the property predicate.-
Methods inherited from class javafx.scene.control.CheckBoxTreeItem
checkBoxSelectionChangedEvent, independentProperty, indeterminateProperty, isIndependent, isIndeterminate, isSelected, selectedProperty, setIndependent, setIndeterminate, setSelected
-
Methods inherited from class javafx.scene.control.TreeItem
addEventHandler, branchCollapsedEvent, branchExpandedEvent, buildEventDispatchChain, childrenModificationEvent, expandedItemCountChangeEvent, expandedProperty, getChildren, getGraphic, getParent, getValue, graphicChangedEvent, graphicProperty, isExpanded, isLeaf, leafProperty, nextSibling, nextSibling, parentProperty, previousSibling, previousSibling, removeEventHandler, setExpanded, setGraphic, setValue, toString, treeNotificationEvent, valueChangedEvent, valueProperty
-
-
-
-
Property Detail
-
predicate
public final ObjectProperty<TreeItemPredicate<T>> predicateProperty
- See Also:
getPredicate()
,setPredicate(TreeItemPredicate)
-
-
Constructor Detail
-
FilterableTreeItem
public FilterableTreeItem()
Creates a newFilterableTreeItem
with filtered children. To enable filtering sorting it is necessary to set theTreeItemPredicate
. If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.
-
FilterableTreeItem
public FilterableTreeItem(T value)
Creates a newFilterableTreeItem
with filtered children. To enable filtering sorting it is necessary to set theTreeItemPredicate
. If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.- Parameters:
value
- The value of the tree item.
-
FilterableTreeItem
public FilterableTreeItem(T value, Node graphic)
Creates a newFilterableTreeItem
with filtered children.To enable filtering sorting it is necessary to set theTreeItemPredicate
.If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.
-
FilterableTreeItem
public FilterableTreeItem(T value, Node graphic, boolean selected)
Creates a newFilterableTreeItem
with filtered children.To enable filtering sorting it is necessary to set theTreeItemPredicate
.If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.- Parameters:
value
- The value of the tree item.graphic
- TheNode
to show in theTreeView
next to this tree item.selected
- The initial value of theCheckBoxTreeItem.selectedProperty()
.
-
FilterableTreeItem
public FilterableTreeItem(T value, Node graphic, boolean selected, boolean independent)
Creates a newFilterableTreeItem
with filtered children.To enable filtering sorting it is necessary to set theTreeItemPredicate
.If no predicate is set, then the tree item will attempt so bind itself to the predicate of its parent.- Parameters:
value
- The value of the tree item.graphic
- TheNode
to show in theTreeView
next to this tree item.selected
- The initial value of theCheckBoxTreeItem.selectedProperty()
.independent
- The initial value of theCheckBoxTreeItem.independentProperty()
.
-
-
Method Detail
-
predicateProperty
public final ObjectProperty<TreeItemPredicate<T>> predicateProperty()
- See Also:
getPredicate()
,setPredicate(TreeItemPredicate)
-
getPredicate
public final TreeItemPredicate<T> getPredicate()
Gets the value of the property predicate.- Property description:
-
setPredicate
public final void setPredicate(TreeItemPredicate<T> predicate)
Sets the value of the property predicate.- Property description:
-
getUnfilteredChildren
public ObservableList<TreeItem<T>> getUnfilteredChildren()
Returns the list of children that is backing the filtered list.- Returns:
- The underlying list of children.
-
setHiddenFieldChildren
protected final void setHiddenFieldChildren(ObservableList<TreeItem<T>> list)
Set the hidden private fieldTreeItem.children
through reflection and hook the hiddenListChangeListener
inTreeItem.childrenListener
to the list.- Parameters:
list
- the list to set
-
-