com.mucommander.ui.dnd
Class TransferableFileSet

java.lang.Object
  extended by com.mucommander.ui.dnd.TransferableFileSet
All Implemented Interfaces:
java.awt.datatransfer.Transferable

public class TransferableFileSet
extends java.lang.Object
implements java.awt.datatransfer.Transferable

This class represents a Transferable file set and is used for Drag and Drop transfers initiated by muCommander (dragged from a muCommander UI component).

The actual file set data can be fetched using one of those 3 DataFlavors :

Author:
Maxence Bernard, Xavi MirĂ³

Constructor Summary
TransferableFileSet(FileSet fileSet)
          Creates a new Transferable file set with support for all DataFlavors enabled.
 
Method Summary
static java.awt.datatransfer.DataFlavor getFileSetDataFlavor()
          Returns an instance of the custom FileSet DataFlavor used to transfer files locally.
 boolean getStringDataFlavourTransfersFilename()
          Returns whether the files' full path or just the filenames will be returned when getTransferData(java.awt.datatransfer.DataFlavor) is called with DataFlavor.stringFlavor.
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor dataFlavor)
           
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
           
static FileSet getTransferFiles(java.awt.datatransfer.Transferable transferable)
          Returns the files contained by the specified Transferable as a FileSet, or null if no file was present in the Transferable or if an error occurred.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor dataFlavor)
           
 void setFileSetDataFlavorSupported(boolean supported)
          Sets whether or not the FileSet DataFlavor (as returned by getFileSetDataFlavor() should be supported by this Transferable (supported by default).
 void setJavaFileListDataFlavorSupported(boolean supported)
          Sets whether or not the DataFlavor.javaFileListFlavor should be supported by this Transferable (supported by default).
 void setStringDataFlavorSupported(boolean supported)
          Sets whether or not the DataFlavor.stringFlavor should be supported by this Transferable (supported by default).
 void setStringDataFlavourTransfersFilename(boolean b)
          Sets whether the files' full path or just the filenames should be returned when getTransferData(java.awt.datatransfer.DataFlavor) is called with DataFlavor.stringFlavor.
 void setTextUriFlavorSupported(boolean supported)
          Sets whether or not the text/uri-list (RFC 2483) should be supported by this Transferable (supported by default).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransferableFileSet

public TransferableFileSet(FileSet fileSet)
Creates a new Transferable file set with support for all DataFlavors enabled.

Parameters:
fileSet - the files to be transferred
Method Detail

setFileSetDataFlavorSupported

public void setFileSetDataFlavorSupported(boolean supported)
Sets whether or not the FileSet DataFlavor (as returned by getFileSetDataFlavor() should be supported by this Transferable (supported by default).

Parameters:
supported - true to support the flavor

setJavaFileListDataFlavorSupported

public void setJavaFileListDataFlavorSupported(boolean supported)
Sets whether or not the DataFlavor.javaFileListFlavor should be supported by this Transferable (supported by default).

Parameters:
supported - true to support the flavor

setStringDataFlavorSupported

public void setStringDataFlavorSupported(boolean supported)
Sets whether or not the DataFlavor.stringFlavor should be supported by this Transferable (supported by default).

Parameters:
supported - true to support the flavor

setTextUriFlavorSupported

public void setTextUriFlavorSupported(boolean supported)
Sets whether or not the text/uri-list (RFC 2483) should be supported by this Transferable (supported by default).

Parameters:
supported - true to support the flavor

setStringDataFlavourTransfersFilename

public void setStringDataFlavourTransfersFilename(boolean b)
Sets whether the files' full path or just the filenames should be returned when getTransferData(java.awt.datatransfer.DataFlavor) is called with DataFlavor.stringFlavor. (*not* enabled by default)

Parameters:
b - if true, DataFlavor.stringFlavor returns filenames only, full file paths otherwise.

getStringDataFlavourTransfersFilename

public boolean getStringDataFlavourTransfersFilename()
Returns whether the files' full path or just the filenames will be returned when getTransferData(java.awt.datatransfer.DataFlavor) is called with DataFlavor.stringFlavor. Returns false unless setStringDataFlavourTransfersFilename(boolean) has been called.

Returns:
whether the files' full path or just the filenames will be returned when getTransferData(java.awt.datatransfer.DataFlavor) is called with DataFlavor.stringFlavor

getFileSetDataFlavor

public static java.awt.datatransfer.DataFlavor getFileSetDataFlavor()
Returns an instance of the custom FileSet DataFlavor used to transfer files locally.

Returns:
an instance of the custom FileSet DataFlavor used to transfer files locally

getTransferFiles

public static FileSet getTransferFiles(java.awt.datatransfer.Transferable transferable)
Returns the files contained by the specified Transferable as a FileSet, or null if no file was present in the Transferable or if an error occurred.

3 types of dropped data flavors are supported and used in this order of priority:

Parameters:
transferable - a Transferable instance that contains the files to be retrieved
Returns:
the files contained by the specified Transferable as a FileSet, or null if no file was present or if an error occurred

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor dataFlavor)
Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor dataFlavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard