Last change
on this file since 10755 was 10620, checked in by Don-vip, 8 years ago |
fix #13196 - remove FileDrop class (patch my michael2402) - gsoc-core
|
File size:
1.2 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.datatransfer;
|
---|
3 |
|
---|
4 | import java.awt.datatransfer.UnsupportedFlavorException;
|
---|
5 | import java.io.IOException;
|
---|
6 |
|
---|
7 | import javax.swing.JComponent;
|
---|
8 | import javax.swing.TransferHandler;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.Main;
|
---|
11 | import org.openstreetmap.josm.gui.datatransfer.importers.FilePaster;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * This transfer handler allows to drop files to open them.
|
---|
15 | *
|
---|
16 | * @author Michael Zangl
|
---|
17 | * @since 10620
|
---|
18 | */
|
---|
19 | public class FileTransferHandler extends TransferHandler {
|
---|
20 |
|
---|
21 | private static final FilePaster filePaster = new FilePaster();
|
---|
22 |
|
---|
23 | @Override
|
---|
24 | public int getSourceActions(JComponent c) {
|
---|
25 | return COPY;
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public boolean canImport(TransferSupport support) {
|
---|
30 | return filePaster.supports(support);
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public boolean importData(TransferSupport support) {
|
---|
35 | try {
|
---|
36 | if (filePaster.supports(support)) {
|
---|
37 | return filePaster.importData(support, null, null);
|
---|
38 | }
|
---|
39 | } catch (UnsupportedFlavorException | IOException e) {
|
---|
40 | Main.warn(e, "Error while importing file.");
|
---|
41 | }
|
---|
42 | return super.importData(support);
|
---|
43 | }
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.