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