Changeset 5024 in josm for trunk/src/org


Ignore:
Timestamp:
2012-02-26T15:14:34+01:00 (13 years ago)
Author:
Don-vip
Message:

Extract .osm filename from URL to set the new layer name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r4899 r5024  
    77import java.util.Collection;
    88import java.util.concurrent.Future;
     9import java.util.regex.Matcher;
     10import java.util.regex.Pattern;
    911
    1012import org.openstreetmap.josm.Main;
     
    3537   
    3638    protected OsmDataLayer targetLayer;
     39   
     40    protected String newLayerName = null;
    3741
    3842    protected void rememberDownloadedData(DataSet ds) {
     
    6468                progressMonitor);
    6569        currentBounds = null;
     70        // Extract .osm filename from URL to set the new layer name
     71        Matcher matcher = Pattern.compile("http://.*/(.*\\.osm)").matcher(url);
     72        newLayerName = matcher.matches() ? matcher.group(1) : null;
    6673        return Main.worker.submit(downloadTask);
    6774    }
     
    150157        }
    151158       
     159        protected OsmDataLayer createNewLayer(String layerName) {
     160            if (layerName == null || layerName.isEmpty()) {
     161                layerName = OsmDataLayer.createNewName();
     162            }
     163            return new OsmDataLayer(dataSet, layerName, null);
     164        }
     165       
    152166        protected OsmDataLayer createNewLayer() {
    153             return new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     167            return createNewLayer(null);
    154168        }
    155169
     
    172186                // or it is not clear which layer to merge to
    173187                //
    174                 targetLayer = createNewLayer();
     188                targetLayer = createNewLayer(newLayerName);
    175189                final boolean isDisplayingMapView = Main.isDisplayingMapView();
    176190
Note: See TracChangeset for help on using the changeset viewer.