* is complete.
*/
public void download(URL url, final DownloadCallback callback) throws IOException {
String res = url.toString();
URLDownload udl = null;
// First of all, start the download itself in the background to a temporary file:
final File tmp = File.createTempFile("jabref_download", "tmp");
tmp.deleteOnExit();
//long time = System.currentTimeMillis();
try {
udl = new URLDownload(frame, url, tmp);
// TODO: what if this takes long time?
// TODO: stop editor dialog if this results in an error:
udl.openConnectionOnly(); // Read MIME type
} catch (IOException ex) {
JOptionPane.showMessageDialog(frame, Globals.lang("Invalid URL")+": "
+ ex.getMessage(), Globals.lang("Download file"),
JOptionPane.ERROR_MESSAGE);
Globals.logger("Error while downloading " + "'" + res + "'");
return;
}
final URL urlF = url;
final URLDownload udlF = udl;
//System.out.println("Time: "+(System.currentTimeMillis()-time));
(new Thread() {
public void run() {
try {
udlF.download();
} catch (IOException e2) {
dontShowDialog = true;
if ((editor != null) && (editor.isVisible()))
editor.setVisible(false, false);
JOptionPane.showMessageDialog(frame, Globals.lang("Invalid URL")+": "