org.openstreetmap.josm.actions
Class UploadAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.openstreetmap.josm.actions.JosmAction
          extended by 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 JosmAction

Action that opens a connection to the osm server and uploads all changes. An 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

Field Summary
private static java.util.LinkedList<UploadHook> uploadHooks
          The list of upload hooks.
 
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields 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
UploadAction()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
protected static void alertUnresolvedConflicts(OsmDataLayer layer)
           
 boolean checkPreUploadConditions(OsmDataLayer layer)
           
 boolean checkPreUploadConditions(OsmDataLayer layer, APIDataSet apiData)
          Check whether the preconditions are met to upload data in apiData.
static void registerUploadHook(UploadHook hook)
          Registers an upload hook.
static void unregisterUploadHook(UploadHook hook)
          Unregisters an upload hook.
protected  void updateEnabledState()
          Refreshes the enabled state
 void uploadData(OsmDataLayer layer, APIDataSet apiData)
          Uploads data to the OSM API.
static boolean warnUploadDiscouraged(OsmDataLayer layer)
          returns true if the user wants to cancel, false if they want to continue
 
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
destroy, getCurrentDataSet, getEditLayer, getShortcut, initEnabledState, installAdapters, setTooltip, updateEnabledState
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uploadHooks

private static final java.util.LinkedList<UploadHook> uploadHooks
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. Be 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.

Constructor Detail

UploadAction

public UploadAction()
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.

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.

updateEnabledState

protected void updateEnabledState()
Refreshes the enabled state

Overrides:
updateEnabledState in class JosmAction
See Also:
JosmAction.updateEnabledState(Collection), JosmAction.initEnabledState()

checkPreUploadConditions

public boolean checkPreUploadConditions(OsmDataLayer layer)

alertUnresolvedConflicts

protected static void alertUnresolvedConflicts(OsmDataLayer layer)

warnUploadDiscouraged

public static final boolean warnUploadDiscouraged(OsmDataLayer layer)
returns true if the user wants to cancel, false if they want to continue


checkPreUploadConditions

public boolean checkPreUploadConditions(OsmDataLayer layer,
                                        APIDataSet apiData)
Check whether the preconditions are met to upload data in apiData. Makes sure upload is allowed, primitives in apiData don't participate in conflicts and runs the installed UploadHooks.

Parameters:
layer - the source layer of the data to be uploaded
apiData - the data to be uploaded
Returns:
true, if the preconditions are met; false, otherwise

uploadData

public void uploadData(OsmDataLayer layer,
                       APIDataSet apiData)
Uploads data to the OSM API.

Parameters:
layer - the source layer for the data to upload
apiData - the primitives to be added, updated, or deleted

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)


JOSM