]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/ui/specific/FileDropAdapter.java
1 package org
.argeo
.eclipse
.ui
.specific
;
3 import java
.io
.IOException
;
4 import java
.io
.InputStream
;
5 import java
.util
.Arrays
;
7 import org
.eclipse
.swt
.dnd
.DND
;
8 import org
.eclipse
.swt
.dnd
.DropTarget
;
9 import org
.eclipse
.swt
.dnd
.DropTargetAdapter
;
10 import org
.eclipse
.swt
.dnd
.DropTargetEvent
;
11 import org
.eclipse
.swt
.dnd
.FileTransfer
;
12 import org
.eclipse
.swt
.dnd
.Transfer
;
13 import org
.eclipse
.swt
.widgets
.Control
;
15 public class FileDropAdapter
{
17 public void prepareDropTarget(Control control
, DropTarget dropTarget
) {
18 dropTarget
.setTransfer(new Transfer
[] { FileTransfer
.getInstance() });
19 dropTarget
.addDropListener(new DropTargetAdapter() {
21 public void dropAccept(DropTargetEvent event
) {
22 if (!FileTransfer
.getInstance().isSupportedType(event
.currentDataType
)) {
23 event
.detail
= DND
.DROP_NONE
;
28 public void drop(DropTargetEvent event
) {
29 handleFileDrop(control
, event
);
34 public void handleFileDrop(Control control
, DropTargetEvent event
) {
35 String fileList
[] = null;
36 FileTransfer ft
= FileTransfer
.getInstance();
37 if (ft
.isSupportedType(event
.currentDataType
)) {
38 fileList
= (String
[]) event
.data
;
40 System
.out
.println(Arrays
.toString(fileList
));
43 /** Executed in UI thread */
44 protected void processUpload(InputStream in
, String fileName
, String contentType
) throws IOException
{