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