MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / drop

Method drop

ij/src/main/java/ij/plugin/DragAndDrop.java:60–123  ·  view source on GitHub ↗
(DropTargetDropEvent dtde)

Source from the content-addressed store, hash-verified

58 }
59
60 @AstroImageJ(reason = "Custom Drop Action", modified = true)
61 public void drop(DropTargetDropEvent dtde) {
62 openOptions.clear();
63 dtde.acceptDrop(DnDConstants.ACTION_COPY);
64 DataFlavor[] flavors = null;
65 try {
66 Transferable t = dtde.getTransferable();
67 iterator = null;
68 openOptions = createOptions(dtde);
69 flavors = t.getTransferDataFlavors();
70 if (IJ.debugMode) IJ.log("DragAndDrop.drop: "+flavors.length+" flavors");
71 for (int i=0; i<flavors.length; i++) {
72 if (IJ.debugMode) IJ.log(" flavor["+i+"]: "+flavors[i].getMimeType());
73 if (flavors[i].isFlavorJavaFileListType()) {
74 Object data = t.getTransferData(DataFlavor.javaFileListFlavor);
75 iterator = ((List)data).iterator();
76 break;
77 } else if (flavors[i].isFlavorTextType()) {
78 Object ob = t.getTransferData(flavors[i]);
79 if (!(ob instanceof String)) continue;
80 String s = ob.toString().trim();
81 if (IJ.isLinux() && s.length()>1 && (int)s.charAt(1)==0)
82 s = fixLinuxString(s);
83 ArrayList list = new ArrayList();
84 if (s.indexOf("href=\"")!=-1 || s.indexOf("src=\"")!=-1) {
85 s = parseHTML(s);
86 if (IJ.debugMode) IJ.log(" url: "+s);
87 list.add(s);
88 this.iterator = list.iterator();
89 break;
90 }
91 BufferedReader br = new BufferedReader(new StringReader(s));
92 String tmp;
93 while (null != (tmp = br.readLine())) {
94 tmp = java.net.URLDecoder.decode(tmp.replaceAll("\\+","%2b"), "UTF-8");
95 if (tmp.startsWith("file://")) tmp = tmp.substring(7);
96 if (IJ.debugMode) IJ.log(" content: "+tmp);
97 if (tmp.startsWith("http://"))
98 list.add(s);
99 else
100 list.add(new File(tmp));
101 }
102 this.iterator = list.iterator();
103 break;
104 }
105 }
106 if (iterator!=null) {
107 Thread thread = new Thread(this, "DrawAndDrop");
108 thread.setPriority(Math.max(thread.getPriority()-1, Thread.MIN_PRIORITY));
109 thread.start();
110 }
111 } catch(Exception e) {
112 dtde.dropComplete(false);
113 return;
114 }
115 dtde.dropComplete(true);
116 if (flavors==null || flavors.length==0) {
117 if (IJ.isMacOSX())

Callers

nothing calls this directly

Calls 15

createOptionsMethod · 0.95
logMethod · 0.95
isLinuxMethod · 0.95
fixLinuxStringMethod · 0.95
parseHTMLMethod · 0.95
isMacOSXMethod · 0.95
errorMethod · 0.95
charAtMethod · 0.80
replaceAllMethod · 0.80
startsWithMethod · 0.80
substringMethod · 0.80
lengthMethod · 0.65

Tested by

no test coverage detected