net.xoetrope.swing.docking
Class XDockableTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by net.xoetrope.swing.docking.XDockableTransferHandler
All Implemented Interfaces:
java.io.Serializable

public class XDockableTransferHandler
extends javax.swing.TransferHandler

A transfer handler for a dockable component. The object handles the application/x-xui-xdockable drop flavor. It is only intended that the drag and drop operation occurs within a single application. This transferrable object maintains a static reference to the dockable object and therefore it is not suitable for use in other contexts or between JVM instances.

Copyright: Xoetrope Ltd. (c) 2003-2006
License: see license.txt

$Revision: 1.2 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.TransferHandler
javax.swing.TransferHandler.DropLocation, javax.swing.TransferHandler.TransferSupport
 
Field Summary
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
 
Constructor Summary
XDockableTransferHandler(java.lang.Object target)
          Creates a new instance of XDockableTransferHandler
 
Method Summary
 boolean canImport(javax.swing.JComponent c, java.awt.datatransfer.DataFlavor[] flavors)
          Indicates whether a component would accept an import of the given set of data flavors prior to actually attempting to import it.
protected  java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
          Creates a Transferable to use as the source for a data transfer.
protected  void exportDone(javax.swing.JComponent c, java.awt.datatransfer.Transferable data, int action)
          Invoked after data has been exported.
 int getSourceActions(javax.swing.JComponent c)
          Returns the type of transfer actions supported by the source.
 boolean importData(javax.swing.JComponent c, java.awt.datatransfer.Transferable t)
          Causes a transfer to a component from a clipboard or a DND drop operation.
 
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
 

Constructor Detail

XDockableTransferHandler

public XDockableTransferHandler(java.lang.Object target)
Creates a new instance of XDockableTransferHandler

Method Detail

importData

public boolean importData(javax.swing.JComponent c,
                          java.awt.datatransfer.Transferable t)
Causes a transfer to a component from a clipboard or a DND drop operation. The Transferable represents the data to be imported into the component.

Overrides:
importData in class javax.swing.TransferHandler
Parameters:
comp - the component to receive the transfer; this argument is provided to enable sharing of TransferHandlers by multiple components
t - the data to import
Returns:
true if the data was inserted into the component, false otherwise

createTransferable

protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent c)
Creates a Transferable to use as the source for a data transfer. Returns the representation of the data to be transferred, or null if the component's property is null

Overrides:
createTransferable in class javax.swing.TransferHandler
Parameters:
c - the component holding the data to be transferred; this argument is provided to enable sharing of TransferHandlers by multiple components
Returns:
the representation of the data to be transferred, or null if the property associated with c is null

getSourceActions

public int getSourceActions(javax.swing.JComponent c)
Returns the type of transfer actions supported by the source. Some models are not mutable, so a transfer operation of COPY only should be advertised in that case. In this case only the MOVE operation is supported.

Overrides:
getSourceActions in class javax.swing.TransferHandler
Parameters:
c - the component holding the data to be transferred; this argument is provided to enable sharing of TransferHandlers by multiple components.
Returns:
COPY if the transfer property can be found, otherwise returns NONE; a return value of of NONE disables any transfers out of the component

exportDone

protected void exportDone(javax.swing.JComponent c,
                          java.awt.datatransfer.Transferable data,
                          int action)
Invoked after data has been exported. This method should remove the data that was transferred if the action was MOVE.

This method is implemented to do nothing since MOVE is not a supported action of this implementation (getSourceActions does not include MOVE).

Overrides:
exportDone in class javax.swing.TransferHandler
Parameters:
source - the component that was the source of the data
data - The data that was transferred or possibly null if the action is NONE.
action - the actual action that was performed

canImport

public boolean canImport(javax.swing.JComponent c,
                         java.awt.datatransfer.DataFlavor[] flavors)
Indicates whether a component would accept an import of the given set of data flavors prior to actually attempting to import it.

Overrides:
canImport in class javax.swing.TransferHandler
Parameters:
comp - the component to receive the transfer; this argument is provided to enable sharing of TransferHandlers by multiple components
transferFlavors - the data formats available
Returns:
true if the data can be inserted into the component, false otherwise