treebolic.generator.tree
Class TreeTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by treebolic.generator.tree.TreeTransferHandler
All Implemented Interfaces:
java.io.Serializable

public class TreeTransferHandler
extends javax.swing.TransferHandler

Transfer handler for drag and drop operations

Author:
Bernard Bou
See Also:
Serialized Form

Nested Class Summary
(package private)  class TreeTransferHandler.TransferableNode
          Transferable data
 
Nested classes/interfaces inherited from class javax.swing.TransferHandler
javax.swing.TransferHandler.DropLocation, javax.swing.TransferHandler.TransferSupport
 
Field Summary
private static long serialVersionUID
           
private static java.awt.datatransfer.DataFlavor theFlavor
          Data flavour
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
 
Constructor Summary
TreeTransferHandler()
           
 
Method Summary
 boolean canImport(javax.swing.TransferHandler.TransferSupport thisSupport)
           
protected  java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent thisSourceComponent)
           
protected  void exportDone(javax.swing.JComponent thisComponent, java.awt.datatransfer.Transferable data, int action)
           
private  Pair<javax.swing.tree.TreePath,javax.swing.tree.TreePath> getNodes(javax.swing.TransferHandler.TransferSupport thisSupport)
          Get pair of source tree and destination treepaths
 int getSourceActions(javax.swing.JComponent c)
           
 boolean importData(javax.swing.TransferHandler.TransferSupport thisSupport)
           
private  boolean move(Tree thisTree, javax.swing.tree.TreePath thisSource, javax.swing.tree.TreePath thisDestination)
          Move source node as child of destination node
private  boolean testMove(javax.swing.tree.TreePath thisSource, javax.swing.tree.TreePath thisDestination)
          Whether source node can drag and drop to destination node
 
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, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

theFlavor

private static java.awt.datatransfer.DataFlavor theFlavor
Data flavour

Constructor Detail

TreeTransferHandler

public TreeTransferHandler()
Method Detail

getSourceActions

public int getSourceActions(javax.swing.JComponent c)
Overrides:
getSourceActions in class javax.swing.TransferHandler

createTransferable

protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent thisSourceComponent)
Overrides:
createTransferable in class javax.swing.TransferHandler

canImport

public boolean canImport(javax.swing.TransferHandler.TransferSupport thisSupport)
Overrides:
canImport in class javax.swing.TransferHandler

importData

public boolean importData(javax.swing.TransferHandler.TransferSupport thisSupport)
Overrides:
importData in class javax.swing.TransferHandler

exportDone

protected void exportDone(javax.swing.JComponent thisComponent,
                          java.awt.datatransfer.Transferable data,
                          int action)
Overrides:
exportDone in class javax.swing.TransferHandler

getNodes

private Pair<javax.swing.tree.TreePath,javax.swing.tree.TreePath> getNodes(javax.swing.TransferHandler.TransferSupport thisSupport)
Get pair of source tree and destination treepaths

Parameters:
thisSupport - transfer support
Returns:
source tree and destination treepaths

testMove

private boolean testMove(javax.swing.tree.TreePath thisSource,
                         javax.swing.tree.TreePath thisDestination)
Whether source node can drag and drop to destination node

Parameters:
thisSource - source node
thisDestination - destination node
Returns:
true if source node can drag and drop to destination node

move

private boolean move(Tree thisTree,
                     javax.swing.tree.TreePath thisSource,
                     javax.swing.tree.TreePath thisDestination)
Move source node as child of destination node

Parameters:
thisSource - source node
thisDestination - destination node
Returns:
true if successful