public class ExtendedTransferHandler
extends javax.swing.TransferHandler
Modifier and Type | Class and Description |
---|---|
class |
ExtendedTransferHandler.SelectedTextTransferable
Transferable for text pane components that enables drag and drop of text.
|
Constructor and Description |
---|
ExtendedTransferHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
canImport(javax.swing.JComponent comp,
java.awt.datatransfer.DataFlavor[] flavor)
Indicates whether a component will accept an import of the given
set of data flavors prior to actually attempting to import it.
|
protected java.awt.datatransfer.Transferable |
createTransferable(javax.swing.JComponent component)
Creates a transferable for text pane components in order to enable drag
and drop of text.
|
void |
exportAsDrag(javax.swing.JComponent comp,
java.awt.event.InputEvent e,
int action)
Overrides TransferHandler.exportAsDrag method in order to call
our own SwingDragGestureRecognizer, which takes care of the
visual representation icon.
|
void |
exportToClipboard(javax.swing.JComponent comp,
java.awt.datatransfer.Clipboard clipboard,
int action)
Handles transport (cut and copy) from the chat panel to
clipboard.
|
java.lang.String |
getSelectedTextFromComponent(javax.swing.text.JTextComponent textComponent)
Gets the selected text and if the text is HTML replaces the images with
the content in ALT attribute.
|
int |
getSourceActions(javax.swing.JComponent c)
Returns the type of transfer actions supported by the source;
any bitwise-OR combination of COPY, MOVE
and LINK.
|
javax.swing.Icon |
getVisualRepresentation(java.awt.datatransfer.Transferable t)
Overrides TransferHandler.getVisualRepresentation(Transferable t)
in order to return a custom drag icon.
|
public int getSourceActions(javax.swing.JComponent c)
Some models are not mutable, so a transfer operation of MOVE should not be advertised in that case. Returning NONE disables transfers from the component.
getSourceActions
in class javax.swing.TransferHandler
c
- the component holding the data to be transferred;
provided to enable sharing of TransferHandler
sCOPY
if the transfer property can be found,
otherwise returns NONE
public boolean canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavor)
canImport
in class javax.swing.TransferHandler
comp
- componentflavor
- the data formats availablejava.lang.NullPointerException
- if support
is null
protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent component)
createTransferable
in class javax.swing.TransferHandler
component
- the component for which to create a
Transferablepublic void exportToClipboard(javax.swing.JComponent comp, java.awt.datatransfer.Clipboard clipboard, int action) throws java.lang.IllegalStateException
exportToClipboard
in class javax.swing.TransferHandler
comp
- the component holding the data to be transferred;
provided to enable sharing of TransferHandler
sclipboard
- the clipboard to transfer the data intoaction
- the transfer action requested; this should
be a value of either COPY
or MOVE
;
the operation performed is the intersection of the transfer
capabilities given by getSourceActions and the requested action;
the intersection may result in an action of NONE
if the requested action isn't supportedjava.lang.IllegalStateException
- if the clipboard is currently unavailableClipboard.setContents(Transferable, ClipboardOwner)
public java.lang.String getSelectedTextFromComponent(javax.swing.text.JTextComponent textComponent)
textComponent
- the component which contains the selected datapublic javax.swing.Icon getVisualRepresentation(java.awt.datatransfer.Transferable t)
The default parent implementation of this method returns null.
getVisualRepresentation
in class javax.swing.TransferHandler
t
- the data to be transferred; this value is expected to have been
created by the createTransferable
methodpublic void exportAsDrag(javax.swing.JComponent comp, java.awt.event.InputEvent e, int action)
exportAsDrag
in class javax.swing.TransferHandler
comp
- the component holding the data to be transferred; this
argument is provided to enable sharing of TransferHandler
s
by multiple componentse
- the event that triggered the transferaction
- the transfer action initially requested; this should
be a value of either COPY
or MOVE
;
the value may be changed during the course of the drag operation
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.