public class ReadRemotePluginInformationTask extends PleaseWaitRunnable
Modifier and Type | Class and Description |
---|---|
protected static class |
ReadRemotePluginInformationTask.CacheType |
Modifier and Type | Field and Description |
---|---|
private java.util.List<PluginInformation> |
availablePlugins |
private boolean |
canceled |
private java.net.HttpURLConnection |
connection |
private boolean |
displayErrMsg |
private java.util.Collection<java.lang.String> |
sites |
progressMonitor
Constructor and Description |
---|
ReadRemotePluginInformationTask(java.util.Collection<java.lang.String> sites)
Creates the task
|
ReadRemotePluginInformationTask(ProgressMonitor monitor,
java.util.Collection<java.lang.String> sites,
boolean displayErrMsg)
Creates the task
|
Modifier and Type | Method and Description |
---|---|
protected void |
cachePluginList(java.lang.String site,
java.lang.String list)
Writes the list of plugins to a cache file
|
protected void |
cancel()
User pressed cancel button.
|
protected java.io.File |
createSiteCacheFile(java.io.File pluginDir,
java.lang.String site,
ReadRemotePluginInformationTask.CacheType type)
Creates the file name for the cached plugin list and the icon cache
file.
|
private void |
displayErrorMessage(ProgressMonitor monitor,
java.lang.String msg,
java.lang.String details,
java.lang.String title,
java.lang.String firstMessage) |
protected void |
downloadPluginIcons(java.lang.String site,
java.io.File destFile,
ProgressMonitor monitor)
Downloads the icon archive from a remote location
|
protected java.lang.String |
downloadPluginList(java.lang.String site,
ProgressMonitor monitor)
Downloads the list from a remote location
|
protected java.util.List<PluginInformation> |
filterDeprecatedPlugins(java.util.List<PluginInformation> plugins)
Filter information about deprecated plugins from the list of downloaded
plugins
|
protected void |
finish()
Finish up the data work.
|
java.util.List<PluginInformation> |
getAvailablePlugins()
Replies the list of plugins described in the downloaded plugin lists
|
private void |
handleIOException(ProgressMonitor monitor,
java.io.IOException e,
java.lang.String title,
java.lang.String firstMessage,
boolean displayMsg) |
protected void |
init(java.util.Collection<java.lang.String> sites,
boolean displayErrMsg) |
boolean |
isCanceled()
Replies true if the task was canceled
|
protected void |
parsePluginListDocument(java.lang.String site,
java.lang.String doc)
Parses the plugin list
|
protected void |
realRun()
Called in the worker thread to do the actual work.
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private java.util.Collection<java.lang.String> sites
private boolean canceled
private java.net.HttpURLConnection connection
private java.util.List<PluginInformation> availablePlugins
private boolean displayErrMsg
public ReadRemotePluginInformationTask(java.util.Collection<java.lang.String> sites)
sites
- the collection of download sites. Defaults to the empty collection if null.public ReadRemotePluginInformationTask(ProgressMonitor monitor, java.util.Collection<java.lang.String> sites, boolean displayErrMsg)
monitor
- the progress monitor. Defaults to NullProgressMonitor.INSTANCE
if nullsites
- the collection of download sites. Defaults to the empty collection if null.displayErrMsg
- if true
, a blocking error message is displayed in case of I/O exception.protected final void init(java.util.Collection<java.lang.String> sites, boolean displayErrMsg)
protected void cancel()
PleaseWaitRunnable
cancel
in class PleaseWaitRunnable
protected void finish()
PleaseWaitRunnable
finish
in class PleaseWaitRunnable
protected java.io.File createSiteCacheFile(java.io.File pluginDir, java.lang.String site, ReadRemotePluginInformationTask.CacheType type)
site
- the name of the sitetype
- icon cache or plugin list cacheprotected java.lang.String downloadPluginList(java.lang.String site, ProgressMonitor monitor)
site
- the site URLmonitor
- a progress monitorprivate void handleIOException(ProgressMonitor monitor, java.io.IOException e, java.lang.String title, java.lang.String firstMessage, boolean displayMsg)
private void displayErrorMessage(ProgressMonitor monitor, java.lang.String msg, java.lang.String details, java.lang.String title, java.lang.String firstMessage)
protected void downloadPluginIcons(java.lang.String site, java.io.File destFile, ProgressMonitor monitor)
site
- the site URLmonitor
- a progress monitorprotected void cachePluginList(java.lang.String site, java.lang.String list)
site
- the site from where the list was downloadedlist
- the downloaded listprotected java.util.List<PluginInformation> filterDeprecatedPlugins(java.util.List<PluginInformation> plugins)
plugins
- the plugin informationsprotected void parsePluginListDocument(java.lang.String site, java.lang.String doc)
site
- the site from where the list was downloadeddoc
- the document with the plugin listprotected void realRun() throws org.xml.sax.SAXException, java.io.IOException, OsmTransferException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
org.xml.sax.SAXException
java.io.IOException
OsmTransferException
public boolean isCanceled()
true
if the task was stopped by the userpublic java.util.List<PluginInformation> getAvailablePlugins()