org.jdesktop.wonderland.client.jme.dnd
Class DragAndDropManager

java.lang.Object
  extended by org.jdesktop.wonderland.client.jme.dnd.DragAndDropManager

public class DragAndDropManager
extends java.lang.Object

Manages the drag-and-drop for the world. There is a single drop source for the world, which is typically the main rendering panel. Other parts of the system (e.g. modules) can register (via annotations) to handle various data flavors of drag sources (e.g. if you are dragging from the Desktop versus dragging a cell from the Cell Palette.

Author:
Jordan Slott

Method Summary
 DataFlavorHandlerSPI getDataFlavorHandler(java.awt.datatransfer.DataFlavor dataFlavor)
          Returns the data flavor handler for the given data flavor, null if one does not exist for the data flavor.
 java.util.Set<java.awt.datatransfer.DataFlavor> getDataFlavors()
          Returns a set of supported data flavors.
static DragAndDropManager getDragAndDropManager()
          Returns a single instance of this class
 java.lang.String getFileExtension(DropTargetEvent3D event)
          Get the file extension for the given event, or return null if no extension can be determined.
static java.lang.String getFileExtension(java.lang.String fileName)
          Returns the string extension name of the given file name.
 boolean hasDataFlavorHandler(java.awt.datatransfer.DataFlavor dataFlavor)
          Return true if a handler exists for the given data flavor
 void importContent(DropTargetDropEvent3D event, DataFlavorHandlerSPI.ImportResultListener listener)
          Import a file and return the corresponding URI to the listner
 void registerDataFlavorHandler(DataFlavorHandlerSPI handler)
          Registers a DataFlavorHandlerSPI.
 void unregisterDataFlavorHandler(DataFlavorHandlerSPI handler)
          Unregisters a DataFlavorHandlerSPI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDragAndDropManager

public static final DragAndDropManager getDragAndDropManager()
Returns a single instance of this class

Returns:
Single instance of this class.

registerDataFlavorHandler

public void registerDataFlavorHandler(DataFlavorHandlerSPI handler)
Registers a DataFlavorHandlerSPI. A data flavor handler handles when an item has been dropped into the world for a specific type. Only one handler is permitted per data flavor type.

Parameters:
handler - The data flavor handler

unregisterDataFlavorHandler

public void unregisterDataFlavorHandler(DataFlavorHandlerSPI handler)
Unregisters a DataFlavorHandlerSPI.

Parameters:
handler - The data flavor handler

getDataFlavors

public java.util.Set<java.awt.datatransfer.DataFlavor> getDataFlavors()
Returns a set of supported data flavors.

Returns:
A Set of DataFlavor objects

getDataFlavorHandler

public DataFlavorHandlerSPI getDataFlavorHandler(java.awt.datatransfer.DataFlavor dataFlavor)
Returns the data flavor handler for the given data flavor, null if one does not exist for the data flavor.

Parameters:
dataFlavor - The DataFlavor object
Returns:
A DataFlavorHandlerSPI object

hasDataFlavorHandler

public boolean hasDataFlavorHandler(java.awt.datatransfer.DataFlavor dataFlavor)
Return true if a handler exists for the given data flavor

Parameters:
dataFlavor - The DataFlavor object
Returns:
true if there is a handler for this flavor

getFileExtension

public java.lang.String getFileExtension(DropTargetEvent3D event)
Get the file extension for the given event, or return null if no extension can be determined.

Parameters:
event - the event to determine the file name of

importContent

public void importContent(DropTargetDropEvent3D event,
                          DataFlavorHandlerSPI.ImportResultListener listener)
Import a file and return the corresponding URI to the listner

Parameters:
event - the event to import a file from
listener - the optional listener to report results to

getFileExtension

public static java.lang.String getFileExtension(java.lang.String fileName)
Returns the string extension name of the given file name. If none, return null. This simply looks for the final period (.) in the name.

Parameters:
fileName - The name of the file
Returns:
The file extension


Open Wonderland - http://openwonderland.org