1 package org
.argeo
.cms
.ui
.fs
;
3 import java
.io
.IOException
;
4 import java
.io
.InputStream
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
8 import org
.argeo
.eclipse
.ui
.specific
.FileDropAdapter
;
9 import org
.eclipse
.swt
.dnd
.DND
;
10 import org
.eclipse
.swt
.dnd
.DropTarget
;
11 import org
.eclipse
.swt
.dnd
.DropTargetEvent
;
12 import org
.eclipse
.swt
.widgets
.Control
;
14 /** Allows a control to receive file drops. */
15 public class FileDrop
{
16 private final static Log log
= LogFactory
.getLog(FileDrop
.class);
18 public void createDropTarget(Control control
) {
19 FileDropAdapter fileDropAdapter
= new FileDropAdapter() {
21 protected void processUpload(InputStream in
, String fileName
, String contentType
) throws IOException
{
22 if (log
.isDebugEnabled())
23 log
.debug("Process upload of " + fileName
+ " (" + contentType
+ ")");
24 processFileUpload(in
, fileName
, contentType
);
27 DropTarget dropTarget
= new DropTarget(control
, DND
.DROP_MOVE
| DND
.DROP_COPY
);
28 fileDropAdapter
.prepareDropTarget(control
, dropTarget
);
31 public void handleFileDrop(Control control
, DropTargetEvent event
) {
34 /** Executed in UI thread */
35 protected void processFileUpload(InputStream in
, String fileName
, String contentType
) throws IOException
{