Changeset 95 in josm for src


Ignore:
Timestamp:
2006-04-23T20:40:19+02:00 (18 years ago)
Author:
imi
Message:
  • fixed exception in aborting download
Location:
src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/actions/DownloadAction.java

    r94 r95  
    7272                @Override public void realRun() throws IOException, SAXException {
    7373                        dataSet = reader.parseOsm();
    74                         if (dataSet == null)
    75                                 return;
    76                         if (dataSet.nodes.isEmpty())
    77                                 JOptionPane.showMessageDialog(Main.main, "No data imported.");
    7874                }
    7975
     
    8177                        if (dataSet == null)
    8278                                return; // user cancelled download or error occoured
     79                        if (dataSet.nodes.isEmpty())
     80                                errorMessage = "No data imported.";
    8381                        Layer layer = new OsmDataLayer(dataSet, "Data Layer", false);
    8482                        if (Main.main.getMapFrame() == null)
     
    120118
    121119                @Override protected void cancel() {
     120                        reader.cancel();
    122121                }
    123122        }
  • src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java

    r92 r95  
    3232public abstract class PleaseWaitRunnable implements Runnable {
    3333        public final JDialog pleaseWaitDlg;
    34         private String errorMessage;
     34        public String errorMessage;
    3535
    3636        private final JProgressBar progressBar = new JProgressBar();
  • src/org/openstreetmap/josm/io/OsmServerReader.java

    r92 r95  
    4747         */
    4848        public Collection<Collection<GpsPoint>> parseRawGps() throws IOException, JDOMException {
    49                 String url = Main.pref.get("osm-server.url")+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
    50                 Collection<Collection<GpsPoint>> data = new LinkedList<Collection<GpsPoint>>();
    51                 Collection<GpsPoint> list = new LinkedList<GpsPoint>();
    52                
    53                 for (int i = 0;;++i) {
    54                         Reader r = getReader(url+i);
    55                         if (r == null)
    56                                 break;
    57                         RawGpsReader gpsReader = new RawGpsReader(r);
    58                         Collection<Collection<GpsPoint>> allWays = gpsReader.parse();
    59                         boolean foundSomething = false;
    60                         for (Collection<GpsPoint> t : allWays) {
    61                                 if (!t.isEmpty()) {
    62                                         foundSomething = true;
    63                                         list.addAll(t);
     49                try {
     50                        String url = Main.pref.get("osm-server.url")+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
     51                        Collection<Collection<GpsPoint>> data = new LinkedList<Collection<GpsPoint>>();
     52                        Collection<GpsPoint> list = new LinkedList<GpsPoint>();
     53                       
     54                        for (int i = 0;;++i) {
     55                                Reader r = getReader(url+i);
     56                                if (r == null)
     57                                        break;
     58                                RawGpsReader gpsReader = new RawGpsReader(r);
     59                                Collection<Collection<GpsPoint>> allWays = gpsReader.parse();
     60                                boolean foundSomething = false;
     61                                for (Collection<GpsPoint> t : allWays) {
     62                                        if (!t.isEmpty()) {
     63                                                foundSomething = true;
     64                                                list.addAll(t);
     65                                        }
    6466                                }
     67                                if (!foundSomething)
     68                                        break;
     69                                r.close();
     70                                activeConnection = null;
    6571                        }
    66                         if (!foundSomething)
    67                                 break;
    68                         r.close();
    69                         activeConnection = null;
     72       
     73                        data.add(list);
     74                        return data;
     75                } catch (IOException e) {
     76                        if (cancel)
     77                                return null;
     78                        throw e;
     79                } catch (JDOMException e) {
     80                        throw e;
     81                } catch (Exception e) {
     82                        if (cancel)
     83                                return null;
     84                        if (e instanceof RuntimeException)
     85                                throw (RuntimeException)e;
     86                        throw new RuntimeException(e);
    7087                }
    71 
    72                 data.add(list);
    73                 return data;
    7488        }
    7589
     
    8094         */
    8195        public DataSet parseOsm() throws SAXException, IOException {
    82                 Reader r = getReader(Main.pref.get("osm-server.url")+"/0.3/map?bbox="+lon1+","+lat1+","+lon2+","+lat2);
    83                 if (r == null)
    84                         return null;
    85                 currentAction.setText("Downloading OSM data...");
    86                 DataSet data = OsmReader.parseDataSet(r);
    87                 r.close();
    88                 activeConnection = null;
    89                 return data;
     96                try {
     97                        final Reader r = getReader(Main.pref.get("osm-server.url")+"/0.3/map?bbox="+lon1+","+lat1+","+lon2+","+lat2);
     98                        if (r == null)
     99                                return null;
     100                        currentAction.setText("Downloading OSM data...");
     101                        final DataSet data = OsmReader.parseDataSet(r);
     102                        r.close();
     103                        activeConnection = null;
     104                        return data;
     105                } catch (IOException e) {
     106                        if (cancel)
     107                                return null;
     108                        throw e;
     109                } catch (SAXException e) {
     110                        throw e;
     111                } catch (Exception e) {
     112                        if (cancel)
     113                                return null;
     114                        if (e instanceof RuntimeException)
     115                                throw (RuntimeException)e;
     116                        throw new RuntimeException(e);
     117                }
    90118        }
    91119
Note: See TracChangeset for help on using the changeset viewer.