Top Description Fields Constructors Methods
com.dlsc.preferencesfx.view

public Class FilterableTreeItem<T>

extends CheckBoxTreeItem<T>
Class Inheritance
Type Parameters
<T>
The type of the value property within TreeItem.
Imports
java.util.HashMap, .Map, javafx.beans.binding.Bindings, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableList, javafx.collections.transformation.FilteredList, javafx.scene.control.CheckBoxTreeItem, .TreeItem, javafx.scene.control.cell.CheckBoxTreeCell, java.util.function.Predicate

An extension of TreeItem with the possibility to filter its children. To enable filtering it is necessary to set the TreeItemPredicate. 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 extends CheckBoxTreeItem so it can, but does not need to be, used in conjunction with CheckBoxTreeCell cells.

Field Summary

Modifier and TypeField and Description
private final Map<FilterableTreeItem<T>, Integer>
private final FilteredList<FilterableTreeItem<T>>
private final ObjectProperty<TreeItemPredicate<T>>
private final ObservableList<FilterableTreeItem<T>>

Constructor Summary

AccessConstructor and Description
public
FilterableTreeItem(T
the value of the TreeItem
value
)

Creates a new TreeItem with sorted children.

Method Summary

Modifier and TypeMethod and Description
public void
changeChildItemVisibility(FilterableTreeItem<T>
- child item object
childItem
,
boolean
- visibility of this child item
visible
)

Remove child item from sourceList and save item position if visibility is false.

protected ObservableList<FilterableTreeItem<T>>

Returns:

the backing list
getBackingList
()

public ObservableList<FilterableTreeItem<T>>

Returns:

underlying list of children
getInternalChildren
()

Returns the list of children that is backing the filtered list.

public final TreeItemPredicate<T>

Returns:

the predicate
getPredicate
()

public final ObjectProperty<TreeItemPredicate<T>>

Returns:

the predicate property
predicateProperty
()

public final void
setPredicate(TreeItemPredicate<T>
the predicate
predicate
)

Set the predicate

private void
Inherited from javafx.scene.control.CheckBoxTreeItem:
checkBoxSelectionChangedEventindependentPropertyindeterminatePropertyisIndependentisIndeterminateisSelectedselectedPropertysetIndependentsetIndeterminatesetSelected

Field Detail

childItemIndexesMapback to summary
private final Map<FilterableTreeItem<T>, Integer> childItemIndexesMap
filteredListback to summary
private final FilteredList<FilterableTreeItem<T>> filteredList
predicateback to summary
private final ObjectProperty<TreeItemPredicate<T>> predicate
sourceListback to summary
private final ObservableList<FilterableTreeItem<T>> sourceList

Constructor Detail

FilterableTreeItemback to summary
public FilterableTreeItem(T value)

Creates a new TreeItem with sorted children.

Parameters
value:T

the value of the TreeItem

Method Detail

changeChildItemVisibilityback to summary
public void changeChildItemVisibility(FilterableTreeItem<T> childItem, boolean visible)

Remove child item from sourceList and save item position if visibility is false. If visibility is true it restore (add item to sourceList) to same position using index.

Parameters
childItem:FilterableTreeItem<T>

- child item object

visible:boolean

- visibility of this child item

getBackingListback to summary
protected ObservableList<FilterableTreeItem<T>> getBackingList()
Returns:ObservableList<FilterableTreeItem<T>>

the backing list

getInternalChildrenback to summary
public ObservableList<FilterableTreeItem<T>> getInternalChildren()

Returns the list of children that is backing the filtered list.

Returns:ObservableList<FilterableTreeItem<T>>

underlying list of children

getPredicateback to summary
public final TreeItemPredicate<T> getPredicate()
Returns:TreeItemPredicate<T>

the predicate

predicatePropertyback to summary
public final ObjectProperty<TreeItemPredicate<T>> predicateProperty()
Returns:ObjectProperty<TreeItemPredicate<T>>

the predicate property

setPredicateback to summary
public final void setPredicate(TreeItemPredicate<T> predicate)

Set the predicate

Parameters
predicate:TreeItemPredicate<T>

the predicate

setupFilteredListPredicateBindingsback to summary
private void setupFilteredListPredicateBindings()