Package org.openstreetmap.josm.plugins
Class PluginDownloadTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- org.openstreetmap.josm.plugins.PluginDownloadTask
-
- All Implemented Interfaces:
java.lang.Runnable,ProgressMonitor.CancelListener
public class PluginDownloadTask extends PleaseWaitRunnable
Asynchronous task for downloading a collection of plugins. When the task is finishedgetDownloadedPlugins()replies the list of downloaded plugins andgetFailedPlugins()replies the list of failed plugins.- Since:
- 2817
-
-
Field Summary
Fields Modifier and Type Field Description private booleancanceledprivate HttpClientdownloadConnectionprivate java.util.Collection<PluginInformation>downloadedprivate java.util.Collection<PluginInformation>failedprivate java.lang.ExceptionlastExceptionstatic java.lang.StringPLUGIN_MIME_TYPESThe accepted MIME types sent in the HTTP Accept header.private java.util.Collection<PluginInformation>toUpdate-
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
-
-
Constructor Summary
Constructors Constructor Description PluginDownloadTask(java.awt.Component parent, java.util.Collection<PluginInformation> toUpdate, java.lang.String title)Creates the download taskPluginDownloadTask(ProgressMonitor monitor, java.util.Collection<PluginInformation> toUpdate, java.lang.String title)Creates the task
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcancel()User pressed cancel button.protected voiddownload(PluginInformation pi, java.io.File file)protected voidfinish()Finish up the data work.java.util.Collection<PluginInformation>getDownloadedPlugins()Replies the list of successfully downloaded plugins.java.util.Collection<PluginInformation>getFailedPlugins()Replies the list of plugins whose download has failed.java.lang.ExceptiongetLastException()Replies the last exception that occurred during download, ornull.booleanisCanceled()Replies true if the task was canceled by the userprotected voidrealRun()Called in the worker thread to do the actual work.voidsetPluginsToDownload(java.util.Collection<PluginInformation> toUpdate)Sets the collection of plugins to update.-
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
-
-
-
Field Detail
-
PLUGIN_MIME_TYPES
public static final java.lang.String PLUGIN_MIME_TYPES
The accepted MIME types sent in the HTTP Accept header.- Since:
- 6867
- See Also:
- Constant Field Values
-
toUpdate
private final java.util.Collection<PluginInformation> toUpdate
-
failed
private final java.util.Collection<PluginInformation> failed
-
downloaded
private final java.util.Collection<PluginInformation> downloaded
-
lastException
private java.lang.Exception lastException
-
canceled
private boolean canceled
-
downloadConnection
private HttpClient downloadConnection
-
-
Constructor Detail
-
PluginDownloadTask
public PluginDownloadTask(java.awt.Component parent, java.util.Collection<PluginInformation> toUpdate, java.lang.String title)
Creates the download task- Parameters:
parent- the parent component relative to which thePleaseWaitDialogis displayedtoUpdate- a collection of plugin descriptions for plugins to update/download. Must not be null.title- the title to display in thePleaseWaitDialog- Throws:
java.lang.IllegalArgumentException- if toUpdate is null
-
PluginDownloadTask
public PluginDownloadTask(ProgressMonitor monitor, java.util.Collection<PluginInformation> toUpdate, java.lang.String title)
Creates the task- Parameters:
monitor- a progress monitor. Defaults toNullProgressMonitor.INSTANCEif nulltoUpdate- a collection of plugin descriptions for plugins to update/download. Must not be null.title- the title to display in thePleaseWaitDialog- Throws:
java.lang.IllegalArgumentException- if toUpdate is null
-
-
Method Detail
-
setPluginsToDownload
public void setPluginsToDownload(java.util.Collection<PluginInformation> toUpdate)
Sets the collection of plugins to update.- Parameters:
toUpdate- the collection of plugins to update. Must not be null.- Throws:
java.lang.IllegalArgumentException- if toUpdate is null
-
cancel
protected void cancel()
Description copied from class:PleaseWaitRunnableUser pressed cancel button.- Specified by:
cancelin classPleaseWaitRunnable
-
finish
protected void 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
protected void download(PluginInformation pi, java.io.File file) throws PluginDownloadException
- Throws:
PluginDownloadException
-
realRun
protected void realRun() throws org.xml.sax.SAXException, java.io.IOException
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:
org.xml.sax.SAXException- if a SAX error occursjava.io.IOException- if an I/O error occurs
-
isCanceled
public boolean isCanceled()
Replies true if the task was canceled by the user- Returns:
trueif the task was stopped by the user
-
getFailedPlugins
public java.util.Collection<PluginInformation> getFailedPlugins()
Replies the list of plugins whose download has failed.- Returns:
- the list of plugins whose download has failed
-
getDownloadedPlugins
public java.util.Collection<PluginInformation> getDownloadedPlugins()
Replies the list of successfully downloaded plugins.- Returns:
- the list of successfully downloaded plugins
-
getLastException
public java.lang.Exception getLastException()
Replies the last exception that occurred during download, ornull.- Returns:
- the last exception that occurred during download, or
null - Since:
- 9621
-
-