Changeset 12878 in josm for trunk/src/org
- Timestamp:
- 2017-09-19T21:17:54+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/download
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r12846 r12878 55 55 import org.openstreetmap.josm.tools.InputMapUtils; 56 56 import org.openstreetmap.josm.tools.JosmRuntimeException; 57 import org.openstreetmap.josm.tools.ListenerList; 57 58 import org.openstreetmap.josm.tools.Logging; 58 59 import org.openstreetmap.josm.tools.OsmUrlToBounds; … … 84 85 } 85 86 86 protected final transient List<DownloadSource<?>> downloadSources = new ArrayList<>(); 87 protected static final ListenerList<DownloadSourceListener> downloadSourcesListeners = ListenerList.create(); 88 protected static final List<DownloadSource<?>> downloadSources = new ArrayList<>(); 89 static { 90 // add default download sources 91 addDownloadSource(new OSMDownloadSource()); 92 addDownloadSource(new OverpassDownloadSource()); 93 } 94 87 95 protected final transient List<DownloadSelection> downloadSelections = new ArrayList<>(); 88 96 protected final JTabbedPane tpDownloadAreaSelectors = new JTabbedPane(); … … 114 122 protected final JPanel buildMainPanel() { 115 123 mainPanel = new JPanel(new GridBagLayout()); 116 117 // add default download sources118 addDownloadSource(new OSMDownloadSource());119 addDownloadSource(new OverpassDownloadSource());120 124 121 125 // must be created before hook … … 335 339 * @throws JosmRuntimeException If the download source is already added. Note, download sources are 336 340 * compared by their reference. 337 */ 338 public <T> void addDownloadSource(DownloadSource<T> downloadSource) { 341 * @since 12878 342 */ 343 public static <T> void addDownloadSource(DownloadSource<T> downloadSource) { 339 344 if (downloadSources.contains(downloadSource)) { 340 345 throw new JosmRuntimeException("The download source you are trying to add already exists."); … … 342 347 343 348 downloadSources.add(downloadSource); 344 addNewDownloadSourceTab(downloadSource);349 downloadSourcesListeners.fireEvent(l -> l.downloadSourceAdded(downloadSource)); 345 350 } 346 351 … … 581 586 * @since 12706 582 587 */ 583 private static class DownloadSourceTabs extends JTabbedPane { 588 private static class DownloadSourceTabs extends JTabbedPane implements DownloadSourceListener { 584 589 private final List<AbstractDownloadSourcePanel<?>> allPanels = new ArrayList<>(); 590 591 DownloadSourceTabs() { 592 downloadSources.forEach(this::downloadSourceAdded); 593 downloadSourcesListeners.addListener(this); 594 } 585 595 586 596 List<AbstractDownloadSourcePanel<?>> getAllPanels() { … … 631 641 } 632 642 super.insertTab(title, icon, component, tip, index); 643 } 644 645 @Override 646 public void downloadSourceAdded(DownloadSource<?> source) { 647 addPanel(source.createPanel()); 633 648 } 634 649 }
Note:
See TracChangeset
for help on using the changeset viewer.