com.alee.extended.tree
Class WebAsyncTree<E extends AsyncUniqueNode>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTree
                  extended by com.alee.laf.tree.WebTree<E>
                      extended by com.alee.extended.tree.WebAsyncTree<E>
Type Parameters:
E - tree nodes type
All Implemented Interfaces:
AsyncTreeModelListener<E>, FontMethods<WebTree<E>>, SwingMethods, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.Scrollable
Direct Known Subclasses:
WebFileTree

public class WebAsyncTree<E extends AsyncUniqueNode>
extends WebTree<E>
implements AsyncTreeModelListener<E>

This class provides a custom tree with asynchronous childs loading. All you need is to provide a custom AsyncTreeDataProvider for the new WebAsyncTree instance.

Author:
Mikle Garin
See Also:
How to use WebAsyncTree, WebTree, AsyncTreeModel, AsyncTreeDataProvider, AsyncTreeListener, WebAsyncTreeCellRenderer, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTree
javax.swing.JTree.AccessibleJTree, javax.swing.JTree.DropLocation, javax.swing.JTree.DynamicUtilTreeNode, javax.swing.JTree.EmptySelectionModel, javax.swing.JTree.TreeModelHandler, javax.swing.JTree.TreeSelectionRedirector
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean asyncLoading
          Whether to load childs asynchronously or not.
protected  java.util.List<AsyncTreeListener> asyncTreeListeners
          Asynchronous tree listeners.
protected  CellEditorAdapter cellEditorAdapter
          Special cell editor listener.
protected  java.util.Comparator<E> comparator
          Tree nodes comparator.
protected  Filter<E> filter
          Tree nodes filter.
protected  java.lang.Object listenersLock
          Asynchronous tree listeners lock object.
protected static java.lang.Object lock
          General lock.
protected  java.lang.Object syncLoadingLock
          Sync loading methods and option lock.
 
Fields inherited from class com.alee.laf.tree.WebTree
cellEditorListeners, CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, scrollToSelectionListener, SINGLE_TREE_SELECTION
 
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WebAsyncTree()
          Constructs sample asynchronous tree.
WebAsyncTree(AsyncTreeDataProvider dataProvider)
          Costructs asynchronous tree using data from the custom data provider.
WebAsyncTree(AsyncTreeModel newModel)
          Costructs asynchronous tree using the specified tree model.
 
Method Summary
 void addAsyncTreeListener(AsyncTreeListener listener)
          Adds new asynchronous tree listener.
 void addChildNode(E parent, E child)
          Adds child node for the specified node.
 void addChildNodes(E parent, java.util.List<E> children)
          Adds child nodes for the specified node.
 boolean areChildsLoaded(E parent)
          Returns whether childs for the specified node are already loaded or not.
 void childsLoadCompleted(E parent, java.util.List<E> childs)
          Invoked when childs load operation finishes.
 void childsLoadFailed(E parent, java.lang.Throwable cause)
          Invoked when childs load operation fails.
 void childsLoadStarted(E parent)
          Invoked when childs load operation starts.
 void clearComparator()
          Removes any applied tree nodes comparator.
 void clearFilter()
          Removes any applied tree nodes filter.
 void expandAll()
          Expands all visible tree rows in a single call.
 void expandNode(java.lang.String nodeId)
          Expands node with the specified ID.
 void expandPath(java.util.List<java.lang.String> pathNodeIds)
          Expands path using the specified node path IDs.
 void expandPath(java.util.List<java.lang.String> pathNodeIds, AsyncPathExpansionListener listener)
          Expands path using the specified node path IDs.
 void expandPath(java.util.List<java.lang.String> pathNodeIds, boolean expandLastNode)
          Expands path using the specified node path IDs.
 void expandPath(java.util.List<java.lang.String> pathNodeIds, boolean expandLastNode, AsyncPathExpansionListener listener)
          Expands path using the specified node path IDs.
 void expandPath(java.util.List<java.lang.String> pathNodeIds, boolean expandLastNode, boolean selectLastNode)
          Expands path using the specified node path IDs.
 void expandPath(java.util.List<java.lang.String> pathNodeIds, boolean expandLastNode, boolean selectLastNode, AsyncPathExpansionListener listener)
          Expands path using the specified node path IDs.
protected  void expandPathEndImpl(E lastFoundNode, boolean expandLastNode, boolean selectLastNode)
          Finishes async tree path expansion.
protected  void expandPathImpl(E currentNode, java.util.List<java.lang.String> leftToExpand, boolean expandLastNode, boolean selectLastNode, AsyncPathExpansionListener listener)
          Performs a single path node expansion.
 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 complete event.
protected  void fireChildsLoadStarted(E parent)
          Fires childs load start event.
 AsyncTreeModel<E> getAsyncModel()
          Returns asynchronous tree model.
 java.util.List<AsyncTreeListener> getAsyncTreeListeners()
          Returns all available asynchronous tree listeners list.
 java.util.Comparator<E> getComparator()
          Returns tree nodes comparator.
 AsyncTreeDataProvider<E> getDataProvider()
          Returns asynchronous tree data provider.
 Filter<E> getFilter()
          Returns tree nodes filter.
 void insertChildNodes(E[] children, E parent, int index)
          Inserts an array of child nodes into parent node.
 void insertChildNodes(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 isAsyncModel()
          Returns whether asynchronous tree model is installed or not.
protected  void performFullAsyncPathExpand(javax.swing.tree.TreePath path)
          Expands path asynchronously.
protected  void performFullPathExpand(javax.swing.tree.TreePath path)
          Expands path right away (if node childs were loaded atleast once before or not) or asynchronously.
protected  void performFullSyncPathExpand(javax.swing.tree.TreePath path)
          Expands path right away.
protected  void performReload(E node, javax.swing.tree.TreePath path, boolean select)
          Performs the actual reload call.
 E reloadNode(E node)
          Reloads specified node childs.
 E reloadNode(E node, boolean select)
          Reloads specified node childs and selects it if requested.
 E reloadNode(java.lang.String nodeId)
          Reloads node with the specified ID.
 E reloadNodeSync(E node)
          Reloads specified node childs.
 E reloadNodeSync(E node, boolean select)
          Reloads specified node childs and selects it if requested.
 E reloadNodeSync(java.lang.String nodeId)
          Reloads node with the specified ID.
 E reloadNodeUnderPoint(int x, int y)
          Reloads node under the specified point.
 E reloadNodeUnderPoint(java.awt.Point point)
          Reloads node under the specified point.
 E reloadPath(javax.swing.tree.TreePath path)
          Reloads node childs at the specified path.
 E reloadPath(javax.swing.tree.TreePath path, boolean select)
          Reloads node childs at the specified path and selects it if needed.
 E reloadPathSync(javax.swing.tree.TreePath path)
          Reloads node childs at the specified path.
 E reloadPathSync(javax.swing.tree.TreePath path, boolean select)
          Reloads node childs at the specified path and selects it if needed.
 E reloadRootNode()
          Reloads root node childs.
 void reloadSelectedNodes()
          Reloads selected node childs.
 void reloadSelectedNodesSync()
          Reloads selected node childs.
 void removeAsyncTreeListener(AsyncTreeListener listener)
          Removes asynchronous tree listener.
 boolean removeNode(E node)
          Removes node from tree structure.
 boolean removeNode(java.lang.String nodeId)
          Removes node with the specified ID from tree structure.
 void removeNodes(E[] nodes)
          Removes nodes from tree structure.
 void removeNodes(java.util.List<E> nodes)
          Removes nodes from tree structure.
 void setAsyncLoading(boolean asyncLoading)
          Sets whether to load childs asynchronously or not.
 void setCellEditor(javax.swing.tree.TreeCellEditor cellEditor)
          Sets the cell editor for this tree.
 void setChildNodes(E parent, java.util.List<E> children)
          Sets child nodes for the specified node.
 void setComparator(java.util.Comparator<E> comparator)
          Sets tree nodes comparator.
 void setDataProvider(AsyncTreeDataProvider dataProvider)
          Changes data provider for this asynchronous tree.
 void setFilter(Filter<E> filter)
          Sets tree nodes filter.
 void setMaximumThreadsAmount(int amount)
          Sets maximum threads amount for this asynchronous tree.
 void setModel(javax.swing.tree.TreeModel newModel)
          Sets the TreeModel that will provide the data.
 void updateNode(E node)
          Forces tree node to be updated.
 void updateNode(java.lang.String nodeId)
          Forces tree node with the specified ID to be updated.
 void updateNodeStructure(E node)
          Forces tree node structure with the specified ID to be updated.
 void updateNodeStructure(java.lang.String nodeId)
          Forces tree node structure with the specified ID to be updated.
 void updateSortingAndFiltering()
          Updates nodes sorting and filtering for all loaded nodes.
 void updateSortingAndFiltering(E node)
          Updates sorting and filtering for the specified node childs.
 
Methods inherited from class com.alee.laf.tree.WebTree
addCellEditorListener, changeFontSize, createTreeModel, expandNode, expandRoot, getAllNodes, getClosestNodeForLocation, getClosestNodeForLocation, getClosestPathForLocation, getDefaultTreeModel, getDropCellShadeWidth, getFirstVisibleLeafNode, getFontName, getFontSize, getLinesColor, getNodeBounds, getNodeBounds, getNodeForLocation, getNodeForLocation, getNodeForPath, getNodeForRow, getPathForLocation, getPathForNode, getRootNode, getSelectedNode, getSelectedNodes, getSelectionRound, getSelectionShadeWidth, getSelectionStyle, getSelectorBorderColor, getSelectorColor, getSelectorRound, getSelectorStroke, getTreeState, getTreeState, getWebUI, init, isAutoExpandSelectedNode, isBoldFont, isExpanded, isHighlightRolloverNode, isItalicFont, isPaintLines, isPlainFont, isRolloverSelectionEnabled, isScrollToSelection, isSelected, isSelectorEnabled, removeCellEditorListener, repaint, repaint, repaint, repaint, scrollToNode, scrollToSelection, scrollToStart, selectFirstVisibleLeafNode, selectNextRow, selectNextRow, selectNodeUnderPoint, selectNodeUnderPoint, selectPreviousRow, selectPreviousRow, setAutoExpandSelectedNode, setBoldFont, setBoldFont, setDropCellShadeWidth, setFontName, setFontSize, setFontSizeAndStyle, setFontSizeAndStyle, setFontStyle, setFontStyle, setHighlightRolloverNode, setItalicFont, setItalicFont, setLinesColor, setMultiplySelectionAllowed, setPaintLines, setPlainFont, setPlainFont, setRolloverSelectionEnabled, setScrollToSelection, setSelectedNode, setSelectedNodes, setSelectedNodes, setSelectionMode, setSelectionRound, setSelectionShadeWidth, setSelectionStyle, setSelectorBorderColor, setSelectorColor, setSelectorEnabled, setSelectorRound, setSelectorStroke, setTreeState, setTreeState, startEditingNode, startEditingSelectedNode, updateAllVisibleNodes, updateUI
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellRenderer, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lock

protected static final java.lang.Object lock
General lock.


listenersLock

protected final java.lang.Object listenersLock
Asynchronous tree listeners lock object.


asyncTreeListeners

protected java.util.List<AsyncTreeListener> asyncTreeListeners
Asynchronous tree listeners.


syncLoadingLock

protected final java.lang.Object syncLoadingLock
Sync loading methods and option lock.


asyncLoading

protected boolean asyncLoading
Whether to load childs asynchronously or not.


comparator

protected java.util.Comparator<E extends AsyncUniqueNode> comparator
Tree nodes comparator.


filter

protected Filter<E extends AsyncUniqueNode> filter
Tree nodes filter.


cellEditorAdapter

protected CellEditorAdapter cellEditorAdapter
Special cell editor listener. It updates filtering and sorting after editing has finished.

Constructor Detail

WebAsyncTree

public WebAsyncTree()
Constructs sample asynchronous tree.


WebAsyncTree

public WebAsyncTree(AsyncTreeDataProvider dataProvider)
Costructs asynchronous tree using data from the custom data provider.

Parameters:
dataProvider - custom data provider

WebAsyncTree

public WebAsyncTree(AsyncTreeModel newModel)
Costructs asynchronous tree using the specified tree model.

Parameters:
newModel - custom tree model
Method Detail

isAsyncLoading

public boolean isAsyncLoading()
Returns whether childs are loaded asynchronously or not.

Returns:
true if childs are loaded asynchronously, false otherwise

setAsyncLoading

public void setAsyncLoading(boolean asyncLoading)
Sets whether to load childs asynchronously or not.

Parameters:
asyncLoading - whether to load childs asynchronously or not

getDataProvider

public AsyncTreeDataProvider<E> getDataProvider()
Returns asynchronous tree data provider.

Returns:
data provider

setDataProvider

public void setDataProvider(AsyncTreeDataProvider dataProvider)
Changes data provider for this asynchronous tree.

Parameters:
dataProvider - new data provider

getComparator

public java.util.Comparator<E> getComparator()
Returns tree nodes comparator.

Returns:
tree nodes comparator

setComparator

public void setComparator(java.util.Comparator<E> comparator)
Sets tree nodes comparator. Comparator replacement will automatically update all loaded nodes sorting.

Parameters:
comparator - tree nodes comparator

clearComparator

public void clearComparator()
Removes any applied tree nodes comparator.


getFilter

public Filter<E> getFilter()
Returns tree nodes filter.

Returns:
tree nodes filter

setFilter

public void setFilter(Filter<E> filter)
Sets tree nodes filter. Comparator replacement will automatically re-filter all loaded nodes.

Parameters:
filter - tree nodes filter

clearFilter

public void clearFilter()
Removes any applied tree nodes filter.


updateSortingAndFiltering

public void updateSortingAndFiltering()
Updates nodes sorting and filtering for all loaded nodes.


updateSortingAndFiltering

public void updateSortingAndFiltering(E node)
Updates sorting and filtering for the specified node childs.


setModel

public void setModel(javax.swing.tree.TreeModel newModel)
Sets the TreeModel that will provide the data. This method also adds async tree model listener in the provided model.

Overrides:
setModel in class javax.swing.JTree
Parameters:
newModel - the TreeModel that is to provide the data

setCellEditor

public void setCellEditor(javax.swing.tree.TreeCellEditor cellEditor)
Sets the cell editor for this tree. This method also adds cell editor listener in the provided model.

Overrides:
setCellEditor in class WebTree<E extends AsyncUniqueNode>
Parameters:
cellEditor - cell editor

getAsyncModel

public AsyncTreeModel<E> getAsyncModel()
Returns asynchronous tree model.

Returns:
asynchronous tree model

isAsyncModel

public boolean isAsyncModel()
Returns whether asynchronous tree model is installed or not.

Returns:
true if asynchronous tree model is installed, false otherwise

setMaximumThreadsAmount

public void setMaximumThreadsAmount(int amount)
Sets maximum threads amount for this asynchronous tree. Separate threads are used for childs loading, data updates and other actions which should be performed asynchronously.

Parameters:
amount - new maximum threads amount

setChildNodes

public void setChildNodes(E parent,
                          java.util.List<E> children)
Sets child nodes for the specified node. This method might be used to manually change tree node childs without causing any structure corruptions. It will also cause node to change its state to loaded and it will not retrieve childs from data provider unless reload is called.

Parameters:
parent - node to process
children - new node children

addChildNode

public void addChildNode(E parent,
                         E child)
Adds child node for the specified node. This method might be used to manually change tree node childs without causing any structure corruptions. Be aware that added node will not be displayed if parent node is not yet loaded, this is a strict restriction for async tree.

Parameters:
parent - node to process
child - new node child

addChildNodes

public void addChildNodes(E parent,
                          java.util.List<E> children)
Adds child nodes for the specified node. This method might be used to manually change tree node childs without causing any structure corruptions. Be aware that added nodes will not be displayed if parent node is not yet loaded, this is a strict restriction for async tree.

Parameters:
parent - node to process
children - new node children

insertChildNodes

public void insertChildNodes(java.util.List<E> children,
                             E parent,
                             int index)
Inserts a list of child nodes into parent node. This method might be used to manually change tree node childs without causing any structure corruptions. Be aware that added nodes will not be displayed if parent node is not yet loaded, this is a strict restriction for async tree.

Parameters:
children - list of new child nodes
parent - parent node
index - insert index

insertChildNodes

public void insertChildNodes(E[] children,
                             E parent,
                             int index)
Inserts an array of child nodes into parent node. This method might be used to manually change tree node childs without causing any structure corruptions. Be aware that added nodes will not be displayed if parent node is not yet loaded, this is a strict restriction for async tree.

Parameters:
children - array of new child nodes
parent - parent node
index - insert index

removeNode

public boolean removeNode(java.lang.String nodeId)
Removes node with the specified ID from tree structure. This method will have effect only if node exists.

Parameters:
nodeId - ID of the node to remove
Returns:
true if tree structure was changed by the operation, false otherwise

removeNode

public boolean removeNode(E node)
Removes node from tree structure. This method will have effect only if node exists.

Parameters:
node - node to remove
Returns:
true if tree structure was changed by the operation, false otherwise

removeNodes

public void removeNodes(java.util.List<E> nodes)
Removes nodes from tree structure. This method will have effect only if nodes exist.

Parameters:
nodes - list of nodes to remove

removeNodes

public void removeNodes(E[] nodes)
Removes nodes from tree structure. This method will have effect only if nodes exist.

Parameters:
nodes - array of nodes to remove

areChildsLoaded

public boolean areChildsLoaded(E parent)
Returns whether childs for the specified node are already loaded or not.

Parameters:
parent - node to process
Returns:
true if childs for the specified node are already loaded, false otherwise

findNode

public 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.

Parameters:
nodeId - node ID
Returns:
node with the specified ID or null if it was not found

updateNode

public void updateNode(java.lang.String nodeId)
Forces tree node with the specified ID to be updated.

Parameters:
nodeId - ID of the tree node to be updated

updateNode

public void updateNode(E node)
Forces tree node to be updated.

Parameters:
node - tree node to be updated

updateNodeStructure

public void updateNodeStructure(java.lang.String nodeId)
Forces tree node structure with the specified ID to be updated.

Parameters:
nodeId - ID of the tree node to be updated

updateNodeStructure

public void updateNodeStructure(E node)
Forces tree node structure with the specified ID to be updated.

Parameters:
node - tree node to be updated

reloadSelectedNodesSync

public void reloadSelectedNodesSync()
Reloads selected node childs. Unlike asynchronous methods this one works in EDT and forces to wait until the nodes load finishes.


reloadSelectedNodes

public void reloadSelectedNodes()
Reloads selected node childs.


reloadNodeUnderPoint

public E reloadNodeUnderPoint(java.awt.Point point)
Reloads node under the specified point.

Parameters:
point - point to look for node
Returns:
reloaded node or null if none reloaded

reloadNodeUnderPoint

public E reloadNodeUnderPoint(int x,
                              int y)
Reloads node under the specified point.

Parameters:
x - point X coordinate
y - point Y coordinate
Returns:
reloaded node or null if none reloaded

reloadNodeSync

public E reloadNodeSync(java.lang.String nodeId)
Reloads node with the specified ID. Unlike asynchronous methods this one works in EDT and forces to wait until the nodes load finishes.

Parameters:
nodeId - ID of the node to reload
Returns:
reloaded node or null if none reloaded

reloadNodeSync

public E reloadNodeSync(E node)
Reloads specified node childs. Unlike asynchronous methods this one works in EDT and forces to wait until the nodes load finishes.

Parameters:
node - node to reload
Returns:
reloaded node or null if none reloaded

reloadNodeSync

public E reloadNodeSync(E node,
                        boolean select)
Reloads specified node childs and selects it if requested. Unlike asynchronous methods this one works in EDT and forces to wait until the nodes load finishes.

Parameters:
node - node to reload
select - whether select the node or not
Returns:
reloaded node or null if none reloaded

reloadRootNode

public E reloadRootNode()
Reloads root node childs.

Returns:
reloaded root node

reloadNode

public E reloadNode(java.lang.String nodeId)
Reloads node with the specified ID.

Parameters:
nodeId - ID of the node to reload
Returns:
reloaded node or null if none reloaded

reloadNode

public E reloadNode(E node)
Reloads specified node childs.

Parameters:
node - node to reload
Returns:
reloaded node or null if none reloaded

reloadNode

public E reloadNode(E node,
                    boolean select)
Reloads specified node childs and selects it if requested.

Parameters:
node - node to reload
select - whether select the node or not
Returns:
reloaded node or null if none reloaded

reloadPathSync

public E reloadPathSync(javax.swing.tree.TreePath path)
Reloads node childs at the specified path. Unlike asynchronous methods this one works in EDT and forces to wait until the nodes load finishes.

Parameters:
path - path of the node to reload
Returns:
reloaded node or null if none reloaded

reloadPathSync

public E reloadPathSync(javax.swing.tree.TreePath path,
                        boolean select)
Reloads node childs at the specified path and selects it if needed. Unlike asynchronous methods this one works in EDT and forces to wait until the nodes load finishes.

Parameters:
path - path of the node to reload
select - whether select the node or not
Returns:
reloaded node or null if none reloaded

reloadPath

public E reloadPath(javax.swing.tree.TreePath path)
Reloads node childs at the specified path.

Parameters:
path - path of the node to reload
Returns:
reloaded node or null if none reloaded

reloadPath

public E reloadPath(javax.swing.tree.TreePath path,
                    boolean select)
Reloads node childs at the specified path and selects it if needed.

Parameters:
path - path of the node to reload
select - whether select the node or not
Returns:
reloaded node or null if none reloaded

performReload

protected void performReload(E node,
                             javax.swing.tree.TreePath path,
                             boolean select)
Performs the actual reload call.

Parameters:
node - node to reload
path - path to node
select - whether select the node or not

getAsyncTreeListeners

public java.util.List<AsyncTreeListener> getAsyncTreeListeners()
Returns all available asynchronous tree listeners list.

Returns:
asynchronous tree listeners list

addAsyncTreeListener

public void addAsyncTreeListener(AsyncTreeListener listener)
Adds new asynchronous tree listener.

Parameters:
listener - asynchronous tree listener to add

removeAsyncTreeListener

public void removeAsyncTreeListener(AsyncTreeListener listener)
Removes asynchronous tree listener.

Parameters:
listener - asynchronous tree listener to remove

childsLoadStarted

public void childsLoadStarted(E parent)
Invoked when childs load operation starts.

Specified by:
childsLoadStarted in interface AsyncTreeModelListener<E extends AsyncUniqueNode>
Parameters:
parent - node which childs are being loaded

fireChildsLoadStarted

protected void fireChildsLoadStarted(E parent)
Fires childs load start event.

Parameters:
parent - node which childs are being loaded

childsLoadCompleted

public void childsLoadCompleted(E parent,
                                java.util.List<E> childs)
Invoked when childs load operation finishes.

Specified by:
childsLoadCompleted in interface AsyncTreeModelListener<E extends AsyncUniqueNode>
Parameters:
parent - node which childs were loaded
childs - loaded child nodes

fireChildsLoadCompleted

protected void fireChildsLoadCompleted(E parent,
                                       java.util.List<E> childs)
Fires childs load complete event.

Parameters:
parent - node which childs were loaded
childs - loaded child nodes

childsLoadFailed

public void childsLoadFailed(E parent,
                             java.lang.Throwable cause)
Invoked when childs load operation fails.

Specified by:
childsLoadFailed in interface AsyncTreeModelListener<E extends AsyncUniqueNode>
Parameters:
parent - node which childs were loaded
cause - childs load failure cause

fireChildsLoadFailed

protected void fireChildsLoadFailed(E parent,
                                    java.lang.Throwable cause)
Fires childs load complete event.

Parameters:
parent - node which childs were loaded
cause - childs load failure cause

expandNode

public void expandNode(java.lang.String nodeId)
Expands node with the specified ID.

Parameters:
nodeId - ID of the node to expand

expandPath

public void expandPath(java.util.List<java.lang.String> pathNodeIds)
Expands path using the specified node path IDs. IDs are used to find real nodes within the expanded roots. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
pathNodeIds - node path IDs

expandPath

public void expandPath(java.util.List<java.lang.String> pathNodeIds,
                       AsyncPathExpansionListener listener)
Expands path using the specified node path IDs. IDs are used to find real nodes within the expanded roots. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
pathNodeIds - node path IDs
listener - async path expansion listener

expandPath

public void expandPath(java.util.List<java.lang.String> pathNodeIds,
                       boolean expandLastNode)
Expands path using the specified node path IDs. IDs are used to find real nodes within the expanded roots. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
pathNodeIds - node path IDs
expandLastNode - whether should expand last found path node or not

expandPath

public void expandPath(java.util.List<java.lang.String> pathNodeIds,
                       boolean expandLastNode,
                       AsyncPathExpansionListener listener)
Expands path using the specified node path IDs. IDs are used to find real nodes within the expanded roots. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
pathNodeIds - node path IDs
expandLastNode - whether should expand last found path node or not
listener - async path expansion listener

expandPath

public void expandPath(java.util.List<java.lang.String> pathNodeIds,
                       boolean expandLastNode,
                       boolean selectLastNode)
Expands path using the specified node path IDs. IDs are used to find real nodes within the expanded roots. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
pathNodeIds - node path IDs
expandLastNode - whether should expand last found path node or not
selectLastNode - whether should select last found path node or not

expandPath

public void expandPath(java.util.List<java.lang.String> pathNodeIds,
                       boolean expandLastNode,
                       boolean selectLastNode,
                       AsyncPathExpansionListener listener)
Expands path using the specified node path IDs. IDs are used to find real nodes within the expanded roots. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
pathNodeIds - node path IDs
expandLastNode - whether should expand last found path node or not
selectLastNode - whether should select last found path node or not
listener - async path expansion listener

expandPathImpl

protected void expandPathImpl(E currentNode,
                              java.util.List<java.lang.String> leftToExpand,
                              boolean expandLastNode,
                              boolean selectLastNode,
                              AsyncPathExpansionListener listener)
Performs a single path node expansion. Be aware that operation might stop even before reaching the end of the path if something unexpected happened.

Parameters:
currentNode - last reached node
leftToExpand - node path IDs left for expansion
expandLastNode - whether should expand last found path node or not
selectLastNode - whether should select last found path node or not
listener - async path expansion listener

expandPathEndImpl

protected void expandPathEndImpl(E lastFoundNode,
                                 boolean expandLastNode,
                                 boolean selectLastNode)
Finishes async tree path expansion.

Parameters:
lastFoundNode - last found path node
expandLastNode - whether should expand last found path node or not
selectLastNode - whether should select last found path node or not

expandAll

public final void expandAll()
Expands all visible tree rows in a single call.

This method provides similar functionality to WebTree expandAll method and will actually expand all tree elements - even those which are not yet loaded from data provider. Make sure you know what you are doing before calling this method.

Overrides:
expandAll in class WebTree<E extends AsyncUniqueNode>

performFullPathExpand

protected void performFullPathExpand(javax.swing.tree.TreePath path)
Expands path right away (if node childs were loaded atleast once before or not) or asynchronously.

Parameters:
path - path to expand

performFullSyncPathExpand

protected void performFullSyncPathExpand(javax.swing.tree.TreePath path)
Expands path right away.

Parameters:
path - path to expand

performFullAsyncPathExpand

protected void performFullAsyncPathExpand(javax.swing.tree.TreePath path)
Expands path asynchronously.

Parameters:
path - path to expand