Changeset 4814 in josm for trunk/src/org
- Timestamp:
- 2012-01-17T22:59:35+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r4800 r4814 22 22 public class OsmImporter extends FileImporter { 23 23 24 protected OsmDataLayer layer; 25 protected Runnable postLayerTask; 24 protected class OsmImporterData { 25 public OsmDataLayer layer; 26 public Runnable postLayerTask; 27 } 26 28 27 29 public OsmImporter() { … … 45 47 46 48 protected void importData(InputStream in, final File associatedFile) throws IllegalDataException { 47 loadLayer(in, associatedFile, associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), NullProgressMonitor.INSTANCE); 48 49 final OsmDataLayer layer = this.layer; 50 final Runnable postLayerTask = this.postLayerTask; 49 final OsmImporterData data = loadLayer(in, associatedFile, 50 associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), NullProgressMonitor.INSTANCE); 51 51 52 52 // FIXME: remove UI stuff from IO subsystem … … 54 54 @Override 55 55 public void run() { 56 Main.main.addLayer( layer);57 postLayerTask.run();58 layer.onPostLoadFromFile();56 Main.main.addLayer(data.layer); 57 data.postLayerTask.run(); 58 data.layer.onPostLoadFromFile(); 59 59 } 60 60 }); … … 65 65 * associatedFile can be null if the stream does not come from a file. 66 66 */ 67 public voidloadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) throws IllegalDataException {67 public OsmImporterData loadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) throws IllegalDataException { 68 68 final DataSet dataSet = parseDataSet(in, progressMonitor); 69 69 if (dataSet == null) { 70 70 throw new IllegalDataException(tr("Invalid dataset")); 71 71 } 72 layer = createLayer(dataSet, associatedFile, layerName); 73 postLayerTask = createPostLayerTask(dataSet, associatedFile, layerName); 72 OsmImporterData data = new OsmImporterData(); 73 data.layer = createLayer(dataSet, associatedFile, layerName); 74 data.postLayerTask = createPostLayerTask(dataSet, associatedFile, layerName, data.layer); 75 return data; 74 76 } 75 77 … … 82 84 } 83 85 84 protected Runnable createPostLayerTask(final DataSet dataSet, final File associatedFile, final String layerName ) {86 protected Runnable createPostLayerTask(final DataSet dataSet, final File associatedFile, final String layerName, final OsmDataLayer layer) { 85 87 return new Runnable() { 86 88 @Override … … 103 105 }; 104 106 } 105 106 public OsmDataLayer getLayer() {107 return layer;108 }109 110 public Runnable getPostLayerTask() {111 return postLayerTask;112 }113 107 }
Note:
See TracChangeset
for help on using the changeset viewer.