VdexReload 1.1.3 API

uk.ac.reload.dweezil.gui.tree
Class DragTreeObject

java.lang.Object
  extended byuk.ac.reload.dweezil.gui.tree.DragTreeObject
All Implemented Interfaces:
DweezilConstants, java.awt.datatransfer.Transferable

public class DragTreeObject
extends java.lang.Object
implements java.awt.datatransfer.Transferable, DweezilConstants

A Drag Object that is a wrapper for an object dragged from DragTree to DragTree Ideally, you would sub-class this to make your own type.

Amendment History: Drag n Drop errors on MacOS X.

It is safer if a drag object inside a DataFlavor reflects the actual object type inside the tree node. As each DragTreeObject is created, the DataFlavor is updated to represent this particular object type. A default data flavor of "DataFlavor.javaJVMLocalObjectMimeType" seems to default to an instance of java.io.InputStream as opposed to an instance of the user object contained with a tree node.

If an instance of the DataFlavor does not reflect the corresponding Transferable instance, then a ClassCastException can occur. MacOS X seems to be more fussy about this format then Windows. For more info see

http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html, section - Specifying the Data Format

and also

http://forum.java.sun.com/thread.jsp?thread=184916&forum=5&message=654598


Field Summary
protected  java.lang.Object _object
          The Object that we are transferring
protected  ReloadDragTree _owner
          The Reload Drag Tree that is the owner of the dragged object
static java.awt.datatransfer.DataFlavor flavor
          The Data Flavor that we support - static because this is a kludge
 
Fields inherited from interface uk.ac.reload.dweezil.DweezilConstants
CR, DEBUG
 
Constructor Summary
DragTreeObject(java.lang.Object object, ReloadDragTree owner)
          Constructor
 
Method Summary
 java.awt.datatransfer.DataFlavor getFlavor()
          Method to dynamically figure out what type of object should be contained within the Flavor.
 ReloadDragTree getOwner()
          Get the owner
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor fl)
          Get transfer data
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Get transfer data flavors
 java.lang.Object getUserObject()
          Method to return the user object contained within the Flavor container
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor fl)
          Determine if a given Data Flavor is Supported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_object

protected java.lang.Object _object
The Object that we are transferring


_owner

protected ReloadDragTree _owner
The Reload Drag Tree that is the owner of the dragged object


flavor

public static java.awt.datatransfer.DataFlavor flavor
The Data Flavor that we support - static because this is a kludge

Constructor Detail

DragTreeObject

public DragTreeObject(java.lang.Object object,
                      ReloadDragTree owner)
Constructor

Parameters:
object - an user object contained within the Flavor container
owner - the ReloadDragTree
Method Detail

getFlavor

public java.awt.datatransfer.DataFlavor getFlavor()
Method to dynamically figure out what type of object should be contained within the Flavor.

Returns:
a DataFlavor or null

getUserObject

public java.lang.Object getUserObject()
Method to return the user object contained within the Flavor container

Returns:
a user object (should correspond to the class type within a tree node).

getOwner

public ReloadDragTree getOwner()
Get the owner

Returns:
the ReloadDragTree

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor fl)
Get transfer data

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Parameters:
fl - the Data Flavor
Returns:
a user object

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor fl)
Determine if a given Data Flavor is Supported

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable
Parameters:
fl - the given Data Flavor
Returns:
true if the given Data Flavor is supported, false otherwise

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Get transfer data flavors

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable
Returns:
an array of Data Flavors

VdexReload 1.1.3 API