001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.download;
003
004/**
005 * Defines an interface for different download sources.
006 * <p>
007 * Plugins may implement this to provide new download sources to the main download dialog.
008 * @param <T> The type of the data that a download source uses.
009 * @since 12652
010 */
011public interface DownloadSource<T> {
012
013    /**
014     * Creates a panel with GUI specific for the download source.
015     * @param dialog the parent download dialog, as {@code DownloadDialog.getInstance()} might not be initialized yet
016     * @return Returns {@link AbstractDownloadSourcePanel}.
017     * @since 12900
018     */
019    AbstractDownloadSourcePanel<T> createPanel(DownloadDialog dialog);
020
021    /**
022     * Downloads the data.
023     * @param data The required data for the download source.
024     * @param settings The global settings of the download dialog, see {@link DownloadDialog}.
025     */
026    void doDownload(T data, DownloadSettings settings);
027
028    /**
029     * Returns a string representation of this download source.
030     * @return A string representation of this download source.
031     */
032    String getLabel();
033
034    /**
035     * Defines whether this download source should be visible only in the expert mode.
036     * @return Returns {@code true} if the download source should be visible only in the
037     * expert mode, {@code false} otherwise.
038     */
039    boolean onlyExpert();
040}