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

java.lang.Object
  extended by org.jdesktop.wonderland.client.jme.dnd.FileListDataFlavorHandler
All Implemented Interfaces:
DataFlavorHandlerSPI

public class FileListDataFlavorHandler
extends java.lang.Object
implements DataFlavorHandlerSPI

A handler to support drag-and-drop from the desktop. The data flavor supported is the "java file list" type. This interacts with the content manager to find the importer for the content and dispatch there.

Author:
Jordan Slott

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jdesktop.wonderland.client.jme.dnd.spi.DataFlavorHandlerSPI
DataFlavorHandlerSPI.ImportResultListener
 
Constructor Summary
FileListDataFlavorHandler()
           
 
Method Summary
 boolean accept(DropTargetEvent3D event, java.awt.datatransfer.DataFlavor dataFlavor)
          Returns true to accept the event.
 java.awt.datatransfer.DataFlavor[] getDataFlavors()
          Returns an array of DataFlavors that this class supports.
 java.lang.String getFileExtension(DropTargetEvent3D event, java.awt.datatransfer.DataFlavor flavor)
          Returns the file extension of the given event, if the extension can be determined.
 void handleDrop(DropTargetDropEvent3D event, java.awt.datatransfer.DataFlavor dataFlavor)
          Handles when an item has been dropped into the world with a data flavor supported by this class.
 void handleImport(DropTargetDropEvent3D event, java.awt.datatransfer.DataFlavor flavor, DataFlavorHandlerSPI.ImportResultListener listener)
          Handles importing a file with the given data flavor (using the content import manager).
static void importFile(java.util.List<java.io.File> fileList, boolean createCell, DataFlavorHandlerSPI.ImportResultListener listener)
          Launches a cell based upon a list of files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileListDataFlavorHandler

public FileListDataFlavorHandler()
Method Detail

getDataFlavors

public java.awt.datatransfer.DataFlavor[] getDataFlavors()
Description copied from interface: DataFlavorHandlerSPI
Returns an array of DataFlavors that this class supports. If none, then return an empty array.

Specified by:
getDataFlavors in interface DataFlavorHandlerSPI

getFileExtension

public java.lang.String getFileExtension(DropTargetEvent3D event,
                                         java.awt.datatransfer.DataFlavor flavor)
Description copied from interface: DataFlavorHandlerSPI
Returns the file extension of the given event, if the extension can be determined. If the extension cannot be determined from the given event, return null.

Specified by:
getFileExtension in interface DataFlavorHandlerSPI

accept

public boolean accept(DropTargetEvent3D event,
                      java.awt.datatransfer.DataFlavor dataFlavor)
Description copied from interface: DataFlavorHandlerSPI
Returns true to accept the event. This method provides the handler the additional ability to either accept or reject the event. If rejected, the system tries to find another suitable data flavor handler

Specified by:
accept in interface DataFlavorHandlerSPI

handleDrop

public void handleDrop(DropTargetDropEvent3D event,
                       java.awt.datatransfer.DataFlavor dataFlavor)
Description copied from interface: DataFlavorHandlerSPI
Handles when an item has been dropped into the world with a data flavor supported by this class.

Specified by:
handleDrop in interface DataFlavorHandlerSPI
dataFlavor - the flavor being queried for

handleImport

public void handleImport(DropTargetDropEvent3D event,
                         java.awt.datatransfer.DataFlavor flavor,
                         DataFlavorHandlerSPI.ImportResultListener listener)
Description copied from interface: DataFlavorHandlerSPI
Handles importing a file with the given data flavor (using the content import manager). When the import completes, the given listener will be asynchronously notified with the status.

Specified by:
handleImport in interface DataFlavorHandlerSPI
flavor - the flavor to handle
listener - the import listener to notify with the results of the import, or null if no listener should be notified.

importFile

public static void importFile(java.util.List<java.io.File> fileList,
                              boolean createCell,
                              DataFlavorHandlerSPI.ImportResultListener listener)
Launches a cell based upon a list of files. This method uploads the first file found to the content repository and launches a Cell with it.

Parameters:
fileList -


Open Wonderland - http://openwonderland.org