public abstract class CachedChildrenTreeModel extends Object implements TreeModel, AsynchronousModelFilter
AsynchronousModelFilter.CALL
CURRENT_THREAD, DEFAULT
Constructor and Description |
---|
CachedChildrenTreeModel() |
Modifier and Type | Method and Description |
---|---|
Executor |
asynchronous(Executor original,
AsynchronousModelFilter.CALL asynchCall,
Object node)
Change the threading information for view models method calls.
|
protected boolean |
cacheChildrenOf(Object node)
Can be overridden to decide which nodes to cache and which not.
|
protected void |
clearCache()
Clear the entire cache.
|
protected abstract Object[] |
computeChildren(Object node)
Compute the children nodes.
|
Object[] |
getChildren(Object o,
int from,
int to)
Returns children for given parent on given indexes.
|
protected void |
recomputeChildren()
Force to recompute all cached children.
|
protected void |
recomputeChildren(Object node)
Force to recompute children cached for the given node.
|
protected void |
refreshCache(Object node)
Force a refresh of the cache.
|
protected Object[] |
reorder(Object[] nodes)
Allows to reorder the children.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addModelListener, getChildrenCount, getRoot, isLeaf, removeModelListener
public Executor asynchronous(Executor original, AsynchronousModelFilter.CALL asynchCall, Object node) throws UnknownTypeException
AsynchronousModelFilter
AsynchronousModelFilter.CALL
enum.asynchronous
in interface AsynchronousModelFilter
original
- The original Executor
asynchCall
- Identification of the method callnode
- Object nodeUnknownTypeException
public final Object[] getChildren(Object o, int from, int to) throws UnknownTypeException
TreeModel
This method works in pair with TreeModel.getChildrenCount(java.lang.Object)
, the to
parameter is up to the value that is returned from TreeModel.getChildrenCount(java.lang.Object)
.
If the list of children varies over time, the implementation code
needs to pay attention to bounds and check the from
and
to
parameters, especially if TreeModel.getChildrenCount(java.lang.Object)
returns Integer.MAX_VALUE
. Caching of the children between
TreeModel.getChildrenCount(java.lang.Object)
and TreeModel.getChildren(java.lang.Object, int, int)
can be used as well,
if necessary.
getChildren
in interface TreeModel
o
- a parent of returned nodesfrom
- a start indexto
- a end indexUnknownTypeException
- if this TreeModel implementation is not
able to resolve children for given node typeTreeModel.getChildrenCount(java.lang.Object)
protected abstract Object[] computeChildren(Object node) throws UnknownTypeException
node
- The node to compute the children forUnknownTypeException
- When this implementation is not able to
resolve children for given node typeprotected boolean cacheChildrenOf(Object node)
node
- The nodetrue
when the children of this node should be cached,
false
otherwise. The default implementation returns
true
always.protected final void refreshCache(Object node)
node
- The node to refresh the cache for.protected final void clearCache()
protected Object[] reorder(Object[] nodes)
nodes
- The original nodes returned by CachedChildrenTreeModel.computeChildren(java.lang.Object)
or by the cache.protected final void recomputeChildren() throws UnknownTypeException
UnknownTypeException
- When this implementation is not able to
resolve children for some node typeprotected final void recomputeChildren(Object node) throws UnknownTypeException
node
- The node to recompute the children forUnknownTypeException
- When this implementation is not able to
resolve children for the given node type