org.fife.ui.rtextarea
public class RTATextTransferHandler extends TransferHandler
RTextArea
via
drag-and-drop. This class is pretty much ripped off from a subclass of
BasicTextUI
. In the future, it will include the ability to
drag-and-drop files into RTextArea
s (i.e., the text will be
inserted into the text area).The main reason this class is kept around is so we can subclass it.
TransferHandler.DropLocation, TransferHandler.TransferSupport
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
Constructor and Description |
---|
RTATextTransferHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
canImport(JComponent comp,
DataFlavor[] flavors)
This method indicates if a component would accept an import of the
given set of data flavors prior to actually attempting to import it.
|
protected Transferable |
createTransferable(JComponent comp)
Create a Transferable to use as the source for a data transfer.
|
protected void |
exportDone(JComponent source,
Transferable data,
int action)
This method is called after data has been exported.
|
protected DataFlavor |
getImportFlavor(DataFlavor[] flavors,
JTextComponent c)
Try to find a flavor that can be used to import a Transferable to a
specified text component.
|
int |
getSourceActions(JComponent c)
This is the type of transfer actions supported by the source.
|
protected void |
handleReaderImport(Reader in,
JTextComponent c)
Import the given stream data into the text component.
|
boolean |
importData(JComponent comp,
Transferable t)
This method causes a transfer to a component from a clipboard or a
DND drop operation.
|
canImport, exportAsDrag, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation, importData
protected DataFlavor getImportFlavor(DataFlavor[] flavors, JTextComponent c)
flavors
- The flavors to check if c will accept them.c
- The text component to see whether it will accept any of the
specified data flavors as input.protected void handleReaderImport(Reader in, JTextComponent c) throws BadLocationException, IOException
BadLocationException
IOException
public int getSourceActions(JComponent c)
getSourceActions
in class TransferHandler
c
- The component holding the data to be transfered. This
argument is provided to enable sharing of TransferHandlers by
multiple components.protected Transferable createTransferable(JComponent comp)
createTransferable
in class TransferHandler
comp
- The component holding the data to be transfered. This
argument is provided to enable sharing of TransferHandlers by
multiple components.protected void exportDone(JComponent source, Transferable data, int action)
exportDone
in class TransferHandler
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.public boolean importData(JComponent comp, Transferable t)
importData
in class TransferHandler
comp
- The component to receive the transfer. This
argument is provided to enable sharing of TransferHandlers by
multiple components.t
- The data to importtrue
iff the data was inserted into the component.public boolean canImport(JComponent comp, DataFlavor[] flavors)
canImport
in class TransferHandler
comp
- The component to receive the transfer. This argument is
provided to enable sharing of TransferHandlers by multiple
components.flavors
- The data formats available.true
iff the data can be inserted.