Index: trunk/.classpath
===================================================================
--- trunk/.classpath (revision 12877)
+++ trunk/.classpath (revision 12878)
@@ -31,5 +31,5 @@
-
+
Index: trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java (revision 12877)
+++ trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java (revision 12878)
@@ -55,4 +55,5 @@
import org.openstreetmap.josm.tools.InputMapUtils;
import org.openstreetmap.josm.tools.JosmRuntimeException;
+import org.openstreetmap.josm.tools.ListenerList;
import org.openstreetmap.josm.tools.Logging;
import org.openstreetmap.josm.tools.OsmUrlToBounds;
@@ -84,5 +85,12 @@
}
- protected final transient List> downloadSources = new ArrayList<>();
+ protected static final ListenerList downloadSourcesListeners = ListenerList.create();
+ protected static final List> downloadSources = new ArrayList<>();
+ static {
+ // add default download sources
+ addDownloadSource(new OSMDownloadSource());
+ addDownloadSource(new OverpassDownloadSource());
+ }
+
protected final transient List downloadSelections = new ArrayList<>();
protected final JTabbedPane tpDownloadAreaSelectors = new JTabbedPane();
@@ -114,8 +122,4 @@
protected final JPanel buildMainPanel() {
mainPanel = new JPanel(new GridBagLayout());
-
- // add default download sources
- addDownloadSource(new OSMDownloadSource());
- addDownloadSource(new OverpassDownloadSource());
// must be created before hook
@@ -335,6 +339,7 @@
* @throws JosmRuntimeException If the download source is already added. Note, download sources are
* compared by their reference.
- */
- public void addDownloadSource(DownloadSource downloadSource) {
+ * @since 12878
+ */
+ public static void addDownloadSource(DownloadSource downloadSource) {
if (downloadSources.contains(downloadSource)) {
throw new JosmRuntimeException("The download source you are trying to add already exists.");
@@ -342,5 +347,5 @@
downloadSources.add(downloadSource);
- addNewDownloadSourceTab(downloadSource);
+ downloadSourcesListeners.fireEvent(l -> l.downloadSourceAdded(downloadSource));
}
@@ -581,6 +586,11 @@
* @since 12706
*/
- private static class DownloadSourceTabs extends JTabbedPane {
+ private static class DownloadSourceTabs extends JTabbedPane implements DownloadSourceListener {
private final List> allPanels = new ArrayList<>();
+
+ DownloadSourceTabs() {
+ downloadSources.forEach(this::downloadSourceAdded);
+ downloadSourcesListeners.addListener(this);
+ }
List> getAllPanels() {
@@ -631,4 +641,9 @@
}
super.insertTab(title, icon, component, tip, index);
+ }
+
+ @Override
+ public void downloadSourceAdded(DownloadSource> source) {
+ addPanel(source.createPanel());
}
}
Index: trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceListener.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceListener.java (revision 12878)
+++ trunk/src/org/openstreetmap/josm/gui/download/DownloadSourceListener.java (revision 12878)
@@ -0,0 +1,15 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.download;
+
+/**
+ * Listener to get notified about changes in the list of download sources.
+ * @since 12878
+ */
+interface DownloadSourceListener {
+
+ /**
+ * Called when a download source has been added.
+ * @param source the new added download source.
+ */
+ void downloadSourceAdded(DownloadSource> source);
+}