Class RelationTreeModel
- java.lang.Object
-
- org.openstreetmap.josm.gui.dialogs.relation.RelationTreeModel
-
- All Implemented Interfaces:
TreeModel
public class RelationTreeModel extends Object implements TreeModel
This is aTreeModel
which provides the hierarchical structure ofRelation
s to aJTree
. The model is initialized with a root relation or with a list ofRelationMember
s, seepopulate(Relation)
andpopulate(List)
respectively.- Since:
- 1828
-
-
Field Summary
Fields Modifier and Type Field Description private CopyOnWriteArrayList<TreeModelListener>
listeners
the tree model listenersprivate Relation
root
the root relation
-
Constructor Summary
Constructors Constructor Description RelationTreeModel()
constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTreeModelListener(TreeModelListener l)
protected void
fireRefreshNode(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.Object
getChild(Object parent, int index)
int
getChildCount(Object parent)
protected int
getIndexForRelationChild(Relation parent, Relation child)
Replies the index of a particularchild
with respect to itsparent
.int
getIndexOfChild(Object parent, Object child)
protected int
getNumRelationChildren(Relation parent)
Replies the number of children of type relation for a particular relationparent
protected Relation
getRelationChildByIdx(Relation parent, int idx)
Replies the i-th child of type relation for a particular relationparent
.Object
getRoot()
boolean
isLeaf(Object node)
void
populate(List<RelationMember> members)
Populates the model with a list of relation membersvoid
populate(Relation root)
Populates the model with a root relationvoid
refreshNode(TreePath pathToNode)
Invoke to notify all listeners about an update of a particular nodevoid
removeTreeModelListener(TreeModelListener l)
void
valueForPathChanged(TreePath path, Object newValue)
-
-
-
Field Detail
-
listeners
private final CopyOnWriteArrayList<TreeModelListener> listeners
the tree model listeners
-
-
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 particularchild
with respect to itsparent
.- Parameters:
parent
- the parent relationchild
- the child relation- Returns:
- the index of a particular
child
with respect to itsparent
; -1 if either parent or child are null or ifchild
isn'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(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(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(TreePath pathToNode)
Invoke to notify all listeners about an update of a particular node- Parameters:
pathToNode
- the tree path to the node
-
getChildCount
public int getChildCount(Object parent)
- Specified by:
getChildCount
in interfaceTreeModel
-
getIndexOfChild
public int getIndexOfChild(Object parent, Object child)
- Specified by:
getIndexOfChild
in interfaceTreeModel
-
addTreeModelListener
public void addTreeModelListener(TreeModelListener l)
- Specified by:
addTreeModelListener
in interfaceTreeModel
-
removeTreeModelListener
public void removeTreeModelListener(TreeModelListener l)
- Specified by:
removeTreeModelListener
in interfaceTreeModel
-
valueForPathChanged
public void valueForPathChanged(TreePath path, Object newValue)
- Specified by:
valueForPathChanged
in interfaceTreeModel
-
-