corpus-services
1.0
|
Classes | |
interface | Fetcher |
Public Member Functions | |
TransferableObject (Object data) | |
TransferableObject (Fetcher fetcher) | |
TransferableObject (Class dataClass, Fetcher fetcher) | |
java.awt.datatransfer.DataFlavor | getCustomDataFlavor () |
java.awt.datatransfer.DataFlavor[] | getTransferDataFlavors () |
Object | getTransferData (java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException |
boolean | isDataFlavorSupported (java.awt.datatransfer.DataFlavor flavor) |
Static Public Attributes | |
static final String | MIME_TYPE = "application/x-net.iharder.dnd.TransferableObject" |
static final java.awt.datatransfer.DataFlavor | DATA_FLAVOR |
At last an easy way to encapsulate your custom objects for dragging and dropping in your Java programs! When you need to create a java.awt.datatransfer.Transferable object, use this class to wrap your object. For example:
...
MyCoolClass myObj = new MyCoolClass();
Transferable xfer = new TransferableObject( myObj );
...
Or if you need to know when the data was actually dropped, like when you're moving data out of a list, say, you can use the TransferableObject.Fetcher inner class to return your object Just in Time. For example:
...
final MyCoolClass myObj = new MyCoolClass();
TransferableObject.Fetcher fetcher = new TransferableObject.Fetcher()
{ public Object getObject(){ return myObj; }
}; // end fetcher
Transferable xfer = new TransferableObject( fetcher );
...
The java.awt.datatransfer.DataFlavor associated with TransferableObject has the representation class net.iharder.dnd.TransferableObject.class
and MIME type application/x-net.iharder.dnd.TransferableObject
. This data flavor is accessible via the static DATA_FLAVOR property.
I'm releasing this code into the Public Domain. Enjoy.
Definition at line 728 of file FileDrop.java.
de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.TransferableObject | ( | Object | data | ) |
Creates a new TransferableObject that wraps data. Along with the DATA_FLAVOR associated with this class, this creates a custom data flavor with a representation class determined from data.getClass()
and the MIME type application/x-net.iharder.dnd.TransferableObject
.
data | The data to transfer |
Definition at line 769 of file FileDrop.java.
de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.TransferableObject | ( | Fetcher | fetcher | ) |
Creates a new TransferableObject that will return the object that is returned by fetcher. No custom data flavor is set other than the default DATA_FLAVOR.
fetcher | The Fetcher that will return the data object |
Definition at line 786 of file FileDrop.java.
de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.TransferableObject | ( | Class | dataClass, |
Fetcher | fetcher | ||
) |
Creates a new TransferableObject that will return the object that is returned by fetcher. Along with the DATA_FLAVOR associated with this class, this creates a custom data flavor with a representation class dataClass and the MIME type application/x-net.iharder.dnd.TransferableObject
.
dataClass | The java.lang.Class to use in the custom data flavor |
fetcher | The Fetcher that will return the data object |
Definition at line 805 of file FileDrop.java.
java.awt.datatransfer.DataFlavor de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.getCustomDataFlavor | ( | ) |
Returns the custom java.awt.datatransfer.DataFlavor associated with the encapsulated object or null
if the Fetcher constructor was used without passing a java.lang.Class.
Definition at line 818 of file FileDrop.java.
Object de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.getTransferData | ( | java.awt.datatransfer.DataFlavor | flavor | ) | throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException |
Returns the data encapsulated in this TransferableObject. If the Fetcher constructor was used, then this is when the getObject() method will be called. If the requested data flavor is not supported, then the getObject() method will not be called.
flavor | The data flavor for the data to return |
Definition at line 864 of file FileDrop.java.
java.awt.datatransfer.DataFlavor [] de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.getTransferDataFlavors | ( | ) |
Returns a two- or three-element array containing first the custom data flavor, if one was created in the constructors, second the default DATA_FLAVOR associated with TransferableObject, and third the java.awt.datatransfer.DataFlavor.stringFlavor.
Definition at line 836 of file FileDrop.java.
boolean de.uni_hamburg.corpora.swing.FileDrop.TransferableObject.isDataFlavorSupported | ( | java.awt.datatransfer.DataFlavor | flavor | ) |
Returns true
if flavor is one of the supported flavors. Flavors are supported using the equals(...)
method.
flavor | The data flavor to check |
Definition at line 890 of file FileDrop.java.
|
static |
The default java.awt.datatransfer.DataFlavor for TransferableObject has the representation class net.iharder.dnd.TransferableObject.class
and the MIME type application/x-net.iharder.dnd.TransferableObject
.
Definition at line 748 of file FileDrop.java.
|
static |
The MIME type for DATA_FLAVOR is application/x-net.iharder.dnd.TransferableObject
.
Definition at line 736 of file FileDrop.java.