Changeset 11486 in josm
- Timestamp:
- 2017-01-22T19:14:12+01:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerAction.java
r11334 r11486 37 37 import org.openstreetmap.josm.tools.GBC; 38 38 import org.openstreetmap.josm.tools.ImageProvider; 39 import org.openstreetmap.josm.tools.UncheckedParseException; 39 40 import org.openstreetmap.josm.tools.date.DateUtils; 40 41 … … 44 45 */ 45 46 public abstract class ConvertToDataLayerAction<T extends Layer> extends AbstractAction { 47 /** source layer */ 46 48 protected final transient T layer; 47 49 50 /** 51 * Constructs a new {@code ConvertToDataLayerAction} 52 * @param layer source layer 53 */ 48 54 protected ConvertToDataLayerAction(final T layer) { 49 55 super(tr("Convert to data layer"), ImageProvider.get("converttoosm")); … … 75 81 String timestr = p.getString(GpxConstants.PT_TIME); 76 82 if (timestr != null) { 77 n.setTimestamp(DateUtils.fromString(timestr)); 83 try { 84 n.setTimestamp(DateUtils.fromString(timestr)); 85 } catch (UncheckedParseException e) { 86 Main.warn(e, false); 87 } 78 88 } 79 89 ds.addPrimitive(n); … … 151 161 } 152 162 final DataSet ds = convert(); 153 final OsmDataLayer layer = new OsmDataLayer(ds, tr("Converted from: {0}", this.layer.getName()), null);154 if ( this.layer.getAssociatedFile() != null) {155 layer.setAssociatedFile(new File(this.layer.getAssociatedFile().getParentFile(), this.layer.getAssociatedFile().getName() + ".osm"));163 final OsmDataLayer osmLayer = new OsmDataLayer(ds, tr("Converted from: {0}", layer.getName()), null); 164 if (layer.getAssociatedFile() != null) { 165 osmLayer.setAssociatedFile(new File(layer.getAssociatedFile().getParentFile(), layer.getAssociatedFile().getName() + ".osm")); 156 166 } 157 layer.setUploadDiscouraged(true);158 Main.getLayerManager().addLayer( layer);159 Main.getLayerManager().removeLayer( this.layer);167 osmLayer.setUploadDiscouraged(true); 168 Main.getLayerManager().addLayer(osmLayer); 169 Main.getLayerManager().removeLayer(layer); 160 170 } 161 171 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java
r11094 r11486 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 7 import java.io.IOException; 5 8 6 9 import org.junit.BeforeClass; … … 13 16 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 14 17 import org.openstreetmap.josm.io.GpxReaderTest; 18 import org.xml.sax.SAXException; 15 19 16 20 /** … … 40 44 osm.getNodes().iterator().next().getKeys()); 41 45 } 46 47 /** 48 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/14275">#14275</a> 49 * @throws IOException if an error occurs during reading 50 * @throws SAXException if any XML error occurs 51 */ 52 @Test 53 public void testTicket14275() throws IOException, SAXException { 54 assertNotNull(GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(14275, "1485101437.8189685.gpx"))); 55 } 42 56 } -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r11036 r11486 117 117 */ 118 118 @Test 119 public void testFromDate() throws Exception{119 public void testFromDate() { 120 120 assertEquals("1970-01-01T00:00:00Z", DateUtils.fromDate(new Date(0))); 121 121 assertEquals("1970-01-01T00:00:00.1Z", DateUtils.fromDate(new Date(100)));
Note:
See TracChangeset
for help on using the changeset viewer.