Class 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
    • 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.

    • Constructor Detail

      • UploadAction

        public UploadAction()
        Constructs a new 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.
      • 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.
      • 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 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
      • 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 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
        onFinish - 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 upload
        apiData - 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 upload
        apiData - the primitives to be added, updated, or deleted
      • actionPerformed

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