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

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

public class URLDataFlavorHandler
extends java.lang.Object
implements DataFlavorHandlerSPI

A handler to support drag-and-drop from a URL (perhaps from a web browser). The data flavor supported has the mime type "application/x-java-url". This simply looks for a Cell that can handle the data type and launches it.

Author:
Jordan Slott

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jdesktop.wonderland.client.jme.dnd.spi.DataFlavorHandlerSPI
DataFlavorHandlerSPI.ImportResultListener
 
Constructor Summary
URLDataFlavorHandler()
           
 
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 importURL(java.net.URL url, DataFlavorHandlerSPI.ImportResultListener listener)
          Import the file at the given URL.
static void launchCellFromURL(java.net.URL url)
          Launches a cell based upon a given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLDataFlavorHandler

public URLDataFlavorHandler()
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.

importURL

public static void importURL(java.net.URL url,
                             DataFlavorHandlerSPI.ImportResultListener listener)
Import the file at the given URL.

Parameters:
url - the url to import
listener - the listener to notify of the result

launchCellFromURL

public static void launchCellFromURL(java.net.URL url)
Launches a cell based upon a given URL. This method assumes the URL refers to some generally-available web content that all clients can fetch

Parameters:
url - The URL to launch a Cell with


Open Wonderland - http://openwonderland.org