- Timestamp:
- 2016-02-06T22:04:49+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/NoteImporter.java
r8895 r9746 37 37 } 38 38 try (InputStream is = Compression.getUncompressedFileInputStream(file)) { 39 final List<Note> fileNotes = new NoteReader(is).parse(); 40 41 List<NoteLayer> noteLayers = null; 42 if (Main.map != null) { 43 noteLayers = Main.map.mapView.getLayersOfType(NoteLayer.class); 44 } 45 if (noteLayers != null && !noteLayers.isEmpty()) { 46 noteLayers.get(0).getNoteData().addNotes(fileNotes); 47 } else { 39 final NoteLayer layer = loadLayer(is, file, file.getName(), progressMonitor); 40 if (!Main.map.mapView.hasLayer(layer)) { 48 41 GuiHelper.runInEDT(new Runnable() { 49 42 @Override 50 43 public void run() { 51 Main.main.addLayer( new NoteLayer(fileNotes, file.getName()));44 Main.main.addLayer(layer); 52 45 } 53 46 }); … … 59 52 } 60 53 } 54 55 /** 56 * Load note layer from InputStream. 57 * @param in input stream 58 * @param associatedFile filename of data (can be <code>null</code> if the stream does not come from a file) 59 * @param layerName name of generated layer 60 * @param progressMonitor handler for progress monitoring and canceling 61 * @return note layer 62 * @throws IOException 63 * @throws SAXException 64 * @since 9746 65 */ 66 public NoteLayer loadLayer(InputStream in, final File associatedFile, final String layerName, ProgressMonitor progressMonitor) 67 throws SAXException, IOException { 68 final List<Note> fileNotes = new NoteReader(in).parse(); 69 List<NoteLayer> noteLayers = null; 70 if (Main.map != null) { 71 noteLayers = Main.map.mapView.getLayersOfType(NoteLayer.class); 72 } 73 final NoteLayer layer; 74 if (noteLayers != null && !noteLayers.isEmpty()) { 75 layer = noteLayers.get(0); 76 layer.getNoteData().addNotes(fileNotes); 77 } else { 78 layer = new NoteLayer(fileNotes, associatedFile != null ? associatedFile.getName() : tr("Notes")); 79 } 80 return layer; 81 } 61 82 } -
trunk/src/org/openstreetmap/josm/io/session/GenericSessionExporter.java
r9669 r9746 221 221 } 222 222 223 protected abstract void addDataFile(OutputStream out) ;223 protected abstract void addDataFile(OutputStream out) throws IOException; 224 224 } -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r9646 r9746 75 75 registerSessionLayerImporter("geoimage", GeoImageSessionImporter.class); 76 76 registerSessionLayerImporter("markers", MarkerSessionImporter.class); 77 registerSessionLayerImporter("osm-notes", NoteSessionImporter.class); 77 78 } 78 79 -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r9455 r9746 35 35 import org.openstreetmap.josm.gui.layer.GpxLayer; 36 36 import org.openstreetmap.josm.gui.layer.Layer; 37 import org.openstreetmap.josm.gui.layer.NoteLayer; 37 38 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 38 39 import org.openstreetmap.josm.gui.layer.TMSLayer; … … 71 72 registerSessionLayerExporter(GeoImageLayer.class, GeoImageSessionExporter.class); 72 73 registerSessionLayerExporter(MarkerLayer.class, MarkerSessionExporter.class); 74 registerSessionLayerExporter(NoteLayer.class, NoteSessionExporter.class); 73 75 } 74 76 -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r9739 r9746 80 80 */ 81 81 public static synchronized long tsFromString(String str) throws UncheckedParseException { 82 // "2007-07-25T09:26:24{Z|{+|-}01 :00}"82 // "2007-07-25T09:26:24{Z|{+|-}01[:00]}" 83 83 if (checkLayout(str, "xxxx-xx-xxTxx:xx:xxZ") || 84 84 checkLayout(str, "xxxx-xx-xxTxx:xx:xx") || 85 85 checkLayout(str, "xxxx:xx:xx xx:xx:xx") || 86 86 checkLayout(str, "xxxx-xx-xx xx:xx:xx UTC") || 87 checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx") || 88 checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx") || 87 89 checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx:00") || 88 90 checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx:00")) { … … 97 99 c.set(Calendar.MILLISECOND, 0); 98 100 99 if (str.length() == 2 5) {101 if (str.length() == 22 || str.length() == 25) { 100 102 int plusHr = parsePart2(str, 20); 101 103 int mul = str.charAt(19) == '+' ? -3600000 : 3600000;
Note:
See TracChangeset
for help on using the changeset viewer.