public class RelationTreeModel extends java.lang.Object implements javax.swing.tree.TreeModel
TreeModel which provides the hierarchical structure of Relations
to a JTree.
The model is initialized with a root relation or with a list of RelationMembers, see
populate(Relation) and populate(List) respectively.| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.CopyOnWriteArrayList<javax.swing.event.TreeModelListener> |
listeners
the tree model listeners
|
private Relation |
root
the root relation
|
| Constructor and Description |
|---|
RelationTreeModel()
constructor
|
RelationTreeModel(java.util.List<RelationMember> members)
constructor
|
RelationTreeModel(Relation root)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTreeModelListener(javax.swing.event.TreeModelListener l) |
protected void |
fireRefreshNode(javax.swing.tree.TreePath path)
Notifies tree model listeners about an update of the
trees nodes.
|
protected void |
fireRootReplacedEvent()
Notifies tree model listeners about a replacement of the
root.
|
java.lang.Object |
getChild(java.lang.Object parent,
int index) |
int |
getChildCount(java.lang.Object parent) |
protected int |
getIndexForRelationChild(Relation parent,
Relation child)
Replies the index of a particular
child with respect to its
parent. |
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child) |
protected int |
getNumRelationChildren(Relation parent)
Replies the number of children of type relation for a particular
relation
parent |
protected Relation |
getRelationChildByIdx(Relation parent,
int idx)
Replies the i-th child of type relation for a particular relation
parent. |
java.lang.Object |
getRoot() |
boolean |
isLeaf(java.lang.Object node) |
void |
populate(java.util.List<RelationMember> members)
Populates the model with a list of relation members
|
void |
populate(Relation root)
Populates the model with a root relation
|
void |
refreshNode(javax.swing.tree.TreePath pathToNode)
Invoke to notify all listeners about an update of a particular node
|
void |
removeTreeModelListener(javax.swing.event.TreeModelListener l) |
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue) |
private java.util.concurrent.CopyOnWriteArrayList<javax.swing.event.TreeModelListener> listeners
public RelationTreeModel()
public RelationTreeModel(Relation root)
root - the root relationpublic RelationTreeModel(java.util.List<RelationMember> members)
members - a list of membersprotected int getNumRelationChildren(Relation parent)
parentparent - the parent relationprotected Relation getRelationChildByIdx(Relation parent, int idx)
parent.parent - the parent relationidx - the indexparent; null, if no such child existsprotected int getIndexForRelationChild(Relation parent, Relation child)
child with respect to its
parent.parent - the parent relationchild - the child relationchild with respect to its
parent; -1 if either parent or child are null or if child
isn't a child of parent.public void populate(Relation root)
root - the root relationpopulate(List)public void populate(java.util.List<RelationMember> members)
members - the relation membersprotected void fireRootReplacedEvent()
protected void fireRefreshNode(javax.swing.tree.TreePath path)
path - the tree path to the nodepublic void refreshNode(javax.swing.tree.TreePath pathToNode)
pathToNode - the tree path to the nodepublic java.lang.Object getChild(java.lang.Object parent, int index)
getChild in interface javax.swing.tree.TreeModelpublic int getChildCount(java.lang.Object parent)
getChildCount in interface javax.swing.tree.TreeModelpublic int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
getIndexOfChild in interface javax.swing.tree.TreeModelpublic java.lang.Object getRoot()
getRoot in interface javax.swing.tree.TreeModelpublic boolean isLeaf(java.lang.Object node)
isLeaf in interface javax.swing.tree.TreeModelpublic void addTreeModelListener(javax.swing.event.TreeModelListener l)
addTreeModelListener in interface javax.swing.tree.TreeModelpublic void removeTreeModelListener(javax.swing.event.TreeModelListener l)
removeTreeModelListener in interface javax.swing.tree.TreeModelpublic void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
valueForPathChanged in interface javax.swing.tree.TreeModel