|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.tree.DefaultTreeModel com.alee.laf.tree.WebTreeModel<E> com.alee.extended.tree.AsyncTreeModel<E>
E
- custom node typepublic class AsyncTreeModel<E extends AsyncUniqueNode>
Special model for asynchronous tree that provides asynchronous data loading. This class also controls the loading animation in elements.
Field Summary | |
---|---|
protected boolean |
asyncLoading
Whether to load childs asynchronously or not. |
protected java.util.List<AsyncTreeModelListener> |
asyncTreeModelListeners
Asynchronous tree listeners. |
protected java.lang.Object |
busyLock
Lock object for busy state changes. |
protected java.lang.Object |
cacheLock
Lock object for cache changes. |
protected AsyncTreeDataProvider<E> |
dataProvider
Asynchronous tree data provider. |
protected java.lang.Object |
modelListenersLock
Lock object for asynchronous tree listeners. |
protected DoubleMap<java.lang.String,E> |
nodeById
Direct nodes cache (node ID -> node). |
protected java.util.Map<java.lang.String,java.lang.Boolean> |
nodeCached
Nodes cached states (parent ID -> childs cached state). |
protected java.util.Map<java.lang.String,java.util.List<E>> |
rawNodeChildsCache
Cache for childs nodes returned by data provider (parent ID -> list of raw child nodes). |
protected static java.lang.String |
ROOT_CACHE
Cache key for root node. |
protected E |
rootNode
Root node cache. |
protected WebAsyncTree<E> |
tree
Asynchronous tree that uses this model. |
Fields inherited from class javax.swing.tree.DefaultTreeModel |
---|
asksAllowsChildren, listenerList, root |
Constructor Summary | |
---|---|
AsyncTreeModel(WebAsyncTree<E> tree,
AsyncTreeDataProvider<E> dataProvider)
Constructs default asynchronous tree model using custom data provider. |
Method Summary | |
---|---|
void |
addAsyncTreeModelListener(AsyncTreeModelListener listener)
Adds new asynchronous tree model listener. |
void |
addChildNodes(E parent,
java.util.List<E> childs)
Adds child nodes for the specified node. |
boolean |
areChildsLoaded(E node)
Returns whether childs for the specified node are already loaded or not. |
protected void |
cacheNodeById(E node)
Caches node by its IDs. |
protected void |
cacheNodesById(java.util.List<E> nodes)
Caches nodes by their IDs. |
protected void |
clearNodeChildsCache(E[] nodes,
boolean clearNodes)
Clears nodes childs cached states. |
protected void |
clearNodeChildsCache(E node,
boolean clearNode)
Clears node and all of its child nodes childs cached states. |
protected void |
clearNodeChildsCache(java.util.List<E> nodes,
boolean clearNodes)
Clears nodes childs cached states. |
protected java.util.List<E> |
filterAndSort(E parentNode,
java.util.List<E> childs)
Performs raw childs filtering and sorting before they can be passed into real tree and returns list of filtered and sorted childs. |
E |
findNode(java.lang.String nodeId)
Looks for the node with the specified ID in the tree model and returns it or null if it was not found. |
protected void |
fireChildsLoadCompleted(E parent,
java.util.List<E> childs)
Fires childs load complete event. |
protected void |
fireChildsLoadFailed(E parent,
java.lang.Throwable cause)
Fires childs load failed event. |
protected void |
fireChildsLoadStarted(E parent)
Fires childs load start event. |
java.util.List<AsyncTreeModelListener> |
getAsyncTreeModelListeners()
Returns list of all available asynchronous tree model listeners. |
E |
getChild(java.lang.Object parent,
int index)
Returns child node for parent node at the specified index. |
int |
getChildCount(java.lang.Object parent)
Returns childs count for specified node. |
AsyncTreeDataProvider<E> |
getDataProvider()
Returns asynchronous tree data provider. |
DoubleMap<java.lang.String,E> |
getNodesCache()
Returns nodes cache map copy. |
E |
getRoot()
Returns tree root node. |
void |
insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
javax.swing.tree.MutableTreeNode parent,
int index)
Inserts new child node into parent node at the specified index. |
void |
insertNodesInto(E[] children,
E parent,
int index)
Inserts an array of child nodes into parent node. |
void |
insertNodesInto(java.util.List<E> children,
E parent,
int index)
Inserts a list of child nodes into parent node. |
protected void |
insertNodesIntoImpl(java.util.List<E> children,
E parent,
int index)
Inserts a list of child nodes into parent node. |
boolean |
isAsyncLoading()
Returns whether childs are loaded asynchronously or not. |
boolean |
isLeaf(java.lang.Object node)
Returns whether the specified node is leaf or not. |
protected int |
loadChildsCount(E parent)
Loads (or reloads) node childs and returns zero or childs count if async mode is off. |
protected void |
performSortingAndFiltering(E parentNode,
boolean recursively)
Updates node childs using current comparator and filter. |
protected void |
performSortingAndFilteringImpl(E parentNode)
Updates node childs recursively using current comparator and filter. |
protected void |
performSortingAndFilteringRecursivelyImpl(E parentNode)
Updates node childs using current comparator and filter. |
protected void |
registerObserver(E node)
Registers image observer for loader icon of the specified node. |
protected void |
registerObservers(E[] nodes)
Registers image observer for loader icons of the specified nodes. |
protected void |
registerObservers(java.util.List<E> nodes)
Registers image observer for loader icons of the specified nodes. |
void |
reload(javax.swing.tree.TreeNode node)
Reloads node childs. |
void |
removeAsyncTreeModelListener(AsyncTreeModelListener listener)
Removes asynchronous tree model listener. |
void |
removeNodeFromParent(javax.swing.tree.MutableTreeNode node)
Removes specified node from parent node. |
void |
setAsyncLoading(boolean asyncLoading)
Sets whether to load childs asynchronously or not. |
void |
setChildNodes(E parent,
java.util.List<E> childs)
Sets child nodes for the specified node. |
void |
updateSortingAndFiltering()
Updates nodes sorting and filtering for all loaded nodes. |
void |
updateSortingAndFiltering(E parentNode)
Updates sorting and filtering for the specified node childs. |
void |
updateSortingAndFiltering(E parentNode,
boolean recursively)
Updates sorting and filtering for the specified node childs. |
Methods inherited from class com.alee.laf.tree.WebTreeModel |
---|
getRootNode, removeNodesFromParent, removeNodesFromParent, removeNodesFromParent, updateNode, updateNodeStructure, updateTree |
Methods inherited from class javax.swing.tree.DefaultTreeModel |
---|
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getTreeModelListeners, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String ROOT_CACHE
protected final java.lang.Object modelListenersLock
protected final java.util.List<AsyncTreeModelListener> asyncTreeModelListeners
protected WebAsyncTree<E extends AsyncUniqueNode> tree
protected boolean asyncLoading
protected AsyncTreeDataProvider<E extends AsyncUniqueNode> dataProvider
protected E extends AsyncUniqueNode rootNode
protected final java.lang.Object cacheLock
protected final java.util.Map<java.lang.String,java.lang.Boolean> nodeCached
protected final java.util.Map<java.lang.String,java.util.List<E extends AsyncUniqueNode>> rawNodeChildsCache
protected final DoubleMap<java.lang.String,E extends AsyncUniqueNode> nodeById
protected final java.lang.Object busyLock
Constructor Detail |
---|
public AsyncTreeModel(WebAsyncTree<E> tree, AsyncTreeDataProvider<E> dataProvider)
tree
- asynchronous treedataProvider
- data providerMethod Detail |
---|
public boolean isAsyncLoading()
public void setAsyncLoading(boolean asyncLoading)
asyncLoading
- whether to load childs asynchronously or notpublic AsyncTreeDataProvider<E> getDataProvider()
public E getRoot()
getRoot
in interface javax.swing.tree.TreeModel
getRoot
in class javax.swing.tree.DefaultTreeModel
public boolean isLeaf(java.lang.Object node)
isLeaf
in interface javax.swing.tree.TreeModel
isLeaf
in class javax.swing.tree.DefaultTreeModel
node
- node
public int getChildCount(java.lang.Object parent)
getChildCount
in interface javax.swing.tree.TreeModel
getChildCount
in class javax.swing.tree.DefaultTreeModel
parent
- parent node
public E getChild(java.lang.Object parent, int index)
getChild
in interface javax.swing.tree.TreeModel
getChild
in class javax.swing.tree.DefaultTreeModel
parent
- parent nodeindex
- child node index
public boolean areChildsLoaded(E node)
node
- node to process
public void reload(javax.swing.tree.TreeNode node)
reload
in class javax.swing.tree.DefaultTreeModel
node
- nodeprotected void clearNodeChildsCache(E node, boolean clearNode)
node
- node to clear cache forclearNode
- whether should clear node cache or notprotected void clearNodeChildsCache(java.util.List<E> nodes, boolean clearNodes)
nodes
- nodes to clear cache forclearNodes
- whether should clear nodes cache or notprotected void clearNodeChildsCache(E[] nodes, boolean clearNodes)
nodes
- nodes to clear cache forclearNodes
- whether should clear nodes cache or notprotected void cacheNodeById(E node)
node
- node to cacheprotected void cacheNodesById(java.util.List<E> nodes)
nodes
- list of nodes to cacheprotected int loadChildsCount(E parent)
parent
- node to load childs for
AsyncTreeDataProvider.loadChilds(AsyncUniqueNode, ChildsListener)
public void setChildNodes(E parent, java.util.List<E> childs)
parent
- node to processchilds
- new node childspublic void addChildNodes(E parent, java.util.List<E> childs)
parent
- node to processchilds
- new node childspublic void removeNodeFromParent(javax.swing.tree.MutableTreeNode node)
removeNodeFromParent
in class javax.swing.tree.DefaultTreeModel
node
- node to removepublic void insertNodeInto(javax.swing.tree.MutableTreeNode newChild, javax.swing.tree.MutableTreeNode parent, int index)
insertNodeInto
in class javax.swing.tree.DefaultTreeModel
newChild
- new child nodeparent
- parent nodeindex
- insert indexpublic void insertNodesInto(java.util.List<E> children, E parent, int index)
insertNodesInto
in class WebTreeModel<E extends AsyncUniqueNode>
children
- list of new child nodesparent
- parent nodeindex
- insert indexprotected void insertNodesIntoImpl(java.util.List<E> children, E parent, int index)
children
- list of new child nodesparent
- parent nodeindex
- insert indexpublic void insertNodesInto(E[] children, E parent, int index)
insertNodesInto
in class WebTreeModel<E extends AsyncUniqueNode>
children
- array of new child nodesparent
- parent nodeindex
- insert indexpublic void updateSortingAndFiltering()
public void updateSortingAndFiltering(E parentNode)
parentNode
- node which childs sorting and filtering should be updatedpublic void updateSortingAndFiltering(E parentNode, boolean recursively)
parentNode
- node which childs sorting and filtering should be updatedrecursively
- whether should update the whole childs structure recursively or notprotected void performSortingAndFiltering(E parentNode, boolean recursively)
parentNode
- node which childs sorting and filtering should be updatedrecursively
- whether should update the whole childs structure recursively or notprotected void performSortingAndFilteringRecursivelyImpl(E parentNode)
parentNode
- node to updateprotected void performSortingAndFilteringImpl(E parentNode)
parentNode
- node to updateprotected java.util.List<E> filterAndSort(E parentNode, java.util.List<E> childs)
childs
- childs to filter and sort
public E findNode(java.lang.String nodeId)
nodeId
- node ID
public DoubleMap<java.lang.String,E> getNodesCache()
protected void registerObservers(java.util.List<E> nodes)
nodes
- nodesprotected void registerObservers(E[] nodes)
nodes
- nodesprotected void registerObserver(E node)
node
- nodepublic java.util.List<AsyncTreeModelListener> getAsyncTreeModelListeners()
public void addAsyncTreeModelListener(AsyncTreeModelListener listener)
listener
- asynchronous tree model listener to addpublic void removeAsyncTreeModelListener(AsyncTreeModelListener listener)
listener
- asynchronous tree model listener to removeprotected void fireChildsLoadStarted(E parent)
parent
- node which childs are being loadedprotected void fireChildsLoadCompleted(E parent, java.util.List<E> childs)
parent
- node which childs were loadedchilds
- loaded child nodesprotected void fireChildsLoadFailed(E parent, java.lang.Throwable cause)
parent
- node which childs were loadedcause
- childs load failure cause
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |