Interface TreeSelection<T>
- Type Parameters:
T- the item type
- All Superinterfaces:
MultiSelection<T>,SingleSelection<T>
- All Known Subinterfaces:
FilterTreeSelection<T>
The selection of a FilterTreeModel, over its visible nodes, addressed by
row via the indexes, by item via the items, and by node via path() and paths().
The same item may appear in several places in a tree. Selecting by item selects one node holding it, while the
paths address particular nodes. A node hidden below a collapsed ancestor, selected by item or by path, has its
ancestors expanded, so that it can be selected right away. A node not yet in the model, its parent not loaded, is
selected via pending(), which loads as needed and selects it once it is visible, or by item, in case the
model provides the paths of items, see FilterTreeModel.Builder.path(Function).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe pending selection, selecting nodes by path once they are visible, expanding their ancestors and loading as needed.Nested classes/interfaces inherited from interface is.codion.common.model.selection.MultiSelection
MultiSelection.Grouping, MultiSelection.IndexedItems<R>, MultiSelection.Indexes, MultiSelection.IndexStore, MultiSelection.Items<R> -
Method Summary
Modifier and TypeMethodDescriptionitem()Returns theValuecontrolling the selected item.items()The items of the selected nodes, in row order, an item selected in several places appearing once for each.path()The path of the selected node, asitem()is its item.paths()The paths of the selected nodes, in row order, asitems()are their items.pending()Methods inherited from interface is.codion.common.model.selection.MultiSelection
adjusting, changing, count, grouping, index, indexes, multiple, selectAll, single, singleSelectionMethods inherited from interface is.codion.common.model.selection.SingleSelection
clear, present
-
Method Details
-
item
Returns the
Valuecontrolling the selected item.Notifies when the selected item changes, and when the instance the selection refers to is replaced, as happens when the items are refreshed or replaced, the replacement being the same item by
equals()but not the same object.Setting an item selects one node holding it, in order of preference:
- a visible node holding the same instance, an already selected one first, keeping the selection in place
- a visible node holding an equal item, an already selected one first
- a node hidden below a collapsed ancestor, one holding the same instance, otherwise the first one holding an equal item, depth first, its ancestors expanded
path()for a particular node, andpending()for a node not yet loaded.A change vetoed via
MultiSelection.changing()leaves the ancestors expanded.The selection moving between nodes holding the same item instance changes
path(), not the item.- Specified by:
itemin interfaceSingleSelection<T>- Returns:
- the
Valuecontrolling the selected item
-
items
MultiSelection.Items<T> items()The items of the selected nodes, in row order, an item selected in several places appearing once for each.
Each item set or added selects a node of its own, as
item()does, an item not in the model having its ancestors expanded and loaded in case the model provides its path, ignoring an item not in the model otherwise, or excluded, whileMultiSelection.Items.remove(Object)andMultiSelection.Items.contains(Object)cover every selected node holding it, so thatset(get())leaves the selection as is. Restoring prefers neither selected nor hidden nodes. Usepaths()for particular nodes.- Specified by:
itemsin interfaceMultiSelection<T>- Returns:
- the selected items, the items of the selected nodes
-
path
The path of the selected node, as
item()is its item.Setting the path of a node hidden below a collapsed ancestor expands its ancestors and selects it, while the path of a node not in the model, or excluded, clears the selection. Use
pending()for a node not yet loaded.- Returns:
- the
Valuecontrolling the path of the selected node
-
paths
MultiSelection.Items<NodePath<T>> paths()The paths of the selected nodes, in row order, as
items()are their items.Setting or adding the paths of nodes hidden below collapsed ancestors expands their ancestors and selects them, while the paths of nodes not in the model, or excluded, are ignored. Use
pending()for a node not yet loaded.- Returns:
- the
MultiSelection.Itemscontrolling the paths of the selected nodes
-
pending
TreeSelection.Pending<T> pending()- Returns:
- the
TreeSelection.Pendingselection, of nodes selected once they are loaded
-