com.alee.extended.tree
Class AsyncTreeTransferHandler<N extends AsyncUniqueNode,T extends WebAsyncTree<N>>
java.lang.Object
javax.swing.TransferHandler
com.alee.extended.tree.AbstractTreeTransferHandler<N,T,AsyncTreeModel<N>>
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 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 javax.swing.TransferHandler |
COPY, COPY_OR_MOVE, LINK, MOVE, NONE |
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 |
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.
AsyncTreeTransferHandler
public AsyncTreeTransferHandler()
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 fromnodesToRemove
- 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 datanodes
- list of nodes to dropdropIndex
- preliminary nodes drop indexparent
- parent node to drop nodes intotree
- tree to drop nodes ontomodel
- 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 dropparent
- parent node to drop nodes intotree
- tree to drop nodes ontomodel
- tree modelindex
- nodes drop index
- Returns:
- true if drop operation was successfully completed, false otherwise