- Timestamp:
- 2012-09-05T22:15:03+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
r5438 r5501 51 51 private boolean zipRequired; 52 52 53 /**54 * Construct the action with "Save" as label.55 */56 53 public SessionSaveAsAction() { 57 54 super(tr("Save Session As..."), "save_as", tr("Save the current session to a new file."), null, true, "save_as-session", true); … … 72 69 for (Layer l : layers) { 73 70 SessionLayerExporter ex = exporters.get(l); 74 if (ex .requiresZip()) {71 if (ex != null && ex.requiresZip()) { 75 72 zipRequired = true; 76 73 break; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r5494 r5501 124 124 GpxImporterData layers = GpxImporter.loadLayers(rawData, reader.isGpxParsedProperly(), name, tr("Markers from {0}", name)); 125 125 126 GpxLayer gpxLayer = addOrMergeLayer(layers.g pxLayer, findGpxMergeLayer());127 addOrMergeLayer(layers. markerLayer, findMarkerMergeLayer(gpxLayer));126 GpxLayer gpxLayer = addOrMergeLayer(layers.getGpxLayer(), findGpxMergeLayer()); 127 addOrMergeLayer(layers.getMarkerLayer(), findMarkerMergeLayer(gpxLayer)); 128 128 129 layers. postLayerTask.run();129 layers.getPostLayerTask().run(); 130 130 } 131 131 -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r5481 r5501 170 170 } 171 171 172 173 172 /** 174 173 * Plugins can add their Marker creation stuff at the bottom or top of this list … … 210 209 } 211 210 212 213 211 if (url == null) { 214 212 String symbolName = wpt.getString("symbol"); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r5481 r5501 68 68 private Marker currentMarker; 69 69 70 @Deprecated 71 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer, boolean addMouseHandlerInConstructor) { 72 this(indata, name, associatedFile, fromLayer); 73 } 74 70 75 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) { 71 this(indata, name, associatedFile, fromLayer, true);72 }73 74 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer, boolean addMouseHandlerInConstructor) {75 76 super(name); 76 77 this.setAssociatedFile(associatedFile); … … 105 106 } 106 107 } 107 108 if (addMouseHandlerInConstructor) { 109 SwingUtilities.invokeLater(new Runnable(){ 110 public void run() { 111 addMouseHandler(); 112 } 113 }); 114 } 115 } 116 117 public void addMouseHandler() { 108 } 109 110 @Override 111 public void hookUpMapView() { 118 112 Main.map.mapView.addMouseListener(new MouseAdapter() { 119 113 @Override public void mousePressed(MouseEvent e) { -
trunk/src/org/openstreetmap/josm/io/GpxImporter.java
r5494 r5501 40 40 * The imported GPX layer. May be null if no GPX data. 41 41 */ 42 p ublicGpxLayer gpxLayer;42 private GpxLayer gpxLayer; 43 43 /** 44 44 * The imported marker layer. May be null if no marker. 45 45 */ 46 p ublicMarkerLayer markerLayer;46 private MarkerLayer markerLayer; 47 47 /** 48 48 * The task to run after GPX and/or marker layer has been added to MapView. 49 49 */ 50 public Runnable postLayerTask; 50 private Runnable postLayerTask; 51 52 public GpxImporterData(GpxLayer gpxLayer, MarkerLayer markerLayer, Runnable postLayerTask) { 53 this.gpxLayer = gpxLayer; 54 this.markerLayer = markerLayer; 55 this.postLayerTask = postLayerTask; 56 } 57 58 public GpxLayer getGpxLayer() { 59 return gpxLayer; 60 } 61 62 public MarkerLayer getMarkerLayer() { 63 return markerLayer; 64 } 65 66 public Runnable getPostLayerTask() { 67 return postLayerTask; 68 } 51 69 } 52 70 … … 108 126 * @see #addLayers 109 127 */ 110 public static GpxImporterData loadLayers(final GpxData data, final boolean parsedProperly, final String gpxLayerName, String markerLayerName) { 111 final GpxImporterData result = new GpxImporterData(); 128 public static GpxImporterData loadLayers(final GpxData data, final boolean parsedProperly, 129 final String gpxLayerName, String markerLayerName) { 130 GpxLayer gpxLayer = null; 131 MarkerLayer markerLayer = null; 112 132 if (data.hasRoutePoints() || data.hasTrackPoints()) { 113 result.gpxLayer = new GpxLayer(data, gpxLayerName, data.storageFile != null);133 gpxLayer = new GpxLayer(data, gpxLayerName, data.storageFile != null); 114 134 } 115 135 if (Main.pref.getBoolean("marker.makeautomarkers", true) && !data.waypoints.isEmpty()) { 116 result.markerLayer = new MarkerLayer(data, markerLayerName, data.storageFile, result.gpxLayer, false);117 if ( result.markerLayer.data.size() == 0) {118 result.markerLayer = null;136 markerLayer = new MarkerLayer(data, markerLayerName, data.storageFile, gpxLayer); 137 if (markerLayer.data.isEmpty()) { 138 markerLayer = null; 119 139 } 120 140 } 121 result.postLayerTask = new Runnable() {141 Runnable postLayerTask = new Runnable() { 122 142 @Override 123 143 public void run() { 124 if (result.markerLayer != null) {125 result.markerLayer.addMouseHandler();126 }127 144 if (!parsedProperly) { 128 145 String msg; … … 138 155 } 139 156 }; 140 return result; 157 return new GpxImporterData(gpxLayer, markerLayer, postLayerTask); 158 } 159 160 public static GpxImporterData loadLayers(InputStream is, final File associatedFile, 161 final String gpxLayerName, String markerLayerName, ProgressMonitor progressMonitor) throws IOException { 162 try { 163 final GpxReader r = new GpxReader(is); 164 final boolean parsedProperly = r.parse(true); 165 r.data.storageFile = associatedFile; 166 return loadLayers(r.data, parsedProperly, gpxLayerName, markerLayerName); 167 } catch (SAXException e) { 168 e.printStackTrace(); 169 throw new IOException(tr("Parsing data for layer ''{0}'' failed", gpxLayerName)); 170 } 141 171 } 142 172 } -
trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java
r5025 r5501 49 49 50 50 private OsmDataLayer layer; 51 private JRadioButton link, include; 52 private JCheckBox export; 51 53 52 54 public OsmDataSessionExporter(OsmDataLayer layer) { … … 55 57 56 58 public OsmDataSessionExporter() { 57 }58 59 public OsmDataSessionExporter newInstance(OsmDataLayer layer) {60 return new OsmDataSessionExporter(layer);61 59 } 62 60 … … 69 67 public LayerSaveAction() { 70 68 putValue(SMALL_ICON, new ImageProvider("save").setWidth(16).get()); 71 putValue(SHORT_DESCRIPTION, tr("Layer contains unsaved data - save to file.")); 69 putValue(SHORT_DESCRIPTION, layer.requiresSaveToFile() ? 70 tr("Layer contains unsaved data - save to file.") : 71 tr("Layer does not contain unsaved data.")); 72 72 updateEnabledState(); 73 73 } … … 82 82 } 83 83 } 84 85 private JRadioButton link, include;86 private JCheckBox export;87 84 88 85 @Override -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r5391 r5501 57 57 registerSessionLayerImporter("osm-data", OsmDataSessionImporter.class); 58 58 registerSessionLayerImporter("imagery", ImagerySessionImporter.class); 59 registerSessionLayerImporter("tracks", GpxTracksSessionImporter.class); 59 60 } 60 61 -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r5391 r5501 28 28 import javax.xml.transform.stream.StreamResult; 29 29 30 import org.w3c.dom.Document; 31 import org.w3c.dom.Element; 32 import org.w3c.dom.Text; 33 30 import org.openstreetmap.josm.gui.layer.GpxLayer; 34 31 import org.openstreetmap.josm.gui.layer.Layer; 35 32 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 38 35 import org.openstreetmap.josm.tools.MultiMap; 39 36 import org.openstreetmap.josm.tools.Utils; 37 import org.w3c.dom.Document; 38 import org.w3c.dom.Element; 39 import org.w3c.dom.Text; 40 40 41 41 public class SessionWriter { … … 47 47 registerSessionLayerExporter(TMSLayer.class , ImagerySessionExporter.class); 48 48 registerSessionLayerExporter(WMSLayer.class , ImagerySessionExporter.class); 49 registerSessionLayerExporter(GpxLayer.class , GpxTracksSessionExporter.class); 49 50 } 50 51 … … 86 87 } 87 88 89 /** 90 * A class that provides some context for the individual {@link SessionLayerExporter} 91 * when doing the export. 92 */ 88 93 public class ExportSupport { 89 94 private Document doc; … … 103 108 } 104 109 110 /** 111 * Get the index of the layer that is currently exported. 112 * @return the index of the layer that is currently exported 113 */ 105 114 public int getLayerIndex() { 106 115 return layerIndex; … … 108 117 109 118 /** 110 * Create a file in the zip archive.119 * Create a file inside the zip archive. 111 120 * 112 * @return never close the output stream, but make sure to flush buffers 121 * @param zipPath the path inside the zip archive, e.g. "layers/03/data.xml" 122 * @return the OutputStream you can write to. Never close the returned 123 * output stream, but make sure to flush buffers. 113 124 */ 114 125 public OutputStream getOutputStreamZip(String zipPath) throws IOException { … … 119 130 } 120 131 132 /** 133 * Check, if the session is exported as a zip archive. 134 * 135 * @return true, if the session is exported as a zip archive (.joz file 136 * extension). It will always return true, if one of the 137 * {@link SessionLayerExporter} returns true for the 138 * {@link SessionLayerExporter#requiresZip()} method. Otherwise, the 139 * user can decide in the file chooser dialog. 140 */ 121 141 public boolean isZip() { 122 142 return zip;
Note:
See TracChangeset
for help on using the changeset viewer.