001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.download; 003 004import javax.swing.Icon; 005import javax.swing.JCheckBox; 006import javax.swing.event.ChangeListener; 007 008import org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask; 009import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 010import org.openstreetmap.josm.data.Bounds; 011import org.openstreetmap.josm.data.preferences.BooleanProperty; 012 013/** 014 * An interface to allow arbitrary download sources and types in the primary 015 * download window of JOSM 016 * 017 * @since 16503 018 */ 019public interface IDownloadSourceType { 020 021 /** 022 * Returns the checkbox to be added to the UI. 023 * @return The checkbox to be added to the UI 024 */ 025 default JCheckBox getCheckBox() { 026 return getCheckBox(null); 027 } 028 029 /** 030 * Returns the checkbox to be added to the UI. 031 * @param checkboxChangeListener The listener for checkboxes (may be {@code null}) 032 * @return The checkbox to be added to the UI 033 */ 034 JCheckBox getCheckBox(ChangeListener checkboxChangeListener); 035 036 /** 037 * Returns the icon to be added to the UI. 038 * @return The icon to be added to the UI 039 */ 040 default Icon getIcon() { 041 return null; 042 } 043 044 /** 045 * Returns the download task class which will be getting the data. 046 * @return The {@link DownloadTask} class which will be getting the data 047 */ 048 Class<? extends AbstractDownloadTask<?>> getDownloadClass(); 049 050 /** 051 * Determines the last state of the download type. 052 * @return The boolean indicating the last state of the download type 053 */ 054 default boolean isEnabled() { 055 return getBooleanProperty().get(); 056 } 057 058 /** 059 * Returns the boolean property for this particular download type. 060 * @return The boolean property for this particular download type 061 */ 062 BooleanProperty getBooleanProperty(); 063 064 /** 065 * Check if the area is too large for the current IDownloadSourceType 066 * 067 * @param bound The bound that will be downloaded 068 * @return {@code true} if we definitely cannot download the area; 069 */ 070 boolean isDownloadAreaTooLarge(Bounds bound); 071}