Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r10972 r11033 31 31 import java.util.Set; 32 32 import java.util.concurrent.CopyOnWriteArrayList; 33 import java.util.concurrent.atomic.AtomicInteger; 33 34 import java.util.regex.Pattern; 34 35 … … 98 99 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 99 100 import org.openstreetmap.josm.io.OsmImporter; 101 import org.openstreetmap.josm.tools.AlphanumComparator; 100 102 import org.openstreetmap.josm.tools.CheckParameterUtil; 101 103 import org.openstreetmap.josm.tools.GBC; … … 198 200 199 201 /** the global counter for created data layers */ 200 private static int dataLayerCounter;202 private static final AtomicInteger dataLayerCounter = new AtomicInteger(); 201 203 202 204 /** … … 206 208 */ 207 209 public static String createNewName() { 208 dataLayerCounter++; 209 return tr("Data Layer {0}", dataLayerCounter); 210 return createLayerName(dataLayerCounter.incrementAndGet()); 211 } 212 213 static String createLayerName(Object arg) { 214 return tr("Data Layer {0}", arg); 210 215 } 211 216 … … 352 357 data.addDataSetListener(MultipolygonCache.getInstance()); 353 358 DataSet.addSelectionListener(this); 359 if (name != null && name.startsWith(createLayerName(""))) { 360 while (AlphanumComparator.getInstance().compare(createLayerName(dataLayerCounter), name) < 0) { 361 dataLayerCounter.incrementAndGet(); 362 } 363 } 354 364 } 355 365 -
trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
r10950 r11033 10 10 import java.io.File; 11 11 12 import org.fest.assertions.Assertions; 12 13 import org.junit.BeforeClass; 13 14 import org.junit.Test; … … 254 255 assertTrue(layer.checkSaveConditions()); 255 256 } 257 258 @Test 259 public void testLayerNameIncreases() throws Exception { 260 final OsmDataLayer layer1 = new OsmDataLayer(new DataSet(), OsmDataLayer.createLayerName(147), null); 261 final OsmDataLayer layer2 = new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null); 262 assertEquals("Data Layer 147", layer1.getName()); 263 assertEquals("Data Layer 148", layer2.getName()); 264 } 256 265 }
Note:
See TracChangeset
for help on using the changeset viewer.