Class DataNodeTransferHandler
java.lang.Object
javax.swing.TransferHandler
uk.ac.starlink.datanode.tree.DataNodeTransferHandler
- All Implemented Interfaces:
Serializable
Handles transferable exports to and from from the DataNodeJTree.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class TransferHandler
TransferHandler.DropLocation, TransferHandler.TransferSupport -
Field Summary
Fields inherited from class TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanImport(JComponent comp, DataFlavor[] flavors) If we are configured to import data, return true, on the grounds that the DataNodeFactory should be able to have a go at turning almost anything into a DataNode.protected TransferablecreateTransferable(JComponent comp) intgetSourceActions(JComponent comp) booleanimportData(JComponent comp, Transferable trans) Attempts to import a transferable into the tree.voidPastes the system selection into the tree window.voidsetNodeMaker(DataNodeFactory nodeMaker) Sets the DataNodeFactory which will be used by this handler to perform import of Transferables (convert them into DataNodes).Methods inherited from class TransferHandler
canImport, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, importData, setDragImage, setDragImageOffset
-
Constructor Details
-
DataNodeTransferHandler
public DataNodeTransferHandler()
-
-
Method Details
-
getSourceActions
- Overrides:
getSourceActionsin classTransferHandler
-
getVisualRepresentation
- Overrides:
getVisualRepresentationin classTransferHandler
-
createTransferable
- Overrides:
createTransferablein classTransferHandler
-
setNodeMaker
Sets the DataNodeFactory which will be used by this handler to perform import of Transferables (convert them into DataNodes). By default this is set tonull; unless it is set to a non-null value, no node import will be permitted. -
canImport
If we are configured to import data, return true, on the grounds that the DataNodeFactory should be able to have a go at turning almost anything into a DataNode. However, only do it if the drop position would not be over a node in the tree, since that might convey a false impression of what's going to happen (the node will get appended to the root).- Overrides:
canImportin classTransferHandler
-
importData
Attempts to import a transferable into the tree.- Overrides:
importDatain classTransferHandler
-
pasteSystemSelection
Pastes the system selection into the tree window. This behaviour is seen in JTextComponent and subclasses (see javax.swing.text.DefaultCaret for the implementation), but not elsewhere in the JFC; however I think it's quite useful, it means you can grab a text string and middle-click it on top of a window to load that URL (or whatever) in.This implementation only works with string-like contents of the selection. Short strings it feeds to the data node factory as Strings, and long ones it ignores.
- Parameters:
comp- the component into which to paste
-