private boolean handleDropTransfer(String dropStr, final int dropRow) throws IOException { if (dropStr.startsWith("file:")) { // This appears to be a dragged file link and not a reference // format. Check if we can map this to a set of files: if (handleDraggedFilenames(dropStr, dropRow)) { return true; // If not, handle it in the normal way... } } else if (dropStr.startsWith("http:")) { // This is the way URL links are received on OS X and KDE (Gnome?): URL url = new URL(dropStr); // JOptionPane.showMessageDialog(null, "Making URL: // "+url.toString()); return handleDropTransfer(url); } File tmpfile = java.io.File.createTempFile("jabrefimport", ""); tmpfile.deleteOnExit(); try (FileWriter fw = new FileWriter(tmpfile)) { fw.write(dropStr); } // System.out.println("importing from " + tmpfile.getAbsolutePath()); ImportMenuItem importer = new ImportMenuItem(frame, false); importer.automatedImport(new String[] {tmpfile.getAbsolutePath()}); return true; }
private boolean handleDropTransfer(URL dropLink) throws IOException { File tmpfile = java.io.File.createTempFile("jabrefimport", ""); tmpfile.deleteOnExit(); // System.out.println("Import url: " + dropLink.toString()); // System.out.println("Temp file: "+tmpfile.getAbsolutePath()); MonitoredURLDownload.buildMonitoredDownload(entryTable, dropLink).downloadToFile(tmpfile); // Import into new if entryTable==null, otherwise into current database: ImportMenuItem importer = new ImportMenuItem(frame, entryTable == null); importer.automatedImport(new String[] {tmpfile.getAbsolutePath()}); return true; }