com.alee.utils
Class DragUtils

java.lang.Object
  extended by com.alee.utils.DragUtils

public final class DragUtils
extends java.lang.Object

This class provides a set of utilities to simplify work with swing drag and drop.

Author:
Mikle Garin

Field Summary
static java.lang.String URI_LIST_MIME_TYPE
          URI list mime type.
static java.lang.String uriListSeparator
          URI string data separator.
 
Constructor Summary
DragUtils()
           
 
Method Summary
static boolean canPassDrop(java.awt.Component component, javax.swing.TransferHandler.TransferSupport info)
          Returns whether can pass drop action to closest component parent that has its own TransferHandler.
static boolean canPassDrop(javax.swing.TransferHandler.TransferSupport info)
          Returns whether can pass drop action to closest component parent that has its own TransferHandler.
static java.lang.String fileListToTextURIList(java.util.List<java.io.File> files)
          Returns text URI list for the specified list of files.
static java.util.List<java.io.File> getImportedFiles(java.awt.datatransfer.Transferable t)
          Returns list of imported files retrieved from the specified transferable.
static java.awt.Image getImportedImage(java.awt.datatransfer.Transferable t)
          Returns improrted image retrieved from the specified transferable.
static java.awt.datatransfer.DataFlavor getUriListDataFlavor()
          Returns URI list data flavor.
static boolean hasURIListFlavor(java.awt.datatransfer.DataFlavor[] flavors)
          Returns whether flavors array has URI list flavor or not.
static boolean passDropAction(java.awt.Component component, javax.swing.TransferHandler.TransferSupport info)
          Passes drop action to closest component parent that has its own TransferHandler.
static boolean passDropAction(javax.swing.TransferHandler.TransferSupport info)
          Passes drop action to closest component parent that has its own TransferHandler.
static java.util.List<java.io.File> textURIListToFileList(java.lang.String data)
          Returns list of files from the specified text URI list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URI_LIST_MIME_TYPE

public static final java.lang.String URI_LIST_MIME_TYPE
URI list mime type.

See Also:
Constant Field Values

uriListSeparator

public static final java.lang.String uriListSeparator
URI string data separator.

See Also:
Constant Field Values
Constructor Detail

DragUtils

public DragUtils()
Method Detail

getImportedImage

public static java.awt.Image getImportedImage(java.awt.datatransfer.Transferable t)
Returns improrted image retrieved from the specified transferable.

Parameters:
t - transferable
Returns:
improrted image

getImportedFiles

public static java.util.List<java.io.File> getImportedFiles(java.awt.datatransfer.Transferable t)
Returns list of imported files retrieved from the specified transferable.

Parameters:
t - transferable
Returns:
list of imported files

textURIListToFileList

public static java.util.List<java.io.File> textURIListToFileList(java.lang.String data)
Returns list of files from the specified text URI list.

Parameters:
data - text list of URI
Returns:
list of files

fileListToTextURIList

public static java.lang.String fileListToTextURIList(java.util.List<java.io.File> files)
Returns text URI list for the specified list of files.

Parameters:
files - list of files to convert
Returns:
text URI list

hasURIListFlavor

public static boolean hasURIListFlavor(java.awt.datatransfer.DataFlavor[] flavors)
Returns whether flavors array has URI list flavor or not.

Parameters:
flavors - flavors array
Returns:
true if flavors array has URI list flavor, false otherwise

getUriListDataFlavor

public static java.awt.datatransfer.DataFlavor getUriListDataFlavor()
Returns URI list data flavor.

Returns:
URI list data flavor

canPassDrop

public static boolean canPassDrop(javax.swing.TransferHandler.TransferSupport info)
Returns whether can pass drop action to closest component parent that has its own TransferHandler. This might be used to make some components that has drag handler transparent for drop actions.

Parameters:
info - transfer support
Returns:
true if drop action succeed, false otherwise

canPassDrop

public static boolean canPassDrop(java.awt.Component component,
                                  javax.swing.TransferHandler.TransferSupport info)
Returns whether can pass drop action to closest component parent that has its own TransferHandler. This might be used to make some components that has drag handler transparent for drop actions.

Parameters:
component - component to pass drop action from
info - transfer support
Returns:
true if drop action succeed, false otherwise

passDropAction

public static boolean passDropAction(javax.swing.TransferHandler.TransferSupport info)
Passes drop action to closest component parent that has its own TransferHandler. This might be used to make some components that has drag handler transparent for drop actions.

Parameters:
info - transfer support
Returns:
true if drop action succeed, false otherwise

passDropAction

public static boolean passDropAction(java.awt.Component component,
                                     javax.swing.TransferHandler.TransferSupport info)
Passes drop action to closest component parent that has its own TransferHandler. This might be used to make some components that has drag handler transparent for drop actions.

Parameters:
component - component to pass drop action from
info - transfer support
Returns:
true if drop action succeed, false otherwise