Changeset 4686 in josm for trunk/src/org


Ignore:
Timestamp:
2011-12-21T20:17:44+01:00 (9 years ago)
Author:
Don-vip
Message:

fix layer name creation of layers without associated files + allow plugins to reuse code portions of loadLayer()

File:
1 edited

Legend:

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

    r4668 r4686  
    4545
    4646    protected void importData(InputStream in, final File associatedFile) throws IllegalDataException {
    47         loadLayer(in, associatedFile, associatedFile.getName(), NullProgressMonitor.INSTANCE);
     47        loadLayer(in, associatedFile, associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName(), NullProgressMonitor.INSTANCE);
    4848        // FIXME: remove UI stuff from IO subsystem
    4949        Runnable uiStuff = new Runnable() {
     
    6868    public void loadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) throws IllegalDataException {
    6969        final DataSet dataSet = OsmReader.parseDataSet(in, progressMonitor);
    70         String name = associatedFile == null ? OsmDataLayer.createNewName() : associatedFile.getName();
    71         layer = new OsmDataLayer(dataSet, layerName, associatedFile);
    72         postLayerTask = new Runnable() {
     70        layer = createLayer(dataSet, associatedFile, layerName);
     71        postLayerTask = createPostLayerTask(dataSet, associatedFile, layerName);
     72    }
     73   
     74    protected OsmDataLayer createLayer(final DataSet dataSet, final File associatedFile, final String layerName) {
     75        return new OsmDataLayer(dataSet, layerName, associatedFile);
     76    }
     77   
     78    protected Runnable createPostLayerTask(final DataSet dataSet, final File associatedFile, final String layerName) {
     79        return new Runnable() {
    7380            @Override
    7481            public void run() {
Note: See TracChangeset for help on using the changeset viewer.