|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.odell.glazedlists.AbstractEventList<E>
ca.odell.glazedlists.TransformedList<TreeList.Node<E>,E>
ca.odell.glazedlists.TreeList<E>
public final class TreeList<E>
A hierarchial EventList that infers its structure from a flat list.
Warning: This class is
thread ready but not thread safe. See EventList
for an example
of thread safe code.
Developer Preview this class is still under development and subject to API changes.
Nested Class Summary | |
---|---|
static interface |
TreeList.ExpansionModel<E>
Provide the expand/collapse state of nodes. |
static interface |
TreeList.Format<E>
Define the tree structure of an node by expressing the path from the element itself to the tree's root. |
static class |
TreeList.Node<E>
A node in the display tree. |
Field Summary | |
---|---|
static TreeList.ExpansionModel |
NODES_START_COLLAPSED
An TreeList.ExpansionModel with a simple policy: all nodes start collapsed. |
static TreeList.ExpansionModel |
NODES_START_EXPANDED
An TreeList.ExpansionModel with a simple policy: all nodes start expanded. |
Fields inherited from class ca.odell.glazedlists.TransformedList |
---|
source |
Fields inherited from class ca.odell.glazedlists.AbstractEventList |
---|
publisher, readWriteLock, updates |
Constructor Summary | |
---|---|
TreeList(EventList<E> source,
TreeList.Format<E> format)
Deprecated. use the constructor that takes an TreeList.ExpansionModel |
|
TreeList(EventList<E> source,
TreeList.Format<E> format,
TreeList.ExpansionModel<E> expansionModel)
Create a new TreeList that adds hierarchy to the specified source list. |
Method Summary | |
---|---|
int |
depth(int visibleIndex)
|
void |
dispose()
Releases the resources consumed by this TransformedList so that it
may eventually be garbage collected. |
E |
get(int visibleIndex)
Returns the element at the specified position in this list. |
boolean |
getAllowsChildren(int visibleIndex)
Whether the value at the specified index can have child nodes or not. |
EventList<TreeList.Node<E>> |
getNodesList()
|
List<TreeList.Node<E>> |
getRoots()
Get a List containing all TreeList.Node s with no parents in the
tree. |
protected int |
getSourceIndex(int mutationIndex)
Gets the index in the source EventList that corresponds to the
specified index. |
TreeList.Node<E> |
getTreeNode(int visibleIndex)
|
boolean |
hasChildren(int visibleIndex)
|
boolean |
isExpanded(int visibleIndex)
|
protected boolean |
isWritable()
Gets whether the source EventList is writable via this API. |
void |
listChanged(ListEvent<TreeList.Node<E>> listChanges)
When the underlying list changes, this notification allows the object to repaint itself or update itself as necessary. |
void |
setExpanded(int visibleIndex,
boolean expanded)
Control whether the child elements of the specified node are visible. |
void |
setTreeFormat(TreeList.Format<E> treeFormat)
Change how the structure of the tree is derived. |
int |
size()
Returns the number of elements in this list. |
int |
subtreeSize(int visibleIndex,
boolean includeCollapsed)
The number of nodes including the node itself in its subtree. |
void |
toggleExpanded(int visibleIndex)
A convenience method to expand the row if it is currently collapsed or vice versa. |
Methods inherited from class ca.odell.glazedlists.TransformedList |
---|
add, addAll, clear, remove, removeAll, retainAll, set |
Methods inherited from class ca.odell.glazedlists.AbstractEventList |
---|
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final TreeList.ExpansionModel NODES_START_EXPANDED
TreeList.ExpansionModel
with a simple policy: all nodes start expanded.
public static final TreeList.ExpansionModel NODES_START_COLLAPSED
TreeList.ExpansionModel
with a simple policy: all nodes start collapsed.
Constructor Detail |
---|
public TreeList(EventList<E> source, TreeList.Format<E> format, TreeList.ExpansionModel<E> expansionModel)
public TreeList(EventList<E> source, TreeList.Format<E> format)
TreeList.ExpansionModel
Method Detail |
---|
public EventList<TreeList.Node<E>> getNodesList()
EventList
of TreeList.Node
s which can be used
to access this tree more structurally.public int depth(int visibleIndex)
public int subtreeSize(int visibleIndex, boolean includeCollapsed)
public int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class TransformedList<TreeList.Node<E>,E>
protected boolean isWritable()
EventList
is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable
in class TransformedList<TreeList.Node<E>,E>
protected int getSourceIndex(int mutationIndex)
EventList
that corresponds to the
specified index. More formally, returns the index such that
this.get(i) == source.get(getSourceIndex(i))
for all
legal values of i
.
getSourceIndex
in class TransformedList<TreeList.Node<E>,E>
public E get(int visibleIndex)
get
in interface List<E>
get
in class TransformedList<TreeList.Node<E>,E>
visibleIndex
- index of element to return.
public TreeList.Node<E> getTreeNode(int visibleIndex)
public boolean hasChildren(int visibleIndex)
true
if the node at the specified index has
children, regardless of whether such children are visible.public void setTreeFormat(TreeList.Format<E> treeFormat)
treeFormat
- public List<TreeList.Node<E>> getRoots()
List
containing all TreeList.Node
s with no parents in the
tree.
public boolean getAllowsChildren(int visibleIndex)
true if child nodes can be added to the
specified node.- See Also:
TreeList.Format.allowsChildren(E)
public boolean isExpanded(int visibleIndex)
true
if the children of the node at the specified
index are visible. Nodes with no children may be expanded or not,
this is used to determine whether to show children should any be
added.public void setExpanded(int visibleIndex, boolean expanded)
expanded
- true
to expand the node, false
to collapse it.public void toggleExpanded(int visibleIndex)
public void listChanged(ListEvent<TreeList.Node<E>> listChanges)
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged
in interface ListEventListener<TreeList.Node<E>>
listChanged
in class TransformedList<TreeList.Node<E>,E>
public void dispose()
TransformedList
so that it
may eventually be garbage collected.
A TransformedList
will be garbage collected without a call to
TransformedList.dispose()
, but not before its source EventList
is garbage
collected. By calling TransformedList.dispose()
, you allow the TransformedList
to be garbage collected before its source EventList
. This is
necessary for situations where a TransformedList
is short-lived but
its source EventList
is long-lived.
Warning: It is an error
to call any method on a TransformedList
after it has been disposed.
dispose
in interface EventList<E>
dispose
in class TransformedList<TreeList.Node<E>,E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |