001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.layer;
003
004import org.openstreetmap.josm.gui.io.AbstractIOTask;
005import org.openstreetmap.josm.gui.io.AbstractUploadDialog;
006import org.openstreetmap.josm.gui.progress.ProgressMonitor;
007
008/**
009 * Interface for layers that can upload data.
010 * @see DownloadFromServer
011 * @since 9751
012 */
013public interface UploadToServer {
014
015    /**
016     * Determines if the layer is able to upload data and implements the
017     * {@code UploadToServer} interface.  A layer that implements the
018     * {@code UploadToServer} interface must return {@code true}.
019     *
020     * @return {@code true} if the layer is able to upload data; {@code false}, otherwise
021     */
022    boolean isUploadable();
023
024    /**
025     * Determines if the data managed by this layer needs to be uploaded to
026     * the server because it contains modified data.
027     *
028     * @return {@code true} if the data managed by this layer needs to be
029     *         uploaded to the server because it contains modified data;
030     *         {@code false}, otherwise
031     */
032    boolean requiresUploadToServer();
033
034    /**
035     * Determines if upload of data managed by this layer is discouraged.
036     * This feature allows to use "private" data layers.
037     *
038     * @return {@code true} if upload is discouraged for this layer; {@code false}, otherwise
039     */
040    boolean isUploadDiscouraged();
041
042    /**
043     * Determines if upload of data managed by this layer is currently in progress.
044     *
045     * @return {@code true} if upload is in progress
046     * @since 13434
047     */
048    boolean isUploadInProgress();
049
050    /**
051     * Initializes the layer after a successful upload to the server.
052     */
053    void onPostUploadToServer();
054
055    /**
056     * Creates a new {@code AbstractIOTask} for uploading data.
057     * @param monitor The progress monitor
058     * @return a new {@code AbstractIOTask} for uploading data, or {@code null} if not applicable
059     */
060    AbstractIOTask createUploadTask(ProgressMonitor monitor);
061
062    /**
063     * Returns the upload dialog for this layer.
064     * @return the upload dialog for this layer, or {@code null} if not applicable
065     */
066    AbstractUploadDialog getUploadDialog();
067}