Changeset 27696 in osm for applications
- Timestamp:
- 2012-02-02T22:33:52+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mirrored_download/src/mirrored_download/UrlSelectionDialog.java
r27692 r27696 10 10 import java.awt.event.ActionEvent; 11 11 import java.awt.event.ActionListener; 12 import java.io.BufferedReader; 12 13 import java.io.File; 13 14 import java.io.FileInputStream; 14 15 import java.io.FileNotFoundException; 15 16 import java.io.InputStream; 17 import java.io.InputStreamReader; 16 18 import java.io.IOException; 17 19 import java.text.DecimalFormat; 18 20 import java.text.Format; 21 import java.util.ArrayList; 22 import java.util.Collection; 19 23 import java.util.Collections; 20 24 import java.util.Iterator; … … 60 64 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 61 65 import org.openstreetmap.josm.io.GpxReader; 66 import org.openstreetmap.josm.io.MirroredInputStream; 67 import org.openstreetmap.josm.tools.Utils; 62 68 63 69 import org.xml.sax.SAXException; … … 70 76 71 77 public UrlSelectionDialog() { 72 73 78 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 74 79 jDialog = new JDialog(frame, tr("Select OSM mirror URL"), false); … … 99 104 cbSelectUrl.setEditable(true); 100 105 101 cbSelectUrl.addItem("http://overpass.osm.rambler.ru/cgi/xapi?"); 102 cbSelectUrl.addItem("http://overpass-api.de/api/xapi?"); 106 for (String url: getURLs()) { 107 cbSelectUrl.addItem(url); 108 } 103 109 104 110 cbSelectUrl.setActionCommand("selectURL"); … … 116 122 jDialog.pack(); 117 123 jDialog.setLocationRelativeTo(frame); 124 } 125 126 private Collection<String> getURLs() { 127 // List can be edited at http://josm.openstreetmap.de/wiki/MirroredDownloadInfo 128 String src = Main.pref.get("plugin.mirrored_download.url-src", "http://josm.openstreetmap.de/mirrored_download_info"); 129 Collection<String> urls = new ArrayList<String>(); 130 InputStream in = null; 131 try { 132 in = new MirroredInputStream(src, 24*60*60); 133 BufferedReader reader = new BufferedReader(new InputStreamReader(in)); 134 String line = null; 135 while ((line = reader.readLine()) != null) { 136 line = line.trim(); 137 if (!line.equals("")) { 138 urls.add(line); 139 } 140 } 141 } catch (IOException e) { 142 e.printStackTrace(); 143 } 144 Utils.close(in); 145 for (String url : Main.pref.getCollection("plugin.mirrored_download.custom-urls")) { 146 urls.add(url); 147 } 148 return urls; 118 149 } 119 150
Note:
See TracChangeset
for help on using the changeset viewer.