Package org.openstreetmap.josm.actions
Class UploadAction
java.lang.Object
javax.swing.AbstractAction
org.openstreetmap.josm.actions.JosmAction
org.openstreetmap.josm.actions.AbstractUploadAction
org.openstreetmap.josm.actions.UploadAction
- All Implemented Interfaces:
ActionListener,Serializable,Cloneable,EventListener,Action,Destroyable
Action that opens a connection to the osm server and uploads all changes.
A dialog is displayed asking the user to specify a rectangle to grab. The url and account settings from the preferences are used.
If the upload fails, this action offers various options to resolve conflicts.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final List<UploadHook>private static final List<UploadHook>The list of upload hooks.Fields inherited from class org.openstreetmap.josm.actions.JosmAction
scFields inherited from class javax.swing.AbstractAction
changeSupport, enabledFields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected static voidstatic booleanCheck whether the preconditions are met to upload data from a given layer, if applicable.static booleancheckPreUploadConditions(AbstractModifiableLayer layer, APIDataSet apiData) Check whether the preconditions are met to upload data inapiData.checkPreUploadConditionsAsync(AbstractModifiableLayer layer, APIDataSet apiData, Consumer<Boolean> onFinish) Check whether the preconditions are met to upload data inapiData.protected booleanOverwrite this ifJosmAction.updateEnabledState()should be called when the selection changed.private static voidrealUploadData(OsmDataLayer layer, APIDataSet apiData) Uploads data to the OSM API.static voidregisterUploadHook(UploadHook hook) Registers an upload hook.static voidregisterUploadHook(UploadHook hook, boolean late) Registers an upload hook.static voidUnregisters an upload hook.protected voidOverride in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.voiduploadData(OsmDataLayer layer, APIDataSet apiData) Uploads data to the OSM API.static booleanWarn user about discouraged upload, propose to cancel operation.Methods inherited from class org.openstreetmap.josm.actions.AbstractUploadAction
buildLayerChangeAdapterMethods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFutureMethods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
Field Details
-
UPLOAD_HOOKS
The list of upload hooks. These hooks will be called one after the other when the user wants to upload data. Plugins can insert their own hooks here if they want to be able to veto an upload.By default, the standard upload dialog is the only element in the list. Plugins should normally insert their code before that, so that the upload dialog is the last thing shown before upload really starts; on occasion however, a plugin might also want to insert something after that.
-
LATE_UPLOAD_HOOKS
-
IS_ASYNC_UPLOAD_ENABLED
- See Also:
-
-
Constructor Details
-
UploadAction
public UploadAction()Constructs a newUploadAction.
-
-
Method Details
-
registerUploadHook
Registers an upload hook. Adds the hook at the first position of the upload hooks.- Parameters:
hook- the upload hook. Ignored if null.
-
registerUploadHook
Registers an upload hook. Adds the hook at the first position of the upload hooks.- Parameters:
hook- the upload hook. Ignored if null.late- true, if the hook should be executed after the upload dialog has been confirmed. Late upload hooks should in general succeed and not abort the upload.
-
unregisterUploadHook
Unregisters an upload hook. Removes the hook from the list of upload hooks.- Parameters:
hook- the upload hook. Ignored if null.
-
listenToSelectionChange
Description copied from class:JosmActionOverwrite this ifJosmAction.updateEnabledState()should be called when the selection changed. Default is true.- Overrides:
listenToSelectionChangein classJosmAction- Returns:
trueif aDataSelectionListenershould be registered.
-
updateEnabledState
Description copied from class:JosmActionOverride in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. when a layer is removed or added. SeeJosmAction.updateEnabledState(Collection)to respond to changes in the collection of selected primitives. Default behavior is empty.- Overrides:
updateEnabledStatein classJosmAction- See Also:
-
checkPreUploadConditions
Check whether the preconditions are met to upload data from a given layer, if applicable.- Parameters:
layer- layer to check- Returns:
trueif the preconditions are met, or not applicable- See Also:
-
alertUnresolvedConflicts
-
warnUploadDiscouraged
Warn user about discouraged upload, propose to cancel operation.- Parameters:
layer- incriminated layer- Returns:
- true if the user wants to cancel, false if they want to continue
-
checkPreUploadConditions
Check whether the preconditions are met to upload data inapiData. Makes sure upload is allowed, primitives inapiDatadon't participate in conflicts and runs the installedUploadHooks.- Parameters:
layer- the source layer of the data to be uploadedapiData- the data to be uploaded- Returns:
- true, if the preconditions are met; false, otherwise
-
checkPreUploadConditionsAsync
private static Future<Boolean> checkPreUploadConditionsAsync(AbstractModifiableLayer layer, APIDataSet apiData, Consumer<Boolean> onFinish) Check whether the preconditions are met to upload data inapiData. Makes sure upload is allowed, primitives inapiDatadon't participate in conflicts and runs the installedUploadHooks.- Parameters:
layer- the source layer of the data to be uploadedapiData- the data to be uploadedonFinish-trueif the preconditions are met;false, otherwise- Returns:
- A future that completes when the checks are finished
- Since:
- 18752
-
uploadData
Uploads data to the OSM API.- Parameters:
layer- the source layer for the data to uploadapiData- the primitives to be added, updated, or deleted
-
realUploadData
Uploads data to the OSM API.- Parameters:
layer- the source layer for the data to uploadapiData- the primitives to be added, updated, or deleted
-
actionPerformed
-