org.xnap.commons.gui.dnd
Class AbstractFileTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by org.xnap.commons.gui.dnd.AbstractFileTransferHandler
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DefaultTextFieldFileTransferHandler, DefaultTreeFileTransferHandler

public abstract class AbstractFileTransferHandler
extends TransferHandler

Abstract handler class easing drag and drop support of file objects.

Also handles Linux Desktop file drag and drops which don't seem to translate to the DataFlavor.javaFileListFlavor.

Subclasses should override createTransferable(JComponent) and importFiles(JComponent, List).

Author:
Felix Berger
See Also:
Serialized Form

Field Summary
static DataFlavor linuxURIFlavor
          URI flavor used for file drag and drops on the Linux desktop.
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
 
Constructor Summary
AbstractFileTransferHandler()
           
 
Method Summary
 boolean canImport(JComponent comp, DataFlavor[] transferFlavors)
          Returns true if one of the supported flavors is either DataFlavor.javaFileListFlavor or linuxURIFlavor.
protected  Transferable createTransferable(JComponent c)
          Returns null.
 int getSourceActions(JComponent c)
          Returns TransferHandler.COPY.
 boolean importData(JComponent comp, Transferable t)
          Overriden to extract the file lists from the different types of transferables.
 boolean importFiles(JComponent comp, List<File> files)
          Returns false, thus disallowing dropping of files on the component comp.
 
Methods inherited from class javax.swing.TransferHandler
exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

linuxURIFlavor

public static DataFlavor linuxURIFlavor
URI flavor used for file drag and drops on the Linux desktop.

Constructor Detail

AbstractFileTransferHandler

public AbstractFileTransferHandler()
Method Detail

canImport

public boolean canImport(JComponent comp,
                         DataFlavor[] transferFlavors)
Returns true if one of the supported flavors is either DataFlavor.javaFileListFlavor or linuxURIFlavor.

Overrides:
canImport in class TransferHandler

getSourceActions

public int getSourceActions(JComponent c)
Returns TransferHandler.COPY.

Overrides:
getSourceActions in class TransferHandler

createTransferable

protected Transferable createTransferable(JComponent c)
Returns null.

Subclasses can return a FileTransferable.

Overrides:
createTransferable in class TransferHandler

importFiles

public boolean importFiles(JComponent comp,
                           List<File> files)
Returns false, thus disallowing dropping of files on the component comp.

Subclasses should import the list of files and return true on success.


importData

public boolean importData(JComponent comp,
                          Transferable t)
Overriden to extract the file lists from the different types of transferables.

Overrides:
importData in class TransferHandler


Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.