public class ExTreeModel<E extends UniqueNode> extends WebTreeModel<E>
WebExTree,
ExTreeDataProvider,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object |
cacheLock
Lock object for cache changes.
|
protected ExTreeDataProvider<E> |
dataProvider
Ex tree data provider.
|
protected com.alee.utils.collection.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 -> children cached state).
|
protected java.util.Map<java.lang.String,java.util.List<E>> |
rawNodeChildrenCache
Cache for children nodes returned by data provider (parent ID -> list of raw child nodes).
|
protected E |
rootNode
Root node cache.
|
protected WebTree<E> |
tree
Ex tree that uses this model.
|
| Constructor and Description |
|---|
ExTreeModel(WebTree<E> tree,
ExTreeDataProvider<E> dataProvider)
Constructs default ex tree model using custom data provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChildNodes(E parent,
java.util.List<E> children)
Adds child nodes for the specified node.
|
boolean |
areChildrenLoaded(E node)
Returns whether children 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 |
clearNodeChildrenCache(E[] nodes,
boolean clearNodes)
Clears nodes children cached states.
|
protected void |
clearNodeChildrenCache(E node,
boolean clearNode)
Clears node and all of its child nodes children cached states.
|
protected void |
clearNodeChildrenCache(java.util.List<E> nodes,
boolean clearNodes)
Clears nodes children cached states.
|
protected java.util.List<E> |
filterAndSort(E parentNode,
java.util.List<E> children)
Returns list of filtered and sorted raw children.
|
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.
|
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 children count for specified node.
|
ExTreeDataProvider<E> |
getDataProvider()
Returns ex tree data provider.
|
com.alee.utils.collection.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.
|
protected void |
insertNodeIntoImpl(E child,
E parent,
int index)
Inserts a child node into parent node.
|
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(E[] children,
E parent,
int index)
Inserts an array 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 |
isLeaf(java.lang.Object node)
Returns whether the specified node is leaf or not.
|
protected int |
loadChildren(E parent)
Loads (or reloads) node children and returns zero or children count if async mode is off.
|
protected void |
loadTreeData(E node)
Forces model to cache the whole structure so any node can be accessed right away.
|
protected void |
performSortingAndFiltering(E parentNode,
boolean recursively)
Updates node children using current comparator and filter.
|
protected void |
performSortingAndFilteringImpl(E parentNode)
Updates node children recursively using current comparator and filter.
|
protected void |
performSortingAndFilteringRecursivelyImpl(E parentNode)
Updates node children using current comparator and filter.
|
void |
reload(javax.swing.tree.TreeNode node)
Reloads node children.
|
void |
removeNodeFromParent(javax.swing.tree.MutableTreeNode node)
Removes specified node from parent node.
|
void |
setChildNodes(E parent,
java.util.List<E> children)
Sets child nodes for the specified node.
|
void |
updateSortingAndFiltering()
Updates nodes sorting and filtering for all nodes.
|
void |
updateSortingAndFiltering(E parentNode)
Updates sorting and filtering for the specified node children.
|
void |
updateSortingAndFiltering(E parentNode,
boolean recursively)
Updates sorting and filtering for the specified node children.
|
getRootNode, removeNodesFromParent, removeNodesFromParent, removeNodesFromParent, updateNode, updateNodeStructure, updateTree, valueForPathChangedaddTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getTreeModelListeners, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, removeTreeModelListener, setAsksAllowsChildren, setRootprotected final WebTree<E extends UniqueNode> tree
protected final ExTreeDataProvider<E extends UniqueNode> dataProvider
protected E extends UniqueNode 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 UniqueNode>> rawNodeChildrenCache
protected final com.alee.utils.collection.DoubleMap<java.lang.String,E extends UniqueNode> nodeById
public ExTreeModel(WebTree<E> tree, ExTreeDataProvider<E> dataProvider)
tree - asynchronous treedataProvider - data providerpublic ExTreeDataProvider<E> getDataProvider()
public E getRoot()
getRoot in interface javax.swing.tree.TreeModelgetRoot in class javax.swing.tree.DefaultTreeModelpublic boolean isLeaf(java.lang.Object node)
isLeaf in interface javax.swing.tree.TreeModelisLeaf in class javax.swing.tree.DefaultTreeModelnode - nodepublic int getChildCount(java.lang.Object parent)
getChildCount in interface javax.swing.tree.TreeModelgetChildCount in class javax.swing.tree.DefaultTreeModelparent - parent nodepublic E getChild(java.lang.Object parent, int index)
getChild in interface javax.swing.tree.TreeModelgetChild in class javax.swing.tree.DefaultTreeModelparent - parent nodeindex - child node indexpublic boolean areChildrenLoaded(E node)
node - node to processprotected void loadTreeData(E node)
This method is mostly used to ensure that at any given time WebExTree has all of its nodes.
That heavily simplifies work with the tree in case you need to access random nodes in the tree directly.
In case this is not your goal it is probably better to use WebAsyncTree.
node - node to load data forpublic void reload(javax.swing.tree.TreeNode node)
reload in class javax.swing.tree.DefaultTreeModelnode - nodeprotected void clearNodeChildrenCache(E node, boolean clearNode)
node - node to clear cache forclearNode - whether should clear node cache or notprotected void clearNodeChildrenCache(java.util.List<E> nodes, boolean clearNodes)
nodes - nodes to clear cache forclearNodes - whether should clear nodes cache or notprotected void clearNodeChildrenCache(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 loadChildren(E parent)
parent - node to load children forpublic void setChildNodes(E parent, java.util.List<E> children)
parent - node to processchildren - new node childrenpublic void addChildNodes(E parent, java.util.List<E> children)
parent - node to processchildren - new node childrenpublic void removeNodeFromParent(javax.swing.tree.MutableTreeNode node)
removeNodeFromParent in class javax.swing.tree.DefaultTreeModelnode - node to removepublic void insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
javax.swing.tree.MutableTreeNode parent,
int index)
insertNodeInto in class javax.swing.tree.DefaultTreeModelnewChild - new child nodeparent - parent nodeindex - insert indexpublic void insertNodesInto(java.util.List<E> children, E parent, int index)
insertNodesInto in class WebTreeModel<E extends UniqueNode>children - list of new child nodesparent - parent nodeindex - insert indexpublic void insertNodesInto(E[] children, E parent, int index)
insertNodesInto in class WebTreeModel<E extends UniqueNode>children - array of new child nodesparent - parent nodeindex - insert indexprotected void insertNodeIntoImpl(E child, E parent, int index)
child - new child nodeparent - parent nodeindex - insert indexprotected void insertNodesIntoImpl(java.util.List<E> children, E parent, int index)
children - list of new child nodesparent - parent nodeindex - insert indexprotected void insertNodesIntoImpl(E[] children, E parent, int index)
children - array of new child nodesparent - parent nodeindex - insert indexpublic void updateSortingAndFiltering()
public void updateSortingAndFiltering(E parentNode)
parentNode - node which children sorting and filtering should be updatedpublic void updateSortingAndFiltering(E parentNode, boolean recursively)
parentNode - node which children sorting and filtering should be updatedrecursively - whether should update the whole children structure recursively or notprotected void performSortingAndFiltering(E parentNode, boolean recursively)
parentNode - node which children sorting and filtering should be updatedrecursively - whether should update the whole children 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> children)
parentNode - parent nodechildren - children to filter and sortpublic E findNode(java.lang.String nodeId)
nodeId - node IDpublic com.alee.utils.collection.DoubleMap<java.lang.String,E> getNodesCache()