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:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,Destroyable
public class UploadAction extends AbstractUploadAction
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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
IS_ASYNC_UPLOAD_ENABLED
private static java.util.List<UploadHook>
LATE_UPLOAD_HOOKS
private static java.util.List<UploadHook>
UPLOAD_HOOKS
The list of upload hooks.-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Constructor Description UploadAction()
Constructs a newUploadAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
protected static void
alertUnresolvedConflicts(OsmDataLayer layer)
static boolean
checkPreUploadConditions(AbstractModifiableLayer layer)
Check whether the preconditions are met to upload data from a given layer, if applicable.static boolean
checkPreUploadConditions(AbstractModifiableLayer layer, APIDataSet apiData)
Check whether the preconditions are met to upload data inapiData
.private static java.util.concurrent.Future<java.lang.Boolean>
checkPreUploadConditionsAsync(AbstractModifiableLayer layer, APIDataSet apiData, java.util.function.Consumer<java.lang.Boolean> onFinish)
Check whether the preconditions are met to upload data inapiData
.protected boolean
listenToSelectionChange()
Overwrite this ifJosmAction.updateEnabledState()
should be called when the selection changed.private static void
realUploadData(OsmDataLayer layer, APIDataSet apiData)
Uploads data to the OSM API.static void
registerUploadHook(UploadHook hook)
Registers an upload hook.static void
registerUploadHook(UploadHook hook, boolean late)
Registers an upload hook.static void
unregisterUploadHook(UploadHook hook)
Unregisters an upload hook.protected void
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.void
uploadData(OsmDataLayer layer, APIDataSet apiData)
Uploads data to the OSM API.static boolean
warnUploadDiscouraged(AbstractModifiableLayer layer)
Warn user about discouraged upload, propose to cancel operation.-
Methods inherited from class org.openstreetmap.josm.actions.AbstractUploadAction
buildLayerChangeAdapter
-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, setHelpId, setToolbarId, setTooltip, updateEnabledState, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
UPLOAD_HOOKS
private static final java.util.List<UploadHook> 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
private static final java.util.List<UploadHook> LATE_UPLOAD_HOOKS
-
IS_ASYNC_UPLOAD_ENABLED
private static final java.lang.String IS_ASYNC_UPLOAD_ENABLED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UploadAction
public UploadAction()
Constructs a newUploadAction
.
-
-
Method Detail
-
registerUploadHook
public static void registerUploadHook(UploadHook hook)
Registers an upload hook. Adds the hook at the first position of the upload hooks.- Parameters:
hook
- the upload hook. Ignored if null.
-
registerUploadHook
public static void registerUploadHook(UploadHook hook, boolean late)
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
public static void unregisterUploadHook(UploadHook hook)
Unregisters an upload hook. Removes the hook from the list of upload hooks.- Parameters:
hook
- the upload hook. Ignored if null.
-
listenToSelectionChange
protected boolean listenToSelectionChange()
Description copied from class:JosmAction
Overwrite this ifJosmAction.updateEnabledState()
should be called when the selection changed. Default is true.- Overrides:
listenToSelectionChange
in classJosmAction
- Returns:
true
if aDataSelectionListener
should be registered.
-
updateEnabledState
protected void updateEnabledState()
Description copied from class:JosmAction
Override 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:
updateEnabledState
in classJosmAction
- See Also:
JosmAction.updateEnabledState(Collection)
,JosmAction.initEnabledState()
,JosmAction.listenToLayerChange()
-
checkPreUploadConditions
public static boolean checkPreUploadConditions(AbstractModifiableLayer layer)
Check whether the preconditions are met to upload data from a given layer, if applicable.- Parameters:
layer
- layer to check- Returns:
true
if the preconditions are met, or not applicable- See Also:
checkPreUploadConditions(AbstractModifiableLayer, APIDataSet)
-
alertUnresolvedConflicts
protected static void alertUnresolvedConflicts(OsmDataLayer layer)
-
warnUploadDiscouraged
public static boolean warnUploadDiscouraged(AbstractModifiableLayer layer)
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
public static boolean checkPreUploadConditions(AbstractModifiableLayer layer, APIDataSet apiData)
Check whether the preconditions are met to upload data inapiData
. Makes sure upload is allowed, primitives inapiData
don't participate in conflicts and runs the installedUploadHook
s.- 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 java.util.concurrent.Future<java.lang.Boolean> checkPreUploadConditionsAsync(AbstractModifiableLayer layer, APIDataSet apiData, java.util.function.Consumer<java.lang.Boolean> onFinish)
Check whether the preconditions are met to upload data inapiData
. Makes sure upload is allowed, primitives inapiData
don't participate in conflicts and runs the installedUploadHook
s.- Parameters:
layer
- the source layer of the data to be uploadedapiData
- the data to be uploadedonFinish
-true
if the preconditions are met;false
, otherwise- Returns:
- A future that completes when the checks are finished
- Since:
- 18752
-
uploadData
public void uploadData(OsmDataLayer layer, APIDataSet apiData)
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
private static void realUploadData(OsmDataLayer layer, APIDataSet apiData)
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
public void actionPerformed(java.awt.event.ActionEvent e)
-
-