Package org.openstreetmap.josm.plugins
Class ReadRemotePluginInformationTask
java.lang.Object
org.openstreetmap.josm.gui.PleaseWaitRunnable
org.openstreetmap.josm.plugins.ReadRemotePluginInformationTask
- All Implemented Interfaces:
Runnable,ProgressMonitor.CancelListener
An asynchronous task for downloading plugin lists from the configured plugin download sites.
- Since:
- 2817
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<PluginInformation>private booleanprivate HttpClientprivate booleanprivate Collection<String>Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newReadRemotePluginInformationTask.ReadRemotePluginInformationTask(ProgressMonitor monitor, Collection<String> sites, boolean displayErrMsg) Constructs a newReadRemotePluginInformationTask. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcachePluginList(String site, String list) Writes the list of plugins to a cache fileprotected voidcancel()User pressed cancel button.protected FilecreateSiteCacheFile(File pluginDir, String site) Creates the file name for the cached plugin list and the icon cache file.private static voiddisplayErrorMessage(ProgressMonitor monitor, String msg, String details, String title, String firstMessage) protected StringdownloadPluginList(String site, ProgressMonitor monitor) Downloads the list from a remote locationprotected List<PluginInformation>filterDeprecatedPlugins(List<PluginInformation> plugins) Filter information about deprecated plugins from the list of downloaded pluginsprotected List<PluginInformation>filterIrrelevantPlugins(List<PluginInformation> plugins) protected voidfinish()Finish up the data work.Replies the list of plugins described in the downloaded plugin listsprivate voidhandleIOException(ProgressMonitor monitor, IOException e, String details) protected final voidinit(Collection<String> sites, boolean displayErrMsg) booleanReplies true if the task was canceledprotected voidparsePluginListDocument(String site, 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 Details
-
sites
-
canceled
-
connection
-
availablePlugins
-
displayErrMsg
-
-
Constructor Details
-
ReadRemotePluginInformationTask
Constructs a newReadRemotePluginInformationTask.- Parameters:
sites- the collection of download sites. Defaults to the empty collection if null.
-
ReadRemotePluginInformationTask
public ReadRemotePluginInformationTask(ProgressMonitor monitor, Collection<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 Details
-
init
-
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
-
createSiteCacheFile
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
Downloads the list from a remote location- Parameters:
site- the site URLmonitor- a progress monitor- Returns:
- the downloaded list
-
handleIOException
-
displayErrorMessage
private static void displayErrorMessage(ProgressMonitor monitor, String msg, String details, String title, String firstMessage) -
cachePluginList
Writes the list of plugins to a cache file- Parameters:
site- the site from where the list was downloadedlist- the downloaded list
-
filterDeprecatedPlugins
Filter information about deprecated plugins from the list of downloaded plugins- Parameters:
plugins- the plugin informations- Returns:
- the plugin informations, without deprecated plugins
-
filterIrrelevantPlugins
-
parsePluginListDocument
Parses the plugin list- Parameters:
site- the site from where the list was downloadeddoc- the document with the plugin list
-
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 occursOsmTransferException- if a communication error with the OSM server occurs
-
isCanceled
Replies true if the task was canceled- Returns:
trueif the task was stopped by the user
-
getAvailablePlugins
Replies the list of plugins described in the downloaded plugin lists- Returns:
- the list of plugins
- Since:
- 5601
-