Package org.openstreetmap.josm.gui.io
Class AsynchronousUploadPrimitivesTask
java.lang.Object
org.openstreetmap.josm.gui.PleaseWaitRunnable
org.openstreetmap.josm.gui.io.AbstractUploadTask
org.openstreetmap.josm.gui.io.UploadPrimitivesTask
org.openstreetmap.josm.gui.io.AsynchronousUploadPrimitivesTask
- All Implemented Interfaces:
Runnable,ProgressMonitor.CancelListener
Task for uploading primitives using background worker threads. The actual upload is delegated to the
UploadPrimitivesTask. This class is a wrapper over that to make the background upload process safe. There
can only be one instance of this class, hence background uploads are limited to one at a time. This class also
changes the editLayer of MainLayerManager to null during upload so that
any changes to the uploading layer are prohibited.- Since:
- 13133
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AsynchronousUploadPrimitivesTaskStatic instanceprivate final ProgressTaskIdMember fieldsprivate final OsmDataLayerFields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAsynchronousUploadPrimitivesTask(UploadStrategySpecification uploadStrategySpecification, OsmDataLayer osmDataLayer, APIDataSet apiDataSet, Changeset changeset) Private constructor to restrict creating more Asynchronous upload tasks -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcancel()User pressed cancel button.Task can run in background if returned value != null.createAsynchronousUploadTask(UploadStrategySpecification uploadStrategySpecification, OsmDataLayer dataLayer, APIDataSet apiDataSet, Changeset changeset) Creates an instance of AsynchronousUploadPrimitiveTaskprotected voidfinish()Depending on the success of the upload operation and on the policy for multi changeset uploads this will send the user back to the appropriate place in JOSM, either: to an error dialog, to the Upload Dialog, or to map editing.Get the current upload taskprotected voidrealRun()Called in the worker thread to do the actual work.Methods inherited from class org.openstreetmap.josm.gui.io.UploadPrimitivesTask
cleanupAfterUpload, handleChangesetFullResponse, promptUserForPolicy, recoverFromGoneOnServerMethods inherited from class org.openstreetmap.josm.gui.io.AbstractUploadTask
handleFailedUpload, handleGone, handlePreconditionFailed, handleUploadConflict, handleUploadConflictForClosedChangeset, handleUploadConflictForKnownConflict, handleUploadConflictForUnknownConflict, handleUploadPreconditionFailedConflict, synchronizeDataSet, synchronizePrimitiveMethods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, getProgressMonitor, operationCanceled, run
-
Field Details
-
asynchronousUploadPrimitivesTask
Static instance -
taskId
Member fields -
uploadDataLayer
-
-
Constructor Details
-
AsynchronousUploadPrimitivesTask
private AsynchronousUploadPrimitivesTask(UploadStrategySpecification uploadStrategySpecification, OsmDataLayer osmDataLayer, APIDataSet apiDataSet, Changeset changeset) Private constructor to restrict creating more Asynchronous upload tasks- Parameters:
uploadStrategySpecification- UploadStrategySpecification for the DataLayerosmDataLayer- Datalayer to be uploadedapiDataSet- ApiDataSet that contains the primitives to be uploadedchangeset- Changeset for the datalayer- Throws:
IllegalArgumentException- if layer is nullIllegalArgumentException- if toUpload is nullIllegalArgumentException- if strategy is nullIllegalArgumentException- if changeset is null
-
-
Method Details
-
createAsynchronousUploadTask
public static Optional<AsynchronousUploadPrimitivesTask> createAsynchronousUploadTask(UploadStrategySpecification uploadStrategySpecification, OsmDataLayer dataLayer, APIDataSet apiDataSet, Changeset changeset) Creates an instance of AsynchronousUploadPrimitiveTask- Parameters:
uploadStrategySpecification- UploadStrategySpecification for the DataLayerdataLayer- Datalayer to be uploadedapiDataSet- ApiDataSet that contains the primitives to be uploadedchangeset- Changeset for the datalayer- Returns:
- Returns an Optional<AsynchronousUploadPrimitivesTask> if there is no background upload in progress. Otherwise returns an Optional.empty()
- Throws:
IllegalArgumentException- if layer is nullIllegalArgumentException- if toUpload is nullIllegalArgumentException- if strategy is nullIllegalArgumentException- if changeset is null
-
getCurrentAsynchronousUploadTask
Get the current upload task- Returns:
- Optional<AsynchronousUploadPrimitivesTask>
-
canRunInBackground
Description copied from class:PleaseWaitRunnableTask can run in background if returned value != null. Note that it's tasks responsibility to ensure proper synchronization, PleaseWaitRunnable doesn't with it.- Overrides:
canRunInBackgroundin classPleaseWaitRunnable- Returns:
- If returned value is != null then task can run in background. TaskId could be used in future for "Always run in background" checkbox
-
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.- Overrides:
realRunin classUploadPrimitivesTask
-
cancel
Description copied from class:PleaseWaitRunnableUser pressed cancel button.- Overrides:
cancelin classUploadPrimitivesTask
-
finish
Description copied from class:UploadPrimitivesTaskDepending on the success of the upload operation and on the policy for multi changeset uploads this will send the user back to the appropriate place in JOSM, either:- to an error dialog,
- to the Upload Dialog, or
- to map editing.
- Overrides:
finishin classUploadPrimitivesTask
-