|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.tree.DefaultTreeModel
org.argouml.ui.explorer.ExplorerTreeModel
The model for the Explorer tree view of the uml model. provides: - receives events from the uml model and updates itself and the tree ui. - responds to changes in perspetive and ordering.
Nested Class Summary | |
(package private) class |
ExplorerTreeModel.ExplorerUpdater
Help class to semi-lazily update nodes in the tree. |
Field Summary | |
private static Logger |
LOG
|
private Map |
modelElementMap
a map used to resolve model elements to tree nodes when determining what effect a model event will have on the tree. |
private ExplorerTreeModel.ExplorerUpdater |
nodeUpdater
A Runnable object that when executed does update some currently pending nodes. |
private Comparator |
order
the global order for siblings in the tree. |
private Object[] |
rules
an array of PerspectiveRules ,
that determine the tree view. |
private Vector |
updatingChildren
The children currently being updated. |
Fields inherited from class javax.swing.tree.DefaultTreeModel |
asksAllowsChildren, listenerList, root |
Constructor Summary | |
ExplorerTreeModel(Object root)
Creates a new instance of ExplorerTreeModel. |
Method Summary | |
private void |
addNodesToMap(TreeNode node)
Map all nodes in the subtree rooted at node |
private void |
addToMap(Object modelElement,
TreeNode node)
adds a new tree node and model element to the map. |
private void |
collectChildren(Object modelElement,
List newChildren,
Set deps)
Collects the set of children modelElement should have at this point in time. |
private Collection |
findNodes(Object modelElement)
node lookup for a given model element. |
(package private) ExplorerTreeModel.ExplorerUpdater |
getNodeUpdater()
|
void |
insertNodeInto(MutableTreeNode newChild,
MutableTreeNode parent,
int index)
Invoked this to insert newChild at location index in parents children. |
void |
itemStateChanged(ItemEvent e)
Updates the explorer for new perspectives / orderings. |
private void |
mergeChildren(ExplorerTreeNode node,
List children,
List newChildren)
Merges the current children with the new children removing children no longer present and adding new children in the right place. |
void |
modelElementAdded(Object node)
a model element has been added to the model. |
void |
modelElementChanged(Object node)
a model element has changed in some way. |
void |
modelElementRemoved(Object node)
a model element has been removed from the model. |
private Set |
prepareAddRemoveSets(List children,
List newChildren)
Returns a Set of current children to remove and modifies newChildren to only contain the children not already in children and not subsumed by any WeakExplorerNode in children. |
private void |
removeFromMap(Object modelElement,
TreeNode node)
removes a new tree node and model element from the map. |
void |
removeNodeFromParent(MutableTreeNode node)
Message this to remove node from its parent. |
private void |
removeNodesFromMap(TreeNode node)
Unmap all nodes in the subtree rooted at node |
private Vector |
reorderChildren(ExplorerTreeNode node)
Sorts the child nodes of node using the current ordering. |
void |
structureChanged()
the model structure has changed, eg a new project. |
private void |
traverseModified(TreeNode start,
Object node)
Traverses the children, finds those affected by node, and notifies them that they are modified. |
void |
updateChildren(TreePath path)
updates next level of the explorer tree for a given tree path. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final Logger LOG
private Object[] rules
PerspectiveRules
,
that determine the tree view.
private Map modelElementMap
private Comparator order
private Vector updatingChildren
private ExplorerTreeModel.ExplorerUpdater nodeUpdater
Constructor Detail |
public ExplorerTreeModel(Object root)
root
- an object to place at the rootMethod Detail |
public void modelElementChanged(Object node)
modelElementChanged
in interface TreeModelUMLEventListener
node
- the modelelement that is changedTreeModelUMLEventListener.modelElementChanged(java.lang.Object)
public void modelElementAdded(Object node)
modelElementAdded
in interface TreeModelUMLEventListener
node
- the modelelement that is addedTreeModelUMLEventListener.modelElementAdded(java.lang.Object)
private void traverseModified(TreeNode start, Object node)
public void modelElementRemoved(Object node)
modelElementRemoved
in interface TreeModelUMLEventListener
node
- the modelelement that is removedTreeModelUMLEventListener.modelElementRemoved(java.lang.Object)
public void structureChanged()
structureChanged
in interface TreeModelUMLEventListener
public void updateChildren(TreePath path)
path
- the path to the node whose children to update.
IllegalArgumentException
- if node has a child that is not a
(descendant of) DefaultMutableTreeNode.private Vector reorderChildren(ExplorerTreeNode node)
Note: UserObject is only available from descendants of DefaultMutableTreeNode, so any other children couldn't be sorted. Thus these are currently forbidden. But currently no such node is ever inserted into the tree.
node
- the node whose children to sort
IllegalArgumentException
- if node has a child that is not a
(descendant of) DefaultMutableTreeNode.private void collectChildren(Object modelElement, List newChildren, Set deps)
Note: Both newChildren and deps are modified by this function, it is in fact it's primary purpose to modify these collections. It is your responsibility to make sure that they are empty when it is called, or to know what you are doing if they are not.
modelElement
- the element to collect children for.newChildren
- the new children of modelElement.deps
- the set of objects that should be monitored for changes
since these could affect this list.
UnsupportedOperationException
- if add is not supported by
newChildren or addAll isn't supported by deps.
NullPointerException
- if newChildren or deps is null.
ClassCastException
- if newChildren or deps rejects some element.
IllegalArgumentException
- if newChildren or deps rejects some
element.private Set prepareAddRemoveSets(List children, List newChildren)
Note: newChildren will be modified by this call.
Note: It is expected that a WeakExplorerNode will not be reused and thus they will always initially be slated for removal, and only those nodes are in fact used to check subsumption of new nodes. New nodes are not checked among themselves for subsumtion.
children
- is the list of current children.newChildren
- is the list of expected children.
UnsupportedOperationException
- if newChildren doesn't support
remove or removeAll.
NullPointerException
- if either argument is null.private void mergeChildren(ExplorerTreeNode node, List children, List newChildren)
node
- the TreeNode were merging lists for.children
- the current child UserObjects, in order.newChildren
- the expected child UserObjects, in order.
UnsupportedOperationException
- if the Iterator returned by
newChildren doesn't support the remove operation, or if
newChildren itself doesn't support remove or removeAll.
NullPointerException
- if node, children or newChildren are null.public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index)
Also performs subclass specific initialization.
newChild
- The new child node.parent
- The parent node.index
- The index.public void removeNodeFromParent(MutableTreeNode node)
Also performs subclass specific uninitialization.
node
- The node to remove.private void addNodesToMap(TreeNode node)
private void removeNodesFromMap(TreeNode node)
private void addToMap(Object modelElement, TreeNode node)
modelElementRemoved
event is received.
private void removeFromMap(Object modelElement, TreeNode node)
private Collection findNodes(Object modelElement)
public void itemStateChanged(ItemEvent e)
itemStateChanged
in interface ItemListener
ItemListener.itemStateChanged(java.awt.event.ItemEvent)
ExplorerTreeModel.ExplorerUpdater getNodeUpdater()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ArgoUML © 1996-2004 (20050222) | ArgoUML Homepage | ArgoUML Developers' page | ArgoUML Cookbook |