Class HistoryLoadTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- 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 a collection of objects from the server. It provides a fluent API for configuration. Sample usage:HistoryLoadTask task = new HistoryLoadTask() .add(node) .add(way) .add(relation) .add(aHistoryItem); MainApplication.worker.execute(task);
-
-
Field Summary
Fields Modifier and Type Field Description private booleancanceledprivate booleancollectMissingprivate booleangetChangesetDataprivate java.lang.ExceptionlastExceptionprivate HistoryDataSetloadedDataprivate java.util.Set<PrimitiveId>missingPrimitivesprivate OsmServerHistoryReaderreaderprivate java.util.Set<PrimitiveId>toLoad-
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
-
-
Constructor Summary
Constructors Constructor Description HistoryLoadTask()Constructs a newHistoryLoadTask.HistoryLoadTask(java.awt.Component parent)Constructs a newHistoryLoadTask.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HistoryLoadTaskadd(History history)Adds an object to be loaded, the object is specified by an already loaded object history.HistoryLoadTaskadd(HistoryOsmPrimitive primitive)Adds an object to be loaded, the object is specified by a history item.HistoryLoadTaskadd(OsmPrimitive primitive)Adds an object to be loaded, the object is specified by an OSM primitive.HistoryLoadTaskadd(PrimitiveId pid)Adds an object whose history is to be loaded.HistoryLoadTaskaddOsmPrimitives(java.util.Collection<? extends OsmPrimitive> primitives)Adds a collection of objects to loaded, specified by a collection of OSM primitives.HistoryLoadTaskaddPrimitiveIds(java.util.Collection<? extends PrimitiveId> primitives)Adds a collection of objects to loaded, specified by a collection of OSM primitives.protected voidcancel()User pressed cancel button.protected voidfinish()Finish up the data work.java.lang.ExceptiongetLastException()Returns the last exception that occurred during loading, if any.protected static java.lang.StringgetLoadingMessage(PrimitiveId pid)java.util.Set<PrimitiveId>getMissingPrimitives()replies the set of ids of all primitives for which a fetch request to the server was submitted but which are not available from the server (the server replied a return code of 404)booleanisCanceled()Determines if this task has ben canceled.private voidloadHistory(PrimitiveId pid)protected static HistoryDataSetloadHistory(OsmServerHistoryReader reader, ProgressMonitor progressMonitor)protected voidrealRun()Called in the worker thread to do the actual work.voidsetChangesetDataNeeded(boolean b)Determine if changeset information is needed.voidsetCollectMissing(boolean b)Determine if missing primitives should be collected.-
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
-
-
-
Field Detail
-
canceled
private boolean canceled
-
lastException
private java.lang.Exception lastException
-
toLoad
private final java.util.Set<PrimitiveId> toLoad
-
loadedData
private HistoryDataSet loadedData
-
reader
private OsmServerHistoryReader reader
-
getChangesetData
private boolean getChangesetData
-
collectMissing
private boolean collectMissing
-
missingPrimitives
private final java.util.Set<PrimitiveId> missingPrimitives
-
-
Constructor Detail
-
HistoryLoadTask
public HistoryLoadTask()
Constructs a newHistoryLoadTask.
-
HistoryLoadTask
public HistoryLoadTask(java.awt.Component parent)
Constructs a newHistoryLoadTask.- Parameters:
parent- the component to be used as reference to find the parent forPleaseWaitDialog. Must not benull.- Throws:
java.lang.NullPointerException- if parent isnull
-
-
Method Detail
-
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.NullPointerException- 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.NullPointerException- 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.getOsmId() > 0 required.- Returns:
- this task
- Throws:
java.lang.NullPointerException- if the primitive is nulljava.lang.IllegalArgumentException- if primitive.getOsmId() <= 0
-
addPrimitiveIds
public HistoryLoadTask addPrimitiveIds(java.util.Collection<? extends PrimitiveId> primitives)
Adds a collection of objects to loaded, specified by a collection of OSM primitives.- Parameters:
primitives- the OSM primitives. Must not benull.primitive.getId() > 0required.- Returns:
- this task
- Throws:
java.lang.NullPointerException- if primitives is nulljava.lang.IllegalArgumentException- if one of the ids in the collection <= 0- Since:
- 16123
-
addOsmPrimitives
public HistoryLoadTask addOsmPrimitives(java.util.Collection<? extends OsmPrimitive> primitives)
Adds a collection of objects to loaded, specified by a collection of OSM primitives.- Parameters:
primitives- the OSM primitives. Must not benull.primitive.getId() > 0required.- Returns:
- this task
- Throws:
java.lang.NullPointerException- if primitives is nulljava.lang.IllegalArgumentException- if one of the ids in the collection <= 0- Since:
- 16123
-
cancel
protected void cancel()
Description copied from class:PleaseWaitRunnableUser pressed cancel button.- Specified by:
cancelin classPleaseWaitRunnable
-
finish
protected void finish()
Description copied from class:PleaseWaitRunnableFinish 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:
finishin classPleaseWaitRunnable
-
realRun
protected void realRun() throws org.xml.sax.SAXException, java.io.IOException, OsmTransferException
Description copied from class:PleaseWaitRunnableCalled 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:
realRunin classPleaseWaitRunnable- Throws:
org.xml.sax.SAXException- if a SAX error occursjava.io.IOException- if an I/O error occursOsmTransferException- if a communication error with the OSM server occurs
-
loadHistory
private void loadHistory(PrimitiveId pid) throws OsmTransferException
- Throws:
OsmTransferException
-
loadHistory
protected static HistoryDataSet loadHistory(OsmServerHistoryReader reader, ProgressMonitor progressMonitor) throws OsmTransferException
- Throws:
OsmTransferException
-
getLoadingMessage
protected static java.lang.String getLoadingMessage(PrimitiveId pid)
-
isCanceled
public boolean isCanceled()
Determines if this task has ben canceled.- Returns:
trueif this task has ben canceled
-
getLastException
public java.lang.Exception getLastException()
Returns the last exception that occurred during loading, if any.- Returns:
- the last exception that occurred during loading, or
null
-
setChangesetDataNeeded
public void setChangesetDataNeeded(boolean b)
Determine if changeset information is needed. By default it is retrieved.- Parameters:
b- false means don't retrieve changeset data.- Since:
- 14763
-
setCollectMissing
public void setCollectMissing(boolean b)
Determine if missing primitives should be collected. By default they are not collected and the first missing object terminates the task.- Parameters:
b- true means collect missing data and continue.- Since:
- 16205
-
getMissingPrimitives
public java.util.Set<PrimitiveId> getMissingPrimitives()
replies the set of ids of all primitives for which a fetch request to the server was submitted but which are not available from the server (the server replied a return code of 404)- Returns:
- the set of ids of missing primitives
- Since:
- 16205
-
-