Class RelationTreeModel
- java.lang.Object
-
- org.openstreetmap.josm.gui.dialogs.relation.RelationTreeModel
-
- All Implemented Interfaces:
javax.swing.tree.TreeModel
public class RelationTreeModel extends java.lang.Object implements javax.swing.tree.TreeModel
This is aTreeModelwhich provides the hierarchical structure ofRelations to aJTree. The model is initialized with a root relation or with a list ofRelationMembers, seepopulate(Relation)andpopulate(List)respectively.- Since:
- 1828
-
-
Constructor Summary
Constructors Constructor Description RelationTreeModel()constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTreeModelListener(javax.swing.event.TreeModelListener l)protected voidfireRefreshNode(javax.swing.tree.TreePath path)Notifies tree model listeners about an update of the trees nodes.protected voidfireRootReplacedEvent()Notifies tree model listeners about a replacement of the root.java.lang.ObjectgetChild(java.lang.Object parent, int index)intgetChildCount(java.lang.Object parent)protected intgetIndexForRelationChild(Relation parent, Relation child)Replies the index of a particularchildwith respect to itsparent.intgetIndexOfChild(java.lang.Object parent, java.lang.Object child)protected intgetNumRelationChildren(Relation parent)Replies the number of children of type relation for a particular relationparentprotected RelationgetRelationChildByIdx(Relation parent, int idx)Replies the i-th child of type relation for a particular relationparent.java.lang.ObjectgetRoot()booleanisLeaf(java.lang.Object node)voidpopulate(java.util.List<RelationMember> members)Populates the model with a list of relation membersvoidpopulate(Relation root)Populates the model with a root relationvoidrefreshNode(javax.swing.tree.TreePath pathToNode)Invoke to notify all listeners about an update of a particular nodevoidremoveTreeModelListener(javax.swing.event.TreeModelListener l)voidvalueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
-
-
-
Constructor Detail
-
RelationTreeModel
public RelationTreeModel()
constructor
-
-
Method Detail
-
getNumRelationChildren
protected int getNumRelationChildren(Relation parent)
Replies the number of children of type relation for a particular relationparent- Parameters:
parent- the parent relation- Returns:
- the number of children of type relation
-
getRelationChildByIdx
protected Relation getRelationChildByIdx(Relation parent, int idx)
Replies the i-th child of type relation for a particular relationparent.- Parameters:
parent- the parent relationidx- the index- Returns:
- the i-th child of type relation for a particular relation
parent; null, if no such child exists
-
getIndexForRelationChild
protected int getIndexForRelationChild(Relation parent, Relation child)
Replies the index of a particularchildwith respect to itsparent.- Parameters:
parent- the parent relationchild- the child relation- Returns:
- the index of a particular
childwith respect to itsparent; -1 if either parent or child are null or ifchildisn't a child ofparent.
-
populate
public void populate(Relation root)
Populates the model with a root relation- Parameters:
root- the root relation- See Also:
populate(List)
-
populate
public void populate(java.util.List<RelationMember> members)
Populates the model with a list of relation members- Parameters:
members- the relation members
-
fireRootReplacedEvent
protected void fireRootReplacedEvent()
Notifies tree model listeners about a replacement of the root.
-
fireRefreshNode
protected void fireRefreshNode(javax.swing.tree.TreePath path)
Notifies tree model listeners about an update of the trees nodes.- Parameters:
path- the tree path to the node
-
refreshNode
public void refreshNode(javax.swing.tree.TreePath pathToNode)
Invoke to notify all listeners about an update of a particular node- Parameters:
pathToNode- the tree path to the node
-
getChild
public java.lang.Object getChild(java.lang.Object parent, int index)
- Specified by:
getChildin interfacejavax.swing.tree.TreeModel
-
getChildCount
public int getChildCount(java.lang.Object parent)
- Specified by:
getChildCountin interfacejavax.swing.tree.TreeModel
-
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
- Specified by:
getIndexOfChildin interfacejavax.swing.tree.TreeModel
-
getRoot
public java.lang.Object getRoot()
- Specified by:
getRootin interfacejavax.swing.tree.TreeModel
-
isLeaf
public boolean isLeaf(java.lang.Object node)
- Specified by:
isLeafin interfacejavax.swing.tree.TreeModel
-
addTreeModelListener
public void addTreeModelListener(javax.swing.event.TreeModelListener l)
- Specified by:
addTreeModelListenerin interfacejavax.swing.tree.TreeModel
-
removeTreeModelListener
public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
- Specified by:
removeTreeModelListenerin interfacejavax.swing.tree.TreeModel
-
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
- Specified by:
valueForPathChangedin interfacejavax.swing.tree.TreeModel
-
-