Changeset 34481 in osm for applications/editors/josm
- Timestamp:
- 2018-08-15T14:16:40+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/DirectDownload
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/DirectDownload/.project
r32286 r34481 16 16 </arguments> 17 17 </buildCommand> 18 <buildCommand> 19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 20 <arguments> 21 </arguments> 22 </buildCommand> 18 23 </buildSpec> 19 24 <natures> 20 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 21 27 </natures> 22 28 </projectDescription> -
applications/editors/josm/plugins/DirectDownload/src/org/openstreetmap/josm/plugins/directdownload/DirectDownload.java
r34381 r34481 5 5 6 6 import java.awt.event.ActionEvent; 7 import java.util.ArrayList; 8 import java.util.HashMap; 7 9 8 10 import org.openstreetmap.josm.Main; 9 11 import org.openstreetmap.josm.actions.JosmAction; 10 12 import org.openstreetmap.josm.data.gpx.GpxData; 13 import org.openstreetmap.josm.data.gpx.GpxTrack; 14 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 15 import org.openstreetmap.josm.data.gpx.GpxConstants; 16 import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack; 11 17 import org.openstreetmap.josm.gui.MainApplication; 12 18 import org.openstreetmap.josm.gui.MainMenu; … … 17 23 18 24 public class DirectDownload extends Plugin { 25 19 26 private DownloadAction openaction; 20 27 … … 32 39 33 40 static class DownloadAction extends JosmAction { 34 publicDownloadAction() {41 DownloadAction() { 35 42 super(tr("Download Track ..."), "DownloadAction", 36 43 tr("Download GPX track from openstreetmap.org"), null, false); … … 42 49 go.setVisible(true); 43 50 44 UserTrack track = go.getSelectedUserTrack();51 ArrayList<UserTrack> tracks = go.getSelectedUserTracks(); 45 52 46 if (!((go.getValue() == 1) && (track != null))) {53 if (!((go.getValue() == 1) && (tracks != null))) { 47 54 return; 48 55 } 49 56 50 final GpxData data = new GpxServerReader().loadGpx(Long.parseLong(track.id)); 51 if (data == null) { 52 return; 53 } 54 final GpxLayer gpxLayer = new GpxLayer(data); 57 for (UserTrack track: tracks) { 55 58 56 if (data.hasRoutePoints() || data.hasTrackPoints()) { 57 MainApplication.getLayerManager().addLayer(gpxLayer); 58 } 59 GpxData data = new GpxServerReader().loadGpx(Long.parseLong(track.id)); 60 if (data == null) { 61 return; 62 } 59 63 60 if (Main.pref.getBoolean("marker.makeautomarkers", true) && !data.waypoints.isEmpty()) { 61 MarkerLayer ml = new MarkerLayer(data, tr("Markers from {0}", track.filename), null, gpxLayer); 62 if (ml.data.size() > 0) { 63 MainApplication.getLayerManager().addLayer(ml); 64 for (GpxTrack trk : data.getTracks()) { 65 HashMap<String, Object> attrib = new HashMap<String, Object>(trk.getAttributes()); 66 if (!trk.getAttributes().containsKey(GpxConstants.GPX_NAME)) { 67 System.out.println(track.filename); 68 attrib.put(GpxConstants.GPX_NAME, track.filename); 69 } 70 if (!trk.getAttributes().containsKey(GpxConstants.GPX_DESC)) { 71 System.out.println(track.description); 72 attrib.put(GpxConstants.GPX_DESC, track.description); 73 } 74 // replace the existing trace in the unmodifiable tracks 75 data.removeTrack(trk); 76 trk = new ImmutableGpxTrack(new ArrayList<GpxTrackSegment>(trk.getSegments()), attrib); 77 data.addTrack(trk); 78 } 79 80 final GpxLayer gpxLayer = new GpxLayer(data, (track.filename + " " + track.description).trim()); 81 82 if (data.hasRoutePoints() || data.hasTrackPoints()) { 83 MainApplication.getLayerManager().addLayer(gpxLayer); 84 } 85 86 if (Main.pref.getBoolean("marker.makeautomarkers", true) && !data.waypoints.isEmpty()) { 87 MarkerLayer ml = new MarkerLayer(data, tr("Markers from {0}", track.filename), null, gpxLayer); 88 if (ml.data.size() > 0) { 89 MainApplication.getLayerManager().addLayer(ml); 90 } 64 91 } 65 92 } -
applications/editors/josm/plugins/DirectDownload/src/org/openstreetmap/josm/plugins/directdownload/DownloadDataGui.java
r34381 r34481 48 48 tblSearchResults = new JTable(model, columnmodel); 49 49 tblSearchResults.setSelectionModel(selectionModel); 50 tblSearchResults.setSelectionMode(ListSelectionModel. SINGLE_SELECTION);50 tblSearchResults.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 51 51 JScrollPane scrollPane = new JScrollPane(tblSearchResults); 52 scrollPane.setPreferredSize(new Dimension(800, 300));52 scrollPane.setPreferredSize(new Dimension(800, 300)); 53 53 panel.add(scrollPane, BorderLayout.CENTER); 54 54 … … 63 63 private ListSelectionModel selectionModel; 64 64 65 publicNamedResultTableModel(ListSelectionModel selectionModel) {65 NamedResultTableModel(ListSelectionModel selectionModel) { 66 66 data = new ArrayList<>(); 67 67 this.selectionModel = selectionModel; … … 84 84 this.data.clear(); 85 85 } else { 86 this.data =new ArrayList<>(data);86 this.data = new ArrayList<>(data); 87 87 } 88 88 fireTableDataChanged(); 89 } 90 91 public ArrayList<UserTrack> getDataArrayList() { 92 return data; 89 93 } 90 94 … … 101 105 } 102 106 107 public ArrayList<UserTrack> getSelectedUserTracks() { 108 ArrayList<UserTrack> DataArray = model.getDataArrayList(); 109 int[] selected = tblSearchResults.getSelectedRows(); 110 ArrayList<UserTrack> selectedTracks = new ArrayList<>(selected.length); 111 for (int i = 0; i < selected.length; i++) { 112 selectedTracks.add(DataArray.get(selected[i])); 113 } 114 return selectedTracks; 115 } 116 103 117 public UserTrack getSelectedUserTrack() { 104 118 return model.getSelectedUserTrack(); … … 135 149 136 150 // column 3 - tags 137 /* 151 138 152 col = new TableColumn(3); 139 153 col.setHeaderValue(tr("Tags")); … … 142 156 col.setCellRenderer(renderer); 143 157 addColumn(col); 144 */ 145 } 146 147 publicNamedResultTableColumnModel() {158 159 } 160 161 NamedResultTableColumnModel() { 148 162 createColumns(); 149 163 } … … 152 166 static class NamedResultCellRenderer extends JLabel implements TableCellRenderer { 153 167 154 publicNamedResultCellRenderer() {168 NamedResultCellRenderer() { 155 169 setOpaque(true); 156 setBorder(BorderFactory.createEmptyBorder(2, 2,2,2));170 setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); 157 171 } 158 172 … … 173 187 174 188 @Override 175 189 public Component getTableCellRendererComponent(JTable table, Object value, 176 190 boolean isSelected, boolean hasFocus, int row, int column) { 177 191 … … 191 205 setText(sr.description); 192 206 break; 193 /* 207 194 208 case 3: 195 209 setText(sr.tags); 196 210 break; 197 */ 211 198 212 } 199 213 return this; -
applications/editors/josm/plugins/DirectDownload/src/org/openstreetmap/josm/plugins/directdownload/GpxServerReader.java
r34381 r34481 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.directdownload; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.io.IOException; 7 import java.io.InputStream; 8 import java.net.URL; 9 10 import javax.swing.JOptionPane; 3 11 4 12 import org.openstreetmap.josm.Main; … … 12 20 import org.xml.sax.SAXException; 13 21 14 import javax.swing.*;15 import java.io.IOException;16 import java.io.InputStream;17 import java.net.URL;18 19 import static org.openstreetmap.josm.tools.I18n.tr;20 21 22 public class GpxServerReader extends OsmConnection { 22 23 … … 28 29 addAuth(client); 29 30 30 try ( finalInputStream in = client.connect().uncompressAccordingToContentDisposition(true).getContent()) {31 try (InputStream in = client.connect().uncompressAccordingToContentDisposition(true).getContent()) { 31 32 final GpxReader r = new GpxReader(in); 32 33 boolean parsedProperly = r.parse(true); -
applications/editors/josm/plugins/DirectDownload/src/org/openstreetmap/josm/plugins/directdownload/UserTrackReader.java
r34381 r34481 41 41 42 42 //parse the file and also register this class for call backs 43 try ( finalInputStream in = client.connect().getContent()) {43 try (InputStream in = client.connect().getContent()) { 44 44 sp.parse(in, handler); 45 45 } … … 80 80 81 81 @Override 82 public void characters(char ch[], int start, int length)82 public void characters(char[] ch, int start, int length) 83 83 throws SAXException { 84 84 cdata += new String(ch, start, length); … … 89 89 if (qName.equals("description")) { 90 90 data.getFirst().description = cdata; 91 } else if (qName.equals("tag")) { 92 data.getFirst().tags = cdata; 93 cdata = new String(); 91 94 } 92 /* 93 else if (qName.equals("tag")) { 94 data.getFirst().tags = cdata; 95 cdata = new String(); 96 } 97 */ 95 98 96 } 99 97
Note:
See TracChangeset
for help on using the changeset viewer.