- Timestamp:
- 2013-04-14T19:10:11+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java
r5856 r5859 161 161 protected void cancel() { 162 162 System.out.println("Cancel!"); 163 //OsmApi.getOsmApi().cancel();164 // fix #8601 : could not cancel when server is extremely slow165 163 if (reader!=null) reader.cancel(); 166 164 canceled = true; -
trunk/src/org/openstreetmap/josm/io/OsmBzip2Importer.java
r5361 r5859 22 22 @Override 23 23 public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { 24 importData(getBZip2InputStream(new FileInputStream(file)), file );24 importData(getBZip2InputStream(new FileInputStream(file)), file, progressMonitor); 25 25 } 26 26 } -
trunk/src/org/openstreetmap/josm/io/OsmChangeImporter.java
r5452 r5859 38 38 39 39 if (file.getName().endsWith(".osc")) { 40 importData(in, file );40 importData(in, file, progressMonitor); 41 41 } else if (file.getName().endsWith(".gz")) { 42 importData(getGZipInputStream(in), file );42 importData(getGZipInputStream(in), file, progressMonitor); 43 43 } else { 44 importData(getBZip2InputStream(in), file );44 importData(getBZip2InputStream(in), file, progressMonitor); 45 45 } 46 46 … … 52 52 53 53 protected void importData(InputStream in, final File associatedFile) throws IllegalDataException { 54 final DataSet dataSet = OsmChangeReader.parseDataSet(in, NullProgressMonitor.INSTANCE); 54 importData(in, associatedFile, NullProgressMonitor.INSTANCE); 55 } 56 57 protected void importData(InputStream in, final File associatedFile, ProgressMonitor progressMonitor) throws IllegalDataException { 58 final DataSet dataSet = OsmChangeReader.parseDataSet(in, progressMonitor); 55 59 final OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile); 56 60 addDataLayer(dataSet, layer, associatedFile.getPath()); -
trunk/src/org/openstreetmap/josm/io/OsmGzipImporter.java
r5361 r5859 22 22 @Override 23 23 public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { 24 importData(getGZipInputStream(new FileInputStream(file)), file );24 importData(getGZipInputStream(new FileInputStream(file)), file, progressMonitor); 25 25 } 26 26 } -
trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r5361 r5859 52 52 } 53 53 54 /** 55 * Imports OSM data from file @param file 56 * This method supports progress monitoring and canceling by using @param progressMonitor 57 */ 54 58 @Override 55 59 public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException { … … 57 61 try { 58 62 in = new FileInputStream(file); 59 importData(in, file );63 importData(in, file, progressMonitor); 60 64 } catch (FileNotFoundException e) { 61 65 e.printStackTrace(); … … 68 72 } 69 73 74 /** 75 * Imports OSM data from stream @param in , sitle will be generated from name of file @param associatedFile 76 */ 70 77 protected void importData(InputStream in, final File associatedFile) throws IllegalDataException { 78 importData(in, associatedFile, NullProgressMonitor.INSTANCE); 79 } 80 81 /** 82 * Imports OSM data from stream @param in , layer name will be generated from name of file @param associatedFile 83 * This method supports progress monitoring and canceling by using @param progressMonitor 84 */ 85 protected void importData(InputStream in, final File associatedFile, ProgressMonitor pm) throws IllegalDataException { 71 86 final OsmImporterData data = loadLayer(in, associatedFile, 72 associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), NullProgressMonitor.INSTANCE);87 associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), pm); 73 88 74 89 // FIXME: remove UI stuff from IO subsystem -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r5326 r5859 50 50 protected XMLStreamReader parser; 51 51 52 protected boolean cancel; 53 52 54 /** Used by plugins to register themselves as data postprocessors. */ 53 55 public static ArrayList<OsmServerReadPostprocessor> postprocessors; … … 128 130 while (true) { 129 131 int event = parser.next(); 132 133 if (cancel) { 134 cancel = false; 135 throwException(tr("Reading was canceled")); 136 } 137 130 138 if (event == XMLStreamConstants.START_ELEMENT) { 131 139 if (parser.getLocalName().equals("bounds")) { … … 561 569 progressMonitor = NullProgressMonitor.INSTANCE; 562 570 } 571 ProgressMonitor.CancelListener cancelListener = new ProgressMonitor.CancelListener() { 572 @Override public void operationCanceled() { 573 cancel = true; 574 } 575 }; 576 progressMonitor.addCancelListener(cancelListener); 563 577 CheckParameterUtil.ensureParameterNotNull(source, "source"); 564 578 try { … … 603 617 } finally { 604 618 progressMonitor.finishTask(); 619 progressMonitor.removeCancelListener(cancelListener); 605 620 } 606 621 }
Note:
See TracChangeset
for help on using the changeset viewer.