public final class TreePathSupport extends Object
Principally what this class does is manage the state of expanded paths which are not visible, or whose parents have been closed/opened. Whereas the layout cache retains information only about what is visibly expanded, this class manages information about any path that has been expanded at some point in the lifetime of an Outline, so that for example, if A contains B contains C, and A and B and C are expanded, then the user collapses A, and later re-expands A, B and C will retain their expanded state and appear as they did the last time A was expanded.
When nodes are removed, the OutlineModel must call removePath() for any defunct paths to avoid memory leaks by the TreePathSupport holding references to defunct nodes and not allowing them to be garbage collected.
Its addTreeWillExpandListener
code supports
ExtTreeWillExpandListener
, so such a listener may be notified
if some other listener vetoes a pending expansion event.
Constructor and Description |
---|
TreePathSupport(OutlineModel mdl,
AbstractLayoutCache layout)
Creates a new instance of TreePathSupport
|
Modifier and Type | Method and Description |
---|---|
void |
addTreeExpansionListener(TreeExpansionListener l)
Add a TreeExpansionListener.
|
void |
addTreeWillExpandListener(TreeWillExpandListener l)
Add a TreeWillExpandListener.
|
void |
clear()
Clear all expanded path data.
|
void |
collapsePath(TreePath path)
Collapse a path.
|
void |
expandPath(TreePath path)
Expand a path.
|
TreePath[] |
getExpandedDescendants(TreePath parent)
Get all expanded descendants of the given tree path.
|
boolean |
hasBeenExpanded(TreePath path)
Test if the tree path is expanded.
|
boolean |
isExpanded(TreePath path)
Returns true if the node identified by the path is currently expanded,
|
boolean |
isVisible(TreePath path)
Test if the tree path is visible (the parent path is expanded).
|
void |
removePath(TreePath path)
Remove a path's data from the list of known paths.
|
void |
removeTreeExpansionListener(TreeExpansionListener l)
Remove a TreeExpansionListener.
|
void |
removeTreeWillExpandListener(TreeWillExpandListener l)
Remove a TreeWillExpandListener.
|
public TreePathSupport(OutlineModel mdl, AbstractLayoutCache layout)
public void clear()
public void expandPath(TreePath path)
path
- The tree path to expandpublic void collapsePath(TreePath path)
path
- The tree path to collapsepublic void removePath(TreePath path)
path
- The tree path to removepublic boolean hasBeenExpanded(TreePath path)
path
- The tree path to testtrue
if the path is expanded, false
otherwise.public boolean isExpanded(TreePath path)
path
- the TreePath
specifying the node to checkpublic boolean isVisible(TreePath path)
path
- The tree path to testtrue
if the path is visible, false
otherwise.public TreePath[] getExpandedDescendants(TreePath parent)
parent
- Tree path to find the expanded descendants forpublic void addTreeExpansionListener(TreeExpansionListener l)
l
- The tree expansion listenerpublic void removeTreeExpansionListener(TreeExpansionListener l)
l
- The tree expansion listenerpublic void addTreeWillExpandListener(TreeWillExpandListener l)
l
- The tree will expand listenerpublic void removeTreeWillExpandListener(TreeWillExpandListener l)
l
- The tree will expand listener