Package org.openstreetmap.josm.plugins
Class ReadRemotePluginInformationTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- org.openstreetmap.josm.plugins.ReadRemotePluginInformationTask
-
- All Implemented Interfaces:
java.lang.Runnable,ProgressMonitor.CancelListener
public class ReadRemotePluginInformationTask extends PleaseWaitRunnable
An asynchronous task for downloading plugin lists from the configured plugin download sites.- Since:
- 2817
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<PluginInformation>availablePluginsprivate booleancanceledprivate HttpClientconnectionprivate booleandisplayErrMsgprivate java.util.Collection<java.lang.String>sites-
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
-
-
Constructor Summary
Constructors Constructor Description ReadRemotePluginInformationTask(java.util.Collection<java.lang.String> sites)Constructs a newReadRemotePluginInformationTask.ReadRemotePluginInformationTask(ProgressMonitor monitor, java.util.Collection<java.lang.String> sites, boolean displayErrMsg)Constructs a newReadRemotePluginInformationTask.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcachePluginList(java.lang.String site, java.lang.String list)Writes the list of plugins to a cache fileprotected voidcancel()User pressed cancel button.protected java.io.FilecreateSiteCacheFile(java.io.File pluginDir, java.lang.String site)Creates the file name for the cached plugin list and the icon cache file.private static voiddisplayErrorMessage(ProgressMonitor monitor, java.lang.String msg, java.lang.String details, java.lang.String title, java.lang.String firstMessage)protected java.lang.StringdownloadPluginList(java.lang.String site, ProgressMonitor monitor)Downloads the list from a remote locationprotected java.util.List<PluginInformation>filterDeprecatedPlugins(java.util.List<PluginInformation> plugins)Filter information about deprecated plugins from the list of downloaded pluginsprotected java.util.List<PluginInformation>filterIrrelevantPlugins(java.util.List<PluginInformation> plugins)protected voidfinish()Finish up the data work.java.util.List<PluginInformation>getAvailablePlugins()Replies the list of plugins described in the downloaded plugin listsprivate voidhandleIOException(ProgressMonitor monitor, java.io.IOException e, java.lang.String details)protected voidinit(java.util.Collection<java.lang.String> sites, boolean displayErrMsg)booleanisCanceled()Replies true if the task was canceledprotected voidparsePluginListDocument(java.lang.String site, java.lang.String doc)Parses the plugin listprotected voidrealRun()Called in the worker thread to do the actual work.-
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
-
-
-
Field Detail
-
sites
private java.util.Collection<java.lang.String> sites
-
canceled
private boolean canceled
-
connection
private HttpClient connection
-
availablePlugins
private java.util.List<PluginInformation> availablePlugins
-
displayErrMsg
private boolean displayErrMsg
-
-
Constructor Detail
-
ReadRemotePluginInformationTask
public ReadRemotePluginInformationTask(java.util.Collection<java.lang.String> sites)
Constructs a newReadRemotePluginInformationTask.- Parameters:
sites- the collection of download sites. Defaults to the empty collection if null.
-
ReadRemotePluginInformationTask
public ReadRemotePluginInformationTask(ProgressMonitor monitor, java.util.Collection<java.lang.String> sites, boolean displayErrMsg)
Constructs a newReadRemotePluginInformationTask.- Parameters:
monitor- the progress monitor. Defaults toNullProgressMonitor.INSTANCEif nullsites- the collection of download sites. Defaults to the empty collection if null.displayErrMsg- iftrue, a blocking error message is displayed in case of I/O exception.
-
-
Method Detail
-
init
protected final void init(java.util.Collection<java.lang.String> sites, boolean displayErrMsg)
-
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
-
createSiteCacheFile
protected java.io.File createSiteCacheFile(java.io.File pluginDir, java.lang.String site)
Creates the file name for the cached plugin list and the icon cache file.- Parameters:
pluginDir- directory of plugin for data storagesite- the name of the site- Returns:
- the file name for the cache file
-
downloadPluginList
protected java.lang.String downloadPluginList(java.lang.String site, ProgressMonitor monitor)
Downloads the list from a remote location- Parameters:
site- the site URLmonitor- a progress monitor- Returns:
- the downloaded list
-
handleIOException
private void handleIOException(ProgressMonitor monitor, java.io.IOException e, java.lang.String details)
-
displayErrorMessage
private static void displayErrorMessage(ProgressMonitor monitor, java.lang.String msg, java.lang.String details, java.lang.String title, java.lang.String firstMessage)
-
cachePluginList
protected void cachePluginList(java.lang.String site, java.lang.String list)
Writes the list of plugins to a cache file- Parameters:
site- the site from where the list was downloadedlist- the downloaded list
-
filterDeprecatedPlugins
protected java.util.List<PluginInformation> filterDeprecatedPlugins(java.util.List<PluginInformation> plugins)
Filter information about deprecated plugins from the list of downloaded plugins- Parameters:
plugins- the plugin informations- Returns:
- the plugin informations, without deprecated plugins
-
filterIrrelevantPlugins
protected java.util.List<PluginInformation> filterIrrelevantPlugins(java.util.List<PluginInformation> plugins)
-
parsePluginListDocument
protected void parsePluginListDocument(java.lang.String site, java.lang.String doc)
Parses the plugin list- Parameters:
site- the site from where the list was downloadeddoc- the document with the plugin list
-
realRun
protected void realRun() throws org.xml.sax.SAXException, java.io.IOException, OsmTransferException
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 occursOsmTransferException- if a communication error with the OSM server occurs
-
isCanceled
public boolean isCanceled()
Replies true if the task was canceled- Returns:
trueif the task was stopped by the user
-
getAvailablePlugins
public java.util.List<PluginInformation> getAvailablePlugins()
Replies the list of plugins described in the downloaded plugin lists- Returns:
- the list of plugins
- Since:
- 5601
-
-