Ignore:
Timestamp:
2009-07-19T17:38:55+02:00 (15 years ago)
Author:
jttt
Message:

PleaseWait refactoring. Progress is now reported using ProgressMonitor interface, that is available through PleaseWaitRunnable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r1772 r1811  
    88
    99import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.data.gpx.GpxData;
    1011import org.openstreetmap.josm.data.osm.DataSet;
    11 import org.openstreetmap.josm.data.gpx.GpxData;
     12import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1213import org.xml.sax.SAXException;
    1314
     
    3940     *      ways.
    4041     */
    41     public GpxData parseRawGps() throws IOException, SAXException {
    42         Main.pleaseWaitDlg.progress.setValue(0);
    43         Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
     42    public GpxData parseRawGps(ProgressMonitor progressMonitor) throws IOException, SAXException {
     43        progressMonitor.beginTask("", 1);
    4444        try {
     45            progressMonitor.indeterminateSubTask(tr("Contacting OSM Server..."));
    4546            String url = "trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
    4647
     
    4849            GpxData result = null;
    4950            for (int i = 0;!done;++i) {
    50                 Main.pleaseWaitDlg.currentAction.setText(tr("Downloading points {0} to {1}...", i * 5000, ((i + 1) * 5000)));
    51                 InputStream in = getInputStream(url+i, Main.pleaseWaitDlg);
     51                progressMonitor.subTask(tr("Downloading points {0} to {1}...", i * 5000, ((i + 1) * 5000)));
     52                InputStream in = getInputStream(url+i, progressMonitor.createSubTaskMonitor(1, true));
    5253                if (in == null) {
    5354                    break;
    5455                }
     56                progressMonitor.setTicks(0);
    5557                GpxData currentGpx = new GpxReader(in, null).data;
    5658                if (result == null) {
     
    8385                throw (RuntimeException)e;
    8486            throw new RuntimeException(e);
     87        } finally {
     88            progressMonitor.finishTask();
    8589        }
    8690    }
     
    9195     */
    9296    @Override
    93     public DataSet parseOsm() throws OsmTransferException {
     97    public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
     98        progressMonitor.beginTask(tr("Contacting OSM Server..."), 10);
    9499        try {
    95             Main.pleaseWaitDlg.progress.setValue(0);
    96             Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
    97             Main.pleaseWaitDlg.setIndeterminate(true);
    98             final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, Main.pleaseWaitDlg);
    99             Main.pleaseWaitDlg.setIndeterminate(false);
     100            progressMonitor.indeterminateSubTask(null);
     101            final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, progressMonitor.createSubTaskMonitor(9, false));
    100102            if (in == null)
    101103                return null;
    102             Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
    103             final DataSet data = OsmReader.parseDataSet(in,Main.pleaseWaitDlg);
     104            final DataSet data = OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
    104105            in.close();
    105106            activeConnection = null;
     
    117118                return null;
    118119            throw new OsmTransferException(e);
     120        } finally {
     121            progressMonitor.finishTask();
    119122        }
    120123    }
Note: See TracChangeset for help on using the changeset viewer.