Package org.openstreetmap.josm.gui.io
Class DownloadFileTask
java.lang.Object
org.openstreetmap.josm.gui.PleaseWaitRunnable
org.openstreetmap.josm.gui.io.DownloadFileTask
- All Implemented Interfaces:
Runnable,ProgressMonitor.CancelListener
Asynchronous task for downloading and unpacking arbitrary file lists
Shows progress bar when downloading
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate booleanprivate HttpClientprivate final Fileprivate final booleanprivate final booleanFields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor -
Constructor Summary
ConstructorsConstructorDescriptionDownloadFileTask(Component parent, String address, File file, boolean mkdir, boolean unpack) Creates the download task -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcancel()User pressed cancel button.private voidvoiddownload()Performs download.protected voidfinish()Finish up the data work.booleanReplies true if the task was canceled by the userprotected voidrealRun()Called in the worker thread to do the actual work.static voidunzipFileRecursively(File file, String dir) Recursive unzipping function TODO: May be placed somewhere else - Tools.Utils?Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
Field Details
-
address
-
file
-
mkdir
-
unpack
-
canceled
-
downloadConnection
-
-
Constructor Details
-
DownloadFileTask
Creates the download task- Parameters:
parent- the parent component relative to which thePleaseWaitDialogis displayedaddress- the URL to downloadfile- The destination filemkdir-trueif the destination directory must be created,falseotherwiseunpack-trueif zip archives must be unpacked recursively,falseotherwise- Throws:
IllegalArgumentException- ifparentis null
-
-
Method Details
-
closeConnectionIfNeeded
-
cancel
Description copied from class:PleaseWaitRunnableUser pressed cancel button.- Specified by:
cancelin classPleaseWaitRunnable
-
finish
Description copied from class:PleaseWaitRunnableFinish up the data work. Is guaranteed to be called if realRun is called. Finish is called in the gui thread just after the dialog disappeared.- Specified by:
finishin classPleaseWaitRunnable
-
download
Performs download.- Throws:
DownloadFileTask.DownloadException- if the URL is invalid or if any I/O error occurs.
-
realRun
Description copied from class:PleaseWaitRunnableCalled in the worker thread to do the actual work. When any of the exception is thrown, a message box will be displayed and closeDialog is called. finish() is called in any case.- Specified by:
realRunin classPleaseWaitRunnable- Throws:
SAXException- if a SAX error occursIOException- if an I/O error occurs
-
isCanceled
Replies true if the task was canceled by the user- Returns:
trueif the task was canceled by the user,falseotherwise
-
unzipFileRecursively
Recursive unzipping function TODO: May be placed somewhere else - Tools.Utils?- Parameters:
file- zip filedir- output directory- Throws:
IOException- if any I/O error occurs
-