com.alee.extended.tree
Class AsyncTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>>

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by com.alee.extended.tree.AbstractTreeTransferHandler<N,T,AsyncTreeModel<N>>
          extended by com.alee.extended.tree.AsyncTreeTransferHandler<N,T>
All Implemented Interfaces:
java.io.Serializable

public abstract class AsyncTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>>
extends AbstractTreeTransferHandler<N,T,AsyncTreeModel<N>>

Custom TransferHandler for WebAsyncTree that provides a quick and convenient way to implement nodes DnD.

Author:
Mikle Garin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.alee.extended.tree.AbstractTreeTransferHandler
AbstractTreeTransferHandler.NodesTransferable
 
Nested classes/interfaces inherited from class javax.swing.TransferHandler
javax.swing.TransferHandler.DropLocation, javax.swing.TransferHandler.TransferSupport
 
Field Summary
protected  boolean allowUncheckedDrop
          Whether should allow dropping nodes onto not-yet-loaded node or not.
 
Fields inherited from class com.alee.extended.tree.AbstractTreeTransferHandler
draggedNodeIndices, draggedNodes, expandMultiplyNodes, expandSingleNode, flavors, nodesFlavor, optimizeDraggedNodes
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
 
Constructor Summary
AsyncTreeTransferHandler()
           
 
Method Summary
protected  boolean canDropTo(N dropLocation)
          Checks whether specified target is acceptable for drop or not.
 boolean isAllowUncheckedDrop()
          Returns whether should allow dropping nodes onto not-yet-loaded node or not.
protected  boolean performDropOperation(java.util.List<N> nodes, N parent, T tree, AsyncTreeModel<N> model, int index)
          Performs actual nodes drop operation.
protected  boolean prepareDropOperation(javax.swing.TransferHandler.TransferSupport support, java.util.List<N> nodes, int dropIndex, N parent, T tree, AsyncTreeModel<N> model)
          Performs all preparations required to perform drop operation and calls for actual drop when ready.
protected  void removeTreeNodes(T tree, java.util.List<N> nodesToRemove)
          Asks tree to remove nodes after drag move operation has completed.
 void setAllowUncheckedDrop(boolean allowUncheckedDrop)
          Sets whether should allow dropping nodes onto not-yet-loaded node or not
 
Methods inherited from class com.alee.extended.tree.AbstractTreeTransferHandler
canBeDragged, canBeDropped, canImport, collect, copy, createNodesFlavor, createTransferable, exportDone, getAdjustedDropIndex, getSourceActions, importData, isExpandMultiplyNodes, isExpandSingleNode, isMoveAction, isOptimizeDraggedNodes, nodesDropped, setExpandMultiplyNodes, setExpandSingleNode, setOptimizeDraggedNodes, toString
 
Methods inherited from class javax.swing.TransferHandler
canImport, exportAsDrag, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allowUncheckedDrop

protected boolean allowUncheckedDrop
Whether should allow dropping nodes onto not-yet-loaded node or not. Be aware that if this set to true and your tree might fail loading childs - old nodes will still get removed on drop. If set to false tree will try to load child nodes first and then perform the drop operation.

Constructor Detail

AsyncTreeTransferHandler

public AsyncTreeTransferHandler()
Method Detail

isAllowUncheckedDrop

public boolean isAllowUncheckedDrop()
Returns whether should allow dropping nodes onto not-yet-loaded node or not.

Returns:
true if should allow dropping nodes onto not-yet-loaded node, false otherwise

setAllowUncheckedDrop

public void setAllowUncheckedDrop(boolean allowUncheckedDrop)
Sets whether should allow dropping nodes onto not-yet-loaded node or not

Parameters:
allowUncheckedDrop - whether should allow dropping nodes onto not-yet-loaded node or not

canDropTo

protected boolean canDropTo(N dropLocation)
Checks whether specified target is acceptable for drop or not. This check is performed before another check for nodes drop possibility.

Overrides:
canDropTo in class AbstractTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>,AsyncTreeModel<N extends AsyncUniqueNode>>
Parameters:
dropLocation - node onto which drop was performed
Returns:
true if the specified target is acceptable for drop, false otherwise

removeTreeNodes

protected void removeTreeNodes(T tree,
                               java.util.List<N> nodesToRemove)
Asks tree to remove nodes after drag move operation has completed.

Specified by:
removeTreeNodes in class AbstractTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>,AsyncTreeModel<N extends AsyncUniqueNode>>
Parameters:
tree - tree to remove nodes from
nodesToRemove - nodes that should be removed

prepareDropOperation

protected boolean prepareDropOperation(javax.swing.TransferHandler.TransferSupport support,
                                       java.util.List<N> nodes,
                                       int dropIndex,
                                       N parent,
                                       T tree,
                                       AsyncTreeModel<N> model)
Performs all preparations required to perform drop operation and calls for actual drop when ready.

Specified by:
prepareDropOperation in class AbstractTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>,AsyncTreeModel<N extends AsyncUniqueNode>>
Parameters:
support - transfer support data
nodes - list of nodes to drop
dropIndex - preliminary nodes drop index
parent - parent node to drop nodes into
tree - tree to drop nodes onto
model - tree model
Returns:
true if drop operation was successfully completed, false otherwise

performDropOperation

protected boolean performDropOperation(java.util.List<N> nodes,
                                       N parent,
                                       T tree,
                                       AsyncTreeModel<N> model,
                                       int index)
Performs actual nodes drop operation.

Specified by:
performDropOperation in class AbstractTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>,AsyncTreeModel<N extends AsyncUniqueNode>>
Parameters:
nodes - list of nodes to drop
parent - parent node to drop nodes into
tree - tree to drop nodes onto
model - tree model
index - nodes drop index
Returns:
true if drop operation was successfully completed, false otherwise