Package is.codion.swing.framework.model
Class SwingEntityTreeModel
java.lang.Object
javax.swing.tree.DefaultTreeModel
is.codion.swing.framework.model.SwingEntityTreeModel
- All Implemented Interfaces:
Serializable,TreeModel
A basic tree model for viewing self-referential entities, using a
SwingEntityTableModel as a data source.
For instances use the swingEntityTreeModel(SwingEntityTableModel, ForeignKey) or
swingEntityTreeModel(SwingEntityTableModel, ForeignKey, Function) factory methods.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA tree node based on anEntityinstance. -
Field Summary
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root -
Method Summary
Modifier and TypeMethodDescriptiongetRoot()voidRefreshes the root node, that is, reloads its children.voidrefreshSelect(Collection<is.codion.framework.domain.entity.Entity> entities) Refreshes this tree and selects the given entitiesvoidremove(Collection<is.codion.framework.domain.entity.Entity> entities) Removes the given entities from this tree modelvoidselect(Collection<is.codion.framework.domain.entity.Entity> entities) Selects the given entities in this tree model.static SwingEntityTreeModelswingEntityTreeModel(SwingEntityTableModel tableModel, is.codion.framework.domain.entity.attribute.ForeignKey parentForeignKey) Instantiates a newSwingEntityTreeModelinstance.static SwingEntityTreeModelswingEntityTreeModel(SwingEntityTableModel tableModel, is.codion.framework.domain.entity.attribute.ForeignKey parentForeignKey, Function<is.codion.framework.domain.entity.Entity, String> stringFunction) Instantiates a newSwingEntityTreeModelinstance.Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
-
Method Details
-
getRoot
- Specified by:
getRootin interfaceTreeModel- Overrides:
getRootin classDefaultTreeModel- Returns:
- the root node
-
treeSelectionModel
- Returns:
- the selection model
-
refreshRoot
public void refreshRoot()Refreshes the root node, that is, reloads its children. -
select
Selects the given entities in this tree model.- Parameters:
entities- the entities to select, an empty collection to clear the selection
-
refreshSelect
Refreshes this tree and selects the given entities- Parameters:
entities- the modified entities
-
remove
Removes the given entities from this tree model- Parameters:
entities- the entities to remove
-
swingEntityTreeModel
public static SwingEntityTreeModel swingEntityTreeModel(SwingEntityTableModel tableModel, is.codion.framework.domain.entity.attribute.ForeignKey parentForeignKey) Instantiates a newSwingEntityTreeModelinstance.- Parameters:
tableModel- the table model data sourceparentForeignKey- the foreign key referencing parent nodes- Returns:
- a new
SwingEntityTreeModelinstance.
-
swingEntityTreeModel
public static SwingEntityTreeModel swingEntityTreeModel(SwingEntityTableModel tableModel, is.codion.framework.domain.entity.attribute.ForeignKey parentForeignKey, Function<is.codion.framework.domain.entity.Entity, String> stringFunction) Instantiates a newSwingEntityTreeModelinstance.- Parameters:
tableModel- the table model data sourceparentForeignKey- the foreign key referencing parent nodesstringFunction- the function for creating String representations of the entities- Returns:
- a new
SwingEntityTreeModelinstance.
-