|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--javax.swing.tree.DefaultTreeModel
|
+--edu.mit.ai.psg.ui.outliner.OutlineModel
OutlineModel extends DefaultTreeModel for OutlineNodes, (1) to
trigger generating children when they are accessed if they have
not yet been computed (getChildCount(java.lang.Object)), and (2) to notify
children after they are added to and before they are removed from
parent (insertNodeInto(javax.swing.tree.MutableTreeNode, javax.swing.tree.MutableTreeNode, int), removeNodeFromParent(javax.swing.tree.MutableTreeNode)).
Thread policy: The model invokes OutlineRenderers to create
children, but OutlineRenderers are not called from the AWT thread,
since a renderer may take arbitrarily long, freezing out other
UI updates. Since Swing requires that its objects be updated only
from the AWT event dispatch thread (i.e., it uses an "apartment"
threading style), so changes to the model to add the created child
nodes are always performed in the AWT thread.
SwingUtilities.invokeAndWait(java.lang.Runnable), Serialized Form| Inner Class Summary | |
static class |
OutlineModel.HiddenRootNode
class used for hidden root node in outlines (outlines have a hidden root so that every display node has a parent, and rerendering can simply replace the node in its parent). |
| Fields inherited from class javax.swing.tree.DefaultTreeModel |
asksAllowsChildren,
listenerList,
root |
| Constructor Summary | |
OutlineModel(OutlineModel.HiddenRootNode hiddenRoot)
|
|
OutlineModel(OutlineNode displayRoot,
OutlineRenderer hiddenRootRenderer)
creates and initializes a HiddenRootNode. |
|
| Method Summary | |
void |
addChildrenSafely(OutlineNode outlineNode,
List children)
adds child outline nodes to outlineNode safely (by using the AWT event dispatch thread so it won't interfere with display operations -- see SwingUtilities.invokeAndWait(java.lang.Runnable)) |
void |
addNodeChild(OutlineNode parent,
OutlineNode newChild)
convenience method to insert child at end of children. |
void |
ensureChildrenAreComputed(OutlineNode outlineNode)
If children haven't been computed, nor are they being computed by this thread or another thread, then computeChildren. |
Object |
getChild(Object parent,
int index)
extended to first triggerComputingChildren(edu.mit.ai.psg.ui.outliner.OutlineNode) so that children
are added after node is first expanded, whether by JTree or someone
else. |
int |
getChildCount(Object parent)
extended to first triggerComputingChildren(edu.mit.ai.psg.ui.outliner.OutlineNode) so that children
are added after node is first expanded, whether by JTree or someone
else. |
static OutlineModel |
getModel(OutlineNode outlineNode)
find model using an outline node through hidden root node of outline. |
void |
insertNodeInto(MutableTreeNode newChild,
MutableTreeNode parent,
int index)
extends MutableTreeModel to inform child after it is successfully inserted by calling OutlineRenderer.notifyInserted(edu.mit.ai.psg.ui.outliner.OutlineModel, edu.mit.ai.psg.ui.outliner.OutlineNode, int). |
OutlineNode |
regenerateNode(OutlineNode outlineNode,
OutlineRenderer renderer)
replaces outlineNode in parent with new node created using renderer, notifies model listeners, and returns new outlineNode. |
void |
removeNodeFromParent(MutableTreeNode child)
extends MutableTreeModel to inform child before it is removed by calling OutlineRenderer.notifyRemoving(edu.mit.ai.psg.ui.outliner.OutlineModel, edu.mit.ai.psg.ui.outliner.OutlineNode),
and to set child's parent to null afterward so it is no longer
part of this outline. |
protected void |
triggerComputingChildren(OutlineNode outlineNode)
If children haven't been computed ( OutlineNode.childrenAreComputed()), nor are they being computed,
then triggers creation of another thread to call
ensureChildrenAreComputed(edu.mit.ai.psg.ui.outliner.OutlineNode). |
| Methods inherited from class javax.swing.tree.DefaultTreeModel |
addTreeModelListener,
asksAllowsChildren,
fireTreeNodesChanged,
fireTreeNodesInserted,
fireTreeNodesRemoved,
fireTreeStructureChanged,
getIndexOfChild,
getPathToRoot,
getPathToRoot,
getRoot,
isLeaf,
nodeChanged,
nodesChanged,
nodeStructureChanged,
nodesWereInserted,
nodesWereRemoved,
reload,
reload,
removeTreeModelListener,
setAsksAllowsChildren,
setRoot,
valueForPathChanged |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public OutlineModel(OutlineModel.HiddenRootNode hiddenRoot)
public OutlineModel(OutlineNode displayRoot,
OutlineRenderer hiddenRootRenderer)
hiddenRoot = new HiddenRootNode(hiddenRootRenderer); hiddenRoot.setModel(this); this.addNodeChild(hiddenRoot, displayRoot); hiddenRoot.setChildrenAreComputed(true);
| Method Detail |
public static OutlineModel getModel(OutlineNode outlineNode)
public int getChildCount(Object parent)
triggerComputingChildren(edu.mit.ai.psg.ui.outliner.OutlineNode) so that children
are added after node is first expanded, whether by JTree or someone
else. If need to guarantee that children are computed, first call
ensureChildrenAreComputed(edu.mit.ai.psg.ui.outliner.OutlineNode)
public Object getChild(Object parent,
int index)
triggerComputingChildren(edu.mit.ai.psg.ui.outliner.OutlineNode) so that children
are added after node is first expanded, whether by JTree or someone
else. If need to guarantee that children are computed, first call
ensureChildrenAreComputed(edu.mit.ai.psg.ui.outliner.OutlineNode)protected void triggerComputingChildren(OutlineNode outlineNode)
OutlineNode.childrenAreComputed()), nor are they being computed,
then triggers creation of another thread to call
ensureChildrenAreComputed(edu.mit.ai.psg.ui.outliner.OutlineNode).
This avoids holding up AWT as user code may take indefinitely long, and
display will be updated when children are added.public void ensureChildrenAreComputed(OutlineNode outlineNode)
public void addChildrenSafely(OutlineNode outlineNode,
List children)
SwingUtilities.invokeAndWait(java.lang.Runnable))
public void addNodeChild(OutlineNode parent,
OutlineNode newChild)
addChildrenSafely(edu.mit.ai.psg.ui.outliner.OutlineNode, java.util.List)
public void insertNodeInto(MutableTreeNode newChild,
MutableTreeNode parent,
int index)
OutlineRenderer.notifyInserted(edu.mit.ai.psg.ui.outliner.OutlineModel, edu.mit.ai.psg.ui.outliner.OutlineNode, int).public void removeNodeFromParent(MutableTreeNode child)
OutlineRenderer.notifyRemoving(edu.mit.ai.psg.ui.outliner.OutlineModel, edu.mit.ai.psg.ui.outliner.OutlineNode),
and to set child's parent to null afterward so it is no longer
part of this outline.
public OutlineNode regenerateNode(OutlineNode outlineNode,
OutlineRenderer renderer)
|
Copyright (c) 1996-1999 Massachusetts Institute of Technology Feedback: jeva-feedback@ai.mit.edu |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||