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 boolean
canceled
private HttpClient
downloadConnection
private java.util.Collection<PluginInformation>
downloaded
private java.util.Collection<PluginInformation>
failed
private java.lang.Exception
lastException
static java.lang.String
PLUGIN_MIME_TYPES
The 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 void
cancel()
User pressed cancel button.protected void
download(PluginInformation pi, java.io.File file)
protected void
finish()
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.Exception
getLastException()
Replies the last exception that occurred during download, ornull
.boolean
isCanceled()
Replies true if the task was canceled by the userprotected void
realRun()
Called in the worker thread to do the actual work.void
setPluginsToDownload(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 thePleaseWaitDialog
is 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.INSTANCE
if 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:PleaseWaitRunnable
User pressed cancel button.- Specified by:
cancel
in classPleaseWaitRunnable
-
finish
protected void finish()
Description copied from class:PleaseWaitRunnable
Finish 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:
finish
in 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:PleaseWaitRunnable
Called 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:
realRun
in 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:
true
if 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
-
-