org.openstreetmap.josm.gui.history
Class HistoryLoadTask

java.lang.Object
  extended by org.openstreetmap.josm.gui.PleaseWaitRunnable
      extended by org.openstreetmap.josm.gui.history.HistoryLoadTask
All Implemented Interfaces:
java.lang.Runnable, ProgressMonitor.CancelListener
Direct Known Subclasses:
DownloadOsmChangeTask.HistoryLoaderAndListener

public class HistoryLoadTask
extends PleaseWaitRunnable

Loads the object history of an collection of objects from the server. It provides a fluent API for configuration. Sample usage:

   HistoryLoadTask task  = new HistoryLoadTask()
      .add(1, OsmPrimitiveType.NODE)
      .add(1233, OsmPrimitiveType.WAY)
      .add(37234, OsmPrimitveType.RELATION)
      .add(aHistoryItem);

   Main.worker.execute(task);

 


Field Summary
private  boolean canceled
           
private  java.lang.Exception lastException
           
private  HistoryDataSet loadedData
           
private  java.util.HashSet<PrimitiveId> toLoad
           
 
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
 
Constructor Summary
HistoryLoadTask()
           
HistoryLoadTask(java.awt.Component parent)
          Creates a new task
 
Method Summary
 HistoryLoadTask add(java.util.Collection<? extends OsmPrimitive> primitives)
          Adds a collection of objects to loaded, specified by a collection of OSM primitives.
 HistoryLoadTask add(History history)
          Adds an object to be loaded, the object is specified by an already loaded object history.
 HistoryLoadTask add(HistoryOsmPrimitive primitive)
          Adds an object to be loaded, the object is specified by a history item.
 HistoryLoadTask add(long id, OsmPrimitiveType type)
          Adds an object whose history is to be loaded.
 HistoryLoadTask add(OsmPrimitive primitive)
          Adds an object to be loaded, the object is specified by an OSM primitive.
 HistoryLoadTask add(PrimitiveId pid)
          Adds an object whose history is to be loaded.
protected  void cancel()
          User pressed cancel button.
protected  void finish()
          Finish up the data work.
 java.lang.Exception getLastException()
           
 boolean isCanceled()
           
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

canceled

private boolean canceled

lastException

private java.lang.Exception lastException

toLoad

private java.util.HashSet<PrimitiveId> toLoad

loadedData

private HistoryDataSet loadedData
Constructor Detail

HistoryLoadTask

public HistoryLoadTask()

HistoryLoadTask

public HistoryLoadTask(java.awt.Component parent)
Creates a new task

Parameters:
parent - the component to be used as reference to find the parent for PleaseWaitDialog. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if parent is null
Method Detail

add

public HistoryLoadTask add(long id,
                           OsmPrimitiveType type)
                    throws java.lang.IllegalArgumentException
Adds an object whose history is to be loaded.

Parameters:
id - the object id
type - the object type
Returns:
this task
Throws:
java.lang.IllegalArgumentException

add

public HistoryLoadTask add(PrimitiveId pid)
Adds an object whose history is to be loaded.

Parameters:
pid - the primitive id. Must not be null. Id > 0 required.
Returns:
this task

add

public HistoryLoadTask add(HistoryOsmPrimitive primitive)
Adds an object to be loaded, the object is specified by a history item.

Parameters:
primitive - the history item
Returns:
this task
Throws:
java.lang.IllegalArgumentException - thrown if primitive is null

add

public HistoryLoadTask add(History history)
Adds an object to be loaded, the object is specified by an already loaded object history.

Parameters:
history - the history. Must not be null.
Returns:
this task
Throws:
java.lang.IllegalArgumentException - thrown if history is null

add

public HistoryLoadTask add(OsmPrimitive primitive)
Adds an object to be loaded, the object is specified by an OSM primitive.

Parameters:
primitive - the OSM primitive. Must not be null. primitive.getId() > 0 required.
Returns:
this task
Throws:
java.lang.IllegalArgumentException - thrown if the primitive is null
java.lang.IllegalArgumentException - thrown if primitive.getId() <= 0

add

public HistoryLoadTask add(java.util.Collection<? extends OsmPrimitive> primitives)
Adds a collection of objects to loaded, specified by a collection of OSM primitives.

Parameters:
primitive - the OSM primitive. Must not be null. primitive.getId() > 0 required.
Returns:
this task
Throws:
java.lang.IllegalArgumentException - thrown if primitives is null
java.lang.IllegalArgumentException - thrown if one of the ids in the collection <= 0

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

isCanceled

public boolean isCanceled()

getLastException

public java.lang.Exception getLastException()


JOSM