org.openstreetmap.josm.plugins
Class PluginDownloadTask

java.lang.Object
  extended by org.openstreetmap.josm.gui.PleaseWaitRunnable
      extended by 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 finished getDownloadedPlugins() replies the list of downloaded plugins and getFailedPlugins() replies the list of failed plugins.


Field Summary
private  boolean canceled
           
private  java.net.HttpURLConnection downloadConnection
           
private  java.util.Collection<PluginInformation> downloaded
           
private  java.util.Collection<PluginInformation> failed
           
private  java.lang.Exception lastException
           
private  java.util.Collection<PluginInformation> toUpdate
           
 
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
 
Constructor Summary
PluginDownloadTask(java.awt.Component parent, java.util.Collection<PluginInformation> toUpdate, java.lang.String title)
          Creates the download task
PluginDownloadTask(ProgressMonitor monitor, java.util.Collection<PluginInformation> toUpdate, java.lang.String title)
          Creates the task
 
Method Summary
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 plugins whose download has failed
 java.util.Collection<PluginInformation> getFailedPlugins()
          Replies the list of successfully downloaded plugins
 boolean isCanceled()
          Replies true if the task was canceled by the user
protected  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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 java.net.HttpURLConnection downloadConnection
Constructor Detail

PluginDownloadTask

public PluginDownloadTask(java.awt.Component parent,
                          java.util.Collection<PluginInformation> toUpdate,
                          java.lang.String title)
                   throws java.lang.IllegalArgumentException
Creates the download task

Parameters:
parent - the parent component relative to which the PleaseWaitDialog is displayed
toUpdate - a collection of plugin descriptions for plugins to update/download. Must not be null.
title - the title to display in the PleaseWaitDialog
Throws:
java.lang.IllegalArgumentException - thrown 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 to NullProgressMonitor.INSTANCE if null
toUpdate - a collection of plugin descriptions for plugins to update/download. Must not be null.
title - the title to display in the PleaseWaitDialog
Throws:
java.lang.IllegalArgumentException - thrown if toUpdate is null
Method Detail

setPluginsToDownload

public void setPluginsToDownload(java.util.Collection<PluginInformation> toUpdate)
                          throws java.lang.IllegalArgumentException
Sets the collection of plugins to update.

Parameters:
toUpdate - the collection of plugins to update. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if toUpdate is null

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

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 class PleaseWaitRunnable
Throws:
org.xml.sax.SAXException
java.io.IOException

isCanceled

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

Returns:

getFailedPlugins

public java.util.Collection<PluginInformation> getFailedPlugins()
Replies the list of successfully downloaded plugins

Returns:
the list of successfully downloaded plugins

getDownloadedPlugins

public java.util.Collection<PluginInformation> getDownloadedPlugins()
Replies the list of plugins whose download has failed

Returns:
the list of plugins whose download has failed


JOSM