- All Superinterfaces:
FilterTreeModel<Entity>
- All Known Subinterfaces:
SwingEntityTreeModel
- All Known Implementing Classes:
AbstractEntityTreeModel
A FilterTreeModel of entities, arranged by foreign keys: the children of a node are the entities
referencing it via the configured foreign keys, selected when the node is loaded.
One foreign key referencing its own entity type, Employee.REPORTSTO_FK for example, applies at every
level, so the depth comes from the data, while foreign keys referencing other types form a fixed number of levels,
Album.ARTIST_FK and Track.ALBUM_FK under artists for example. The two may be mixed: the employees by
their manager, each with their customers.
The roots are the entities of the root type, by default the ones whose self-referencing foreign keys, if any are configured, are null, the top of the hierarchy.
The roots, and the children via each foreign key, can be configured with a condition, the EntityConnection.Select they are
selected with, and a comparator, see EntityTreeModel.Builder.RootsStep.roots(EntityType, Consumer) and
EntityTreeModel.Builder.children(ForeignKey, Consumer).
By default, whether a node is a leaf is decided when its parent is loaded, along with its siblings: a node of an
entity type no configured foreign key references is always a leaf, while for the others a single query per foreign
key finds which of the siblings are referenced, see EntityTreeModel.Builder.leaves(Function).
Siblings of different entity types are ordered by type, in the order their foreign keys were configured. Siblings
of one type are ordered by the first of: the comparator of the roots or the foreign key, the order by of their
select, keeping the query order, the comparator of the tree, see EntityTreeModel.Builder.comparator(Comparator), and the
EntityDefinition.comparator() of the entity type.
The model updates on refresh, FilterTreeModel.Nodes.refresh(NodePath) reloading a node exactly, while
FilterTreeModel.Nodes.add(NodePath, Collection), FilterTreeModel.Nodes.replace(NodePath, Object) and FilterTreeModel.Nodes.remove(Collection)
apply edits in memory.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceEntityTreeModel.Builder<B extends EntityTreeModel.Builder<B>>Builds aEntityTreeModel.Nested classes/interfaces inherited from interface is.codion.common.model.component.tree.FilterTreeModel
FilterTreeModel.Expansion<T>, FilterTreeModel.Loader<T>, FilterTreeModel.Nodes<T>, FilterTreeModel.NodesListener<T>, FilterTreeModel.VisibleNodes<T> -
Method Summary
-
Method Details
-
connection
EntityConnection connection()- Returns:
- the connection used by this tree model
-
builder
- Returns:
- a
EntityTreeModel.Builder.RootsStepinstance
-