public class DragDropHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.List<java.lang.String> |
fileNames
Storage to keep dropped file names with current operation.
|
private static boolean |
inProgress
Flag indicating we are now currently in a middle of drop operation.
|
private static java.util.Set<? extends java.nio.file.OpenOption> |
OPEN_OPTIONS
The default file options set
|
private static int |
readyCounter
File ready counter.
|
private static Widget<?> |
widDropTargetPending
The widget is pending for drop notify event.
|
Constructor and Description |
---|
DragDropHelper() |
Modifier and Type | Method and Description |
---|---|
private static void |
addFileName(java.lang.String fileName)
Adds next file name to the list of the dropped files.
|
static boolean |
endFileDrop()
Terminates file dropping operation and clean up resources.
|
static java.lang.String |
getDroppedFile(int index)
Gets the name of the dropped file from internal 1-based list list.
|
static int |
getNumDroppedFiles()
Gets the number of the dropped files.
|
static void |
readDataAndSaveAsFile(java.lang.String name,
java.nio.channels.FileChannel channel,
int length)
Reads the data from the given file channel starting from its current position and stores
the retrieved data into the file in Java temporary directory with the given name.
|
static void |
saveFile(java.lang.String name,
byte[] data,
int size)
Stores the given byte array date as file in Java temporary directory with the given name.
|
static void |
startDropTarget(Widget<?> widDropTarget,
java.util.List<java.io.File> fileList,
boolean useTmpDir)
Initiates drop operation for given widget.
|
private static final java.util.Set<? extends java.nio.file.OpenOption> OPEN_OPTIONS
private static java.util.List<java.lang.String> fileNames
private static boolean inProgress
private static int readyCounter
private static Widget<?> widDropTargetPending
public static boolean endFileDrop()
TRUE
in success, FALSE
otherwise.public static int getNumDroppedFiles()
public static java.lang.String getDroppedFile(int index)
index
- 1-based number of the file name to get.public static void startDropTarget(Widget<?> widDropTarget, java.util.List<java.io.File> fileList, boolean useTmpDir)
widDropTarget
- The widget to post notification about drop event.fileList
- The file list the widget must handle on drop operation.useTmpDir
- The flag indicating we need to use files uploaded into temporary directory.public static void saveFile(java.lang.String name, byte[] data, int size)
name
- The file name to create.data
- The data to store in the file.size
- The size of the to create, used to check the input array.public static void readDataAndSaveAsFile(java.lang.String name, java.nio.channels.FileChannel channel, int length)
name
- The file name to createchannel
- The file channellength
- The length of the contentprivate static void addFileName(java.lang.String fileName)
fileName
- The filename to add.