Class HistoryLoadTask
java.lang.Object
org.openstreetmap.josm.gui.PleaseWaitRunnable
org.openstreetmap.josm.gui.history.HistoryLoadTask
- All Implemented Interfaces:
Runnable,ProgressMonitor.CancelListener
- Direct Known Subclasses:
DownloadOsmChangeTask.HistoryLoaderAndListener
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
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate Exceptionprivate HistoryDataSetprivate final Set<PrimitiveId>private OsmServerHistoryReaderprivate final Set<PrimitiveId>Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newHistoryLoadTask.HistoryLoadTask(Component parent) Constructs a newHistoryLoadTask. -
Method Summary
Modifier and TypeMethodDescriptionAdds an object to be loaded, the object is specified by an already loaded object history.add(HistoryOsmPrimitive primitive) Adds an object to be loaded, the object is specified by a history item.add(OsmPrimitive primitive) Adds an object to be loaded, the object is specified by an OSM primitive.add(PrimitiveId pid) Adds an object whose history is to be loaded.addOsmPrimitives(Collection<? extends OsmPrimitive> primitives) Adds a collection of objects to loaded, specified by a collection of OSM primitives.addPrimitiveIds(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.Returns the last exception that occurred during loading, if any.protected static Stringreplies 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)booleanDetermines 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 Details
-
canceled
-
lastException
-
toLoad
-
loadedData
-
reader
-
getChangesetData
-
collectMissing
-
missingPrimitives
-
-
Constructor Details
-
HistoryLoadTask
public HistoryLoadTask()Constructs a newHistoryLoadTask. -
HistoryLoadTask
Constructs a newHistoryLoadTask.- Parameters:
parent- the component to be used as reference to find the parent forPleaseWaitDialog. Must not benull.- Throws:
NullPointerException- if parent isnull
-
-
Method Details
-
add
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
Adds an object to be loaded, the object is specified by a history item.- Parameters:
primitive- the history item- Returns:
- this task
- Throws:
NullPointerException- if primitive is null
-
add
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:
NullPointerException- if history is null
-
add
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:
NullPointerException- if the primitive is nullIllegalArgumentException- if primitive.getOsmId() <= 0
-
addPrimitiveIds
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:
NullPointerException- if primitives is nullIllegalArgumentException- if one of the ids in the collection <= 0- Since:
- 16123
-
addOsmPrimitives
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:
NullPointerException- if primitives is nullIllegalArgumentException- if one of the ids in the collection <= 0- Since:
- 16123
-
cancel
Description copied from class:PleaseWaitRunnableUser pressed cancel button.- Specified by:
cancelin classPleaseWaitRunnable
-
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
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:
SAXException- if a SAX error occursIOException- if an I/O error occursOsmTransferException- if a communication error with the OSM server occurs
-
loadHistory
- Throws:
OsmTransferException
-
loadHistory
protected static HistoryDataSet loadHistory(OsmServerHistoryReader reader, ProgressMonitor progressMonitor) throws OsmTransferException - Throws:
OsmTransferException
-
getLoadingMessage
-
isCanceled
Determines if this task has ben canceled.- Returns:
trueif this task has ben canceled
-
getLastException
Returns the last exception that occurred during loading, if any.- Returns:
- the last exception that occurred during loading, or
null
-
setChangesetDataNeeded
Determine if changeset information is needed. By default it is retrieved.- Parameters:
b- false means don't retrieve changeset data.- Since:
- 14763
-
setCollectMissing
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
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
-