org.peace_tools.generic.dndTabs
Class DnDTabHandler.TransferableTab

java.lang.Object
  extended by org.peace_tools.generic.dndTabs.DnDTabHandler.TransferableTab
All Implemented Interfaces:
java.awt.datatransfer.Transferable
Enclosing class:
DnDTabHandler

public class DnDTabHandler.TransferableTab
extends java.lang.Object
implements java.awt.datatransfer.Transferable

This inner class provides a wrapper that impelements Transferable interface to simply provide a place holder for DnD operations. The actual component to be moved is stored as a static member in the TabDnDHandler class. Refer to the documentation on the Transferable interface for details on the API requirements for each one of the methods in this class.


Field Summary
private  java.awt.datatransfer.DataFlavor[] flavors
          An array of flavours that is supported by this Transferable node.
 
Constructor Summary
DnDTabHandler.TransferableTab()
          The only constructor for creating a transferable tab.
 
Method Summary
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          This method is a part of the Transferable interface.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          This method is a part of the Transferable interface.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          This method is a part of the Transferable interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flavors

private transient java.awt.datatransfer.DataFlavor[] flavors
An array of flavours that is supported by this Transferable node. Currently this node supports only one data flavor for DnD operations, which is just a Component object that indicates the component to be moved.

Constructor Detail

DnDTabHandler.TransferableTab

public DnDTabHandler.TransferableTab()
The only constructor for creating a transferable tab. Currently this class does not require any other information as this is just a empty place holder.

Method Detail

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
This method is a part of the Transferable interface. As per API reqirements this method returns the set of data flavours supported by this Transferable object. Currently this object supports only 1 data flavor.

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable
Returns:
The array of data flavors supported by this object.

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
This method is a part of the Transferable interface. As per API reqirements this method checks to see if the specified DataFlavor has the same class as a Component. If so, this method return's true. Otherwise it return's false.

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable
Parameters:
flavor - The DataFlavor to be checked for compatibility.
Returns:
This method returns true if flavor.getRepresentationClass() is the same as Component.class.

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException
This method is a part of the Transferable interface. As per API reqirements this method first checks to ensure that the DataFlavor is supported (via isDataFlavorSupported() method) and if so, it returns the static componentMoved member of the TabDnDHandler. If the flavor is not supported, it throws an UnsupportedFlavorException.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Parameters:
flavor - The DataFlavor corresponding to which an object must be obtained from this Transferable class and returned to the caller. Currently, only TAB_FLAVOR is supported.
Returns:
The Component object contained in the TabDnDHandler class.
Throws:
java.awt.datatransfer.UnsupportedFlavorException - This method throws an exception if the DataFlavor is not compatible (that flavor.getRepresentationClass() is not the same as TreePath.class).