]> git.argeo.org Git - lgpl/argeo-commons.git/blob - FileDrop.java
e875b5a3d1e23b1b9ee4b9de552bbcc5760257fc
[lgpl/argeo-commons.git] / FileDrop.java
1 package org.argeo.cms.ui.fs;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5
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;
12
13 /** Allows a control to receive file drops. */
14 public class FileDrop {
15 private final static CmsLog log = CmsLog.getLog(FileDrop.class);
16
17 public void createDropTarget(Control control) {
18 FileDropAdapter fileDropAdapter = new FileDropAdapter() {
19 @Override
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);
24 }
25 };
26 DropTarget dropTarget = new DropTarget(control, DND.DROP_MOVE | DND.DROP_COPY);
27 fileDropAdapter.prepareDropTarget(control, dropTarget);
28 }
29
30 public void handleFileDrop(Control control, DropTargetEvent event) {
31 }
32
33 /** Executed in UI thread */
34 protected void processFileUpload(InputStream in, String fileName, String contentType) throws IOException {
35
36 }
37 }