org.openstreetmap.josm.gui.dialogs.changeset
Class ChangesetHeaderDownloadTask

java.lang.Object
  extended by org.openstreetmap.josm.gui.PleaseWaitRunnable
      extended by org.openstreetmap.josm.gui.dialogs.changeset.ChangesetHeaderDownloadTask
All Implemented Interfaces:
java.lang.Runnable, ChangesetDownloadTask, ProgressMonitor.CancelListener

public class ChangesetHeaderDownloadTask
extends PleaseWaitRunnable
implements ChangesetDownloadTask

This is an asynchronous task for downloading a collection of changests from the OSM server. The task only downloads the changeset properties without the changeset content. It updates the global ChangesetCache.


Field Summary
private  boolean canceled
           
private  java.util.Set<Changeset> downloadedChangesets
           
private  java.util.Set<java.lang.Integer> idsToDownload
           
private  java.lang.Exception lastException
           
private  OsmServerChangesetReader reader
           
 
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
 
Constructor Summary
ChangesetHeaderDownloadTask(java.util.Collection<java.lang.Integer> ids)
          Creates the download task for a collection of changeset ids.
ChangesetHeaderDownloadTask(java.awt.Component dialogParent, java.util.Collection<java.lang.Integer> ids)
          Creates the download task for a collection of changeset ids.
 
Method Summary
static ChangesetHeaderDownloadTask buildTaskForChangesets(java.util.Collection<Changeset> changesets)
          Builds a download task from for a collection of changesets.
static ChangesetHeaderDownloadTask buildTaskForChangesets(java.awt.Component parent, java.util.Collection<Changeset> changesets)
          Builds a download task from for a collection of changesets.
protected  void cancel()
          User pressed cancel button.
protected  void finish()
          Finish up the data work.
 java.util.Set<Changeset> getDownloadedChangesets()
           
protected  void init(java.util.Collection<java.lang.Integer> ids)
           
 boolean isCanceled()
           
 boolean isFailed()
           
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
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

idsToDownload

private java.util.Set<java.lang.Integer> idsToDownload

reader

private OsmServerChangesetReader reader

canceled

private boolean canceled

lastException

private java.lang.Exception lastException

downloadedChangesets

private java.util.Set<Changeset> downloadedChangesets
Constructor Detail

ChangesetHeaderDownloadTask

public ChangesetHeaderDownloadTask(java.util.Collection<java.lang.Integer> ids)
Creates the download task for a collection of changeset ids. Uses a PleaseWaitDialog whose parent is Main.parent. Null ids or or ids <= 0 in the id collection are ignored.

Parameters:
ids - the collection of ids. Empty collection assumed if null.

ChangesetHeaderDownloadTask

public ChangesetHeaderDownloadTask(java.awt.Component dialogParent,
                                   java.util.Collection<java.lang.Integer> ids)
                            throws java.lang.IllegalArgumentException
Creates the download task for a collection of changeset ids. Uses a PleaseWaitDialog whose parent is the parent window of dialogParent. Null ids or or ids <= 0 in the id collection are ignored.

Parameters:
dialogParent - the parent reference component for the PleaseWaitDialog. Must not be null.
ids - the collection of ids. Empty collection assumed if null.
Throws:
java.lang.IllegalArgumentException - thrown if dialogParent is null
Method Detail

buildTaskForChangesets

public static ChangesetHeaderDownloadTask buildTaskForChangesets(java.util.Collection<Changeset> changesets)
Builds a download task from for a collection of changesets. Ignores null values and changesets with Changeset.isNew() == true.

Parameters:
changesets - the collection of changesets. Assumes an empty collection if null.
Returns:
the download task

buildTaskForChangesets

public static ChangesetHeaderDownloadTask buildTaskForChangesets(java.awt.Component parent,
                                                                 java.util.Collection<Changeset> changesets)
Builds a download task from for a collection of changesets. Ignores null values and changesets with Changeset.isNew() == true.

Parameters:
parent - the parent component relative to which the PleaseWaitDialog is displayed. Must not be null.
changesets - the collection of changesets. Assumes an empty collection if null.
Returns:
the download task
Throws:
java.lang.IllegalArgumentException - thrown if parent is null

init

protected void init(java.util.Collection<java.lang.Integer> ids)

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

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

getDownloadedChangesets

public java.util.Set<Changeset> getDownloadedChangesets()
Specified by:
getDownloadedChangesets in interface ChangesetDownloadTask

isCanceled

public boolean isCanceled()
Specified by:
isCanceled in interface ChangesetDownloadTask

isFailed

public boolean isFailed()
Specified by:
isFailed in interface ChangesetDownloadTask


JOSM