java.lang.Object
javax.swing.TransferHandler
is.codion.swing.common.ui.FileTransferHandler
- All Implemented Interfaces:
Serializable
Handles the importing of files during drag'n drop operations.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport
-
Field Summary
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addSingleFileDragAndDropSupport
(JTextComponent textComponent) Makes the text component accept files during drag and drop operations and insert the absolute path of the dropped file (the first file in a list if more than one file is dropped)boolean
canImport
(TransferHandler.TransferSupport transferSupport) static boolean
fileDataFlavor
(TransferHandler.TransferSupport transferSupport) boolean
importData
(TransferHandler.TransferSupport transferSupport) protected abstract boolean
importFiles
(Component component, List<File> files) Called after a successful importtransferFiles
(TransferHandler.TransferSupport transferSupport) Returns the files described by the given transfer support object.Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getSourceActions, getVisualRepresentation, importData, setDragImage, setDragImageOffset
-
Constructor Details
-
FileTransferHandler
public FileTransferHandler()
-
-
Method Details
-
canImport
- Overrides:
canImport
in classTransferHandler
-
importData
- Overrides:
importData
in classTransferHandler
-
addSingleFileDragAndDropSupport
Makes the text component accept files during drag and drop operations and insert the absolute path of the dropped file (the first file in a list if more than one file is dropped)- Parameters:
textComponent
- the text component
-
fileDataFlavor
- Parameters:
transferSupport
- a drag'n drop transfer support instance- Returns:
- true if the given transfer support instance represents a file or a list of files
-
transferFiles
Returns the files described by the given transfer support object. An empty list is returned if no files are found.- Parameters:
transferSupport
- the drag'n drop transfer support- Returns:
- the files described by the given transfer support object
- Throws:
RuntimeException
- in case of an exception
-
importFiles
Called after a successful import- Parameters:
component
- the componentfiles
- the imported files, non-null and containing at least one item- Returns:
- true if the files were inserted into the component, false otherwise
-