- Timestamp:
- 2014-07-22T00:17:42+02:00 (10 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.settings/sf.eclipse.javacc.prefs
r6921 r7326 1 1 CLEAR_CONSOLE=true 2 JAVACC_OPTIONS=- GRAMMAR_ENCODING\=UTF-82 JAVACC_OPTIONS=-JDK_VERSION\=1.7 -GRAMMAR_ENCODING\=UTF-8 3 3 JJDOC_OPTIONS= 4 4 JJTREE_OPTIONS= -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r7048 r7326 104 104 @Override 105 105 public void cancel() { 106 Thread.dumpStack();107 106 canceled = true; 108 107 } … … 179 178 } 180 179 } 181 180 182 181 private void handleException(String dialogTitle, Exception e) { 183 182 Main.error(e); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r7310 r7326 73 73 public AudioMarker syncAudioMarker = null; 74 74 75 /** 76 * Constructs a new {@code MarkerLayer}. 77 * @param indata The GPX data for this layer 78 * @param name The marker layer name 79 * @param associatedFile The associated GPX file 80 * @param fromLayer The associated GPX layer 81 */ 75 82 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) { 76 83 super(name); -
trunk/src/org/openstreetmap/josm/io/NMEAImporter.java
r7033 r7326 20 20 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 21 21 import org.openstreetmap.josm.gui.util.GuiHelper; 22 import org.openstreetmap.josm.io.GpxImporter.GpxImporterData; 22 23 24 /** 25 * File importer allowing to import NMEA-0183 files (*.nmea/nme/nma/log/txt files). 26 * @since 1637 27 */ 23 28 public class NMEAImporter extends FileImporter { 24 29 30 /** 31 * The NMEA file filter (*.nmea *.nme *.nma *.log *.txt files). 32 */ 25 33 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter( 26 34 "nmea,nme,nma,log,txt", "nmea", tr("NMEA-0183 Files") + " (*.nmea *.nme *.nma *.log *.txt)"); … … 42 50 final GpxLayer gpxLayer = new GpxLayer(r.data, fn, true); 43 51 final File fileFinal = file; 44 52 45 53 GuiHelper.runInEDT(new Runnable() { 46 54 @Override … … 88 96 } 89 97 } 98 99 public static GpxImporterData loadLayers(InputStream is, final File associatedFile, 100 final String gpxLayerName, String markerLayerName) throws IOException { 101 final NmeaReader r = new NmeaReader(is); 102 final boolean parsedProperly = r.getNumberOfCoordinates() > 0; 103 r.data.storageFile = associatedFile; 104 return GpxImporter.loadLayers(r.data, parsedProperly, gpxLayerName, markerLayerName); 105 } 90 106 } -
trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionImporter.java
r7033 r7326 13 13 import javax.xml.xpath.XPathFactory; 14 14 15 import org.w3c.dom.Element;16 17 15 import org.openstreetmap.josm.gui.layer.Layer; 18 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 19 17 import org.openstreetmap.josm.io.GpxImporter; 20 18 import org.openstreetmap.josm.io.IllegalDataException; 19 import org.openstreetmap.josm.io.NMEAImporter; 20 import org.w3c.dom.Element; 21 21 22 22 public class GpxTracksSessionImporter implements SessionLayerImporter { … … 38 38 39 39 try (InputStream in = support.getInputStream(fileStr)) { 40 GpxImporter.GpxImporterData importData = GpxImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null, progressMonitor); 41 40 GpxImporter.GpxImporterData importData = null; 41 42 if (NMEAImporter.FILE_FILTER.acceptName(fileStr)) { 43 importData = NMEAImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null); 44 } else { 45 importData = GpxImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null, progressMonitor); 46 } 47 42 48 support.addPostLayersTask(importData.getPostLayerTask()); 43 49 return importData.getGpxLayer(); … … 45 51 46 52 } catch (XPathExpressionException e) { 47 throw new RuntimeException(e);53 throw new IllegalDataException(e); 48 54 } 49 55 } -
trunk/src/org/openstreetmap/josm/io/session/MarkerSessionImporter.java
r7033 r7326 14 14 import javax.xml.xpath.XPathFactory; 15 15 16 import org.w3c.dom.Element;17 18 16 import org.openstreetmap.josm.gui.layer.GpxLayer; 19 17 import org.openstreetmap.josm.gui.layer.Layer; … … 23 21 import org.openstreetmap.josm.io.IllegalDataException; 24 22 import org.openstreetmap.josm.io.session.SessionReader.ImportSupport; 23 import org.w3c.dom.Element; 25 24 26 25 public class MarkerSessionImporter implements SessionLayerImporter { … … 30 29 String version = elem.getAttribute("version"); 31 30 if (!"0.1".equals(version)) { 32 throw new IllegalDataException(tr("Version ''{0}'' of meta data for imagerylayer is not supported. Expected: 0.1", version));31 throw new IllegalDataException(tr("Version ''{0}'' of meta data for marker layer is not supported. Expected: 0.1", version)); 33 32 } 34 33 try { … … 43 42 try (InputStream in = support.getInputStream(fileStr)) { 44 43 GpxImporter.GpxImporterData importData = GpxImporter.loadLayers(in, support.getFile(fileStr), support.getLayerName(), null, progressMonitor); 45 44 46 45 support.addPostLayersTask(importData.getPostLayerTask()); 47 46 48 47 GpxLayer gpxLayer = null; 49 48 List<SessionReader.LayerDependency> deps = support.getLayerDependencies(); … … 54 53 } 55 54 } 56 55 57 56 MarkerLayer markerLayer = importData.getMarkerLayer(); 58 markerLayer.fromLayer = gpxLayer; 59 57 if (markerLayer != null) { 58 markerLayer.fromLayer = gpxLayer; 59 } 60 60 61 return markerLayer; 61 62 } 62 63 } catch (XPathExpressionException e) { 63 throw new RuntimeException(e);64 throw new IllegalDataException(e); 64 65 } 65 66 } -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionImporter.java
r7033 r7326 13 13 import javax.xml.xpath.XPathFactory; 14 14 15 import org.w3c.dom.Element;16 17 15 import org.openstreetmap.josm.gui.layer.Layer; 18 16 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 20 18 import org.openstreetmap.josm.io.OsmImporter; 21 19 import org.openstreetmap.josm.io.session.SessionReader.ImportSupport; 20 import org.w3c.dom.Element; 22 21 23 22 public class OsmDataSessionImporter implements SessionLayerImporter { … … 41 40 try (InputStream in = support.getInputStream(fileStr)) { 42 41 OsmImporter.OsmImporterData importData = importer.loadLayer(in, support.getFile(fileStr), support.getLayerName(), progressMonitor); 43 42 44 43 support.addPostLayersTask(importData.getPostLayerTask()); 45 44 return importData.getLayer(); 46 45 } 47 46 } catch (XPathExpressionException e) { 48 throw new RuntimeException(e);47 throw new IllegalDataException(e); 49 48 } 50 49 } -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r7089 r7326 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.GraphicsEnvironment; 6 7 import java.io.BufferedInputStream; 7 8 import java.io.File; … … 413 414 String type = e.getAttribute("type"); 414 415 SessionLayerImporter imp = getSessionLayerImporter(type); 415 if (imp == null ) {416 if (imp == null && !GraphicsEnvironment.isHeadless()) { 416 417 CancelOrContinueDialog dialog = new CancelOrContinueDialog(); 417 418 dialog.show( … … 427 428 continue; 428 429 } 429 } else {430 } else if (imp != null) { 430 431 importers.put(idx, imp); 431 432 List<LayerDependency> depsImp = new ArrayList<>(); … … 459 460 if (exception != null) { 460 461 Main.error(exception); 461 CancelOrContinueDialog dialog = new CancelOrContinueDialog(); 462 dialog.show( 463 tr("Error loading layer"), 464 tr("<html>Could not load layer {0} ''{1}''.<br>Error is:<br>{2}</html>", idx, name, exception.getMessage()), 465 JOptionPane.ERROR_MESSAGE, 466 progressMonitor 467 ); 468 if (dialog.isCancel()) { 469 progressMonitor.cancel(); 470 return; 471 } else { 472 continue; 462 if (!GraphicsEnvironment.isHeadless()) { 463 CancelOrContinueDialog dialog = new CancelOrContinueDialog(); 464 dialog.show( 465 tr("Error loading layer"), 466 tr("<html>Could not load layer {0} ''{1}''.<br>Error is:<br>{2}</html>", idx, name, exception.getMessage()), 467 JOptionPane.ERROR_MESSAGE, 468 progressMonitor 469 ); 470 if (dialog.isCancel()) { 471 progressMonitor.cancel(); 472 return; 473 } else { 474 continue; 475 } 473 476 } 474 477 } -
trunk/test/config/performance-josm.home
- Property svn:ignore
-
old new 2 2 preferences.xml_backup 3 3 preferences.xml_tmp 4 cache 5 validator
-
- Property svn:ignore
-
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r7081 r7326 13 13 import org.openstreetmap.josm.JOSMFixture; 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.coor.LatLon; 15 16 import org.openstreetmap.josm.data.gpx.GpxData; 17 import org.openstreetmap.josm.data.gpx.WayPoint; 16 18 import org.openstreetmap.josm.data.osm.DataSet; 17 19 import org.openstreetmap.josm.gui.MainApplication; … … 19 21 import org.openstreetmap.josm.gui.layer.Layer; 20 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 21 24 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 22 25 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 23 26 import org.openstreetmap.josm.tools.MultiMap; 27 import org.openstreetmap.josm.tools.Pair; 24 28 25 29 /** … … 106 110 107 111 private OsmDataLayer createOsmLayer() { 108 OsmDataLayer layer = new OsmDataLayer(new DataSet(), null, null);112 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "OSM layer name", null); 109 113 layer.setAssociatedFile(new File("data.osm")); 110 114 return layer; … … 112 116 113 117 private GpxLayer createGpxLayer() { 114 GpxLayer layer = new GpxLayer(new GpxData()); 118 GpxData data = new GpxData(); 119 data.waypoints.add(new WayPoint(new LatLon(42.72665, -0.00747))); 120 data.waypoints.add(new WayPoint(new LatLon(42.72659, -0.00749))); 121 GpxLayer layer = new GpxLayer(data, "GPX layer name"); 115 122 layer.setAssociatedFile(new File("data.gpx")); 116 123 return layer; 124 } 125 126 private MarkerLayer createMarkerLayer(GpxLayer gpx) { 127 return new MarkerLayer(gpx.data, "Marker layer name", gpx.getAssociatedFile(), gpx); 117 128 } 118 129 … … 170 181 testWrite(Collections.<Layer>singletonList(createGpxLayer()), true); 171 182 } 183 184 /** 185 * Tests to write a .joz file containing GPX and marker data. 186 * @throws IOException if any I/O error occurs 187 */ 188 @Test 189 public void testWriteGpxAndMarkerJoz() throws IOException { 190 GpxLayer gpx = createGpxLayer(); 191 testWrite(Pair.toArrayList(new Pair<Layer, Layer>(gpx, createMarkerLayer(gpx))), true); 192 } 172 193 }
Note:
See TracChangeset
for help on using the changeset viewer.