org.openstreetmap.josm.plugins
Class ReadRemotePluginInformationTask

java.lang.Object
  extended by org.openstreetmap.josm.gui.PleaseWaitRunnable
      extended by 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.


Nested Class Summary
protected static class ReadRemotePluginInformationTask.CacheType
           
 
Field Summary
private  java.util.List<PluginInformation> availablePlugins
           
private  boolean canceled
           
private  java.net.HttpURLConnection connection
           
private  java.util.Collection<java.lang.String> sites
           
 
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
 
Constructor Summary
ReadRemotePluginInformationTask(java.util.Collection<java.lang.String> sites)
          Creates the task
ReadRemotePluginInformationTask(ProgressMonitor monitor, java.util.Collection<java.lang.String> sites)
          Creates the task
 
Method Summary
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.
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> getAvailabePlugins()
          Replies the list of plugins described in the downloaded plugin lists
protected  void init(java.util.Collection<java.lang.String> sites)
           
 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.
 
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sites

private java.util.Collection<java.lang.String> sites

canceled

private boolean canceled

connection

private java.net.HttpURLConnection connection

availablePlugins

private java.util.List<PluginInformation> availablePlugins
Constructor Detail

ReadRemotePluginInformationTask

public ReadRemotePluginInformationTask(java.util.Collection<java.lang.String> sites)
Creates the task

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)
Creates the task

Parameters:
monitor - the progress monitor. Defaults to NullProgressMonitor.INSTANCE if null
sites - the collection of download sites. Defaults to the empty collection if null.
Method Detail

init

protected void init(java.util.Collection<java.lang.String> sites)

cancel

protected void cancel()
Description copied from class: PleaseWaitRunnable
User pressed cancel button.

Specified by:
cancel in class PleaseWaitRunnable

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 class PleaseWaitRunnable

createSiteCacheFile

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.

Parameters:
site - the name of the site
type - icon cache or plugin list cache
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 URL
monitor - a progress monitor
Returns:
the downloaded list

downloadPluginIcons

protected void downloadPluginIcons(java.lang.String site,
                                   java.io.File destFile,
                                   ProgressMonitor monitor)
Downloads the icon archive from a remote location

Parameters:
site - the site URL
monitor - a progress monitor

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 downloaded
list - 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

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 downloaded
doc - the document with the plugin list

realRun

protected void realRun()
                throws org.xml.sax.SAXException,
                       java.io.IOException,
                       OsmTransferException
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 class PleaseWaitRunnable
Throws:
org.xml.sax.SAXException
java.io.IOException
OsmTransferException

isCanceled

public boolean isCanceled()
Replies true if the task was canceled

Returns:

getAvailabePlugins

public java.util.List<PluginInformation> getAvailabePlugins()
Replies the list of plugins described in the downloaded plugin lists

Returns:
the list of plugins


JOSM