Changeset 29745 in osm for applications
- Timestamp:
- 2013-07-06T18:27:54+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/download_along
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/download_along/build.xml
r29744 r29745 4 4 <property name="commit.message" value="Changed the constructor signature of the plugin main class"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value=" 4980"/>6 <property name="plugin.main.version" value="6053"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/download_along/src/org/openstreetmap/josm/plugin/download_along/DownloadAlong.java
r29744 r29745 7 7 8 8 public class DownloadAlong extends Plugin { 9 static final String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE = "downloadAlong.downloadAlongTrack.distance"; 10 static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "downloadAlong.downloadAlongTrack.area"; 9 public static final String PREF_DOWNLOAD_ALONG_TRACK_DISTANCE = "downloadAlong.downloadAlongTrack.distance"; 10 public static final String PREF_DOWNLOAD_ALONG_TRACK_AREA = "downloadAlong.downloadAlongTrack.area"; 11 12 public static final String PREF_DOWNLOAD_ALONG_OSM = "downloadAlong.download.osm"; 13 public static final String PREF_DOWNLOAD_ALONG_GPS = "downloadAlong.download.gps"; 11 14 12 15 public DownloadAlong(PluginInformation info) { -
applications/editors/josm/plugins/download_along/src/org/openstreetmap/josm/plugin/download_along/DownloadAlongAction.java
r29744 r29745 16 16 import javax.swing.JOptionPane; 17 17 import javax.swing.JPanel; 18 import javax.swing.event.ChangeEvent; 19 import javax.swing.event.ChangeListener; 18 20 19 21 import org.openstreetmap.josm.Main; 20 22 import org.openstreetmap.josm.actions.JosmAction; 21 import org.openstreetmap.josm.actions.downloadtasks.Download OsmTaskList;23 import org.openstreetmap.josm.actions.downloadtasks.DownloadTaskList; 22 24 import org.openstreetmap.josm.data.coor.LatLon; 23 25 import org.openstreetmap.josm.data.osm.Node; … … 55 57 } 56 58 57 DownloadPanel panel = new DownloadPanel();59 final DownloadPanel panel = new DownloadPanel(); 58 60 59 ButtonSpec[] options = new ButtonSpec[] {61 final ButtonSpec[] options = new ButtonSpec[] { 60 62 new ButtonSpec( 61 63 tr("Download"), … … 71 73 ) 72 74 }; 75 76 panel.addChangeListener(new ChangeListener() { 77 @Override public void stateChanged(ChangeEvent e) { 78 options[0].setEnabled(panel.isDownloadOsmData() || panel.isDownloadGpxData()); 79 } 80 }); 73 81 74 82 if (0 != HelpAwareOptionPane.showOptionDialog(Main.parent, panel, tr("Download from OSM along this track"), … … 76 84 return; 77 85 } 78 79 Main.pref.putDouble(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, panel.getDistance()); 80 Main.pref.putDouble(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_AREA, panel.getArea()); 86 87 panel.rememberSettings(); 81 88 82 89 /* … … 191 198 } 192 199 final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download data")); 193 final Future<?> future = new Download OsmTaskList().download(false, toDownload, monitor);200 final Future<?> future = new DownloadTaskList().download(false, toDownload, panel.isDownloadOsmData(), panel.isDownloadGpxData(), monitor); 194 201 Main.worker.submit(new Runnable() { 195 202 public void run() { -
applications/editors/josm/plugins/download_along/src/org/openstreetmap/josm/plugin/download_along/DownloadPanel.java
r29744 r29745 5 5 import java.awt.GridBagLayout; 6 6 7 import javax.swing.JCheckBox; 7 8 import javax.swing.JLabel; 8 9 import javax.swing.JList; 9 10 import javax.swing.JPanel; 11 import javax.swing.event.ChangeListener; 10 12 11 13 import org.openstreetmap.josm.Main; … … 14 16 public class DownloadPanel extends JPanel { 15 17 18 // Data types to download 19 private final JCheckBox cbDownloadOsmData; 20 private final JCheckBox cbDownloadGpxData; 21 22 // Legacy list of values 16 23 private static final Integer dist[] = { 5000, 500, 50 }; 17 24 private static final Integer area[] = { 20, 10, 5, 1 }; … … 20 27 private final JList maxRect; 21 28 29 // Get value from preferences, taking into account legacy plugin stored only index from list of values instead of real value 22 30 private static final double getPreferenceValue(String prefKey, Integer array[]) { 23 int legacyIndex = Main.pref.getInteger(prefKey, -1);31 int legacyIndex = Main.pref.getInteger(prefKey, array[0]); 24 32 return (0 <= legacyIndex && legacyIndex < array.length) 25 33 ? array[legacyIndex] … … 27 35 } 28 36 37 /** 38 * Constructs a new {@code DownloadPanel}. 39 */ 29 40 public DownloadPanel() { 30 41 super(new GridBagLayout()); 31 42 43 cbDownloadOsmData = new JCheckBox(tr("OpenStreetMap data"), Main.pref.getBoolean(DownloadAlong.PREF_DOWNLOAD_ALONG_OSM, true)); 44 cbDownloadOsmData.setToolTipText(tr("Select to download OSM data.")); 45 add(cbDownloadOsmData, GBC.std().insets(1,5,1,5)); 46 cbDownloadGpxData = new JCheckBox(tr("Raw GPS data"), Main.pref.getBoolean(DownloadAlong.PREF_DOWNLOAD_ALONG_GPS, false)); 47 cbDownloadGpxData.setToolTipText(tr("Select to download GPS traces.")); 48 add(cbDownloadGpxData, GBC.eol().insets(5,5,1,5)); 49 32 50 add(new JLabel(tr("Download everything within:")), GBC.eol()); 33 51 String s[] = new String[dist.length]; … … 38 56 39 57 double distanceValue = getPreferenceValue(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, dist); 40 int distanceLegacyIndex = Main.pref.getInteger(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, -1);41 if (distanceLegacyIndex == -1) {58 int distanceLegacyIndex = Main.pref.getInteger(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, dist[0]); 59 if (distanceLegacyIndex == dist[0]) { 42 60 for (int i = 0; i < dist.length; i++) { 43 61 if (dist[i] == (int)distanceValue) { … … 59 77 60 78 double areaValue = getPreferenceValue(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_AREA, area); 61 int areaLegacyIndex = Main.pref.getInteger(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_AREA, -1);62 if (areaLegacyIndex == -1) {79 int areaLegacyIndex = Main.pref.getInteger(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_AREA, area[0]); 80 if (areaLegacyIndex == area[0]) { 63 81 for (int i = 0; i < area.length; i++) { 64 82 if (area[i] == (int)areaValue) { … … 73 91 } 74 92 93 /** 94 * Gets the maximum distance in meters 95 * @return The maximum distance, in meters 96 */ 75 97 public final double getDistance() { 76 98 return dist[buffer.getSelectedIndex()]; 77 99 } 78 100 101 /** 102 * Gets the maximum area in squared kilometers 103 * @return The maximum distance, in squared kilometers 104 */ 79 105 public final double getArea() { 80 106 return area[maxRect.getSelectedIndex()]; 81 107 } 108 109 /** 110 * Replies true if the user selected to download OSM data 111 * 112 * @return true if the user selected to download OSM data 113 */ 114 public boolean isDownloadOsmData() { 115 return cbDownloadOsmData.isSelected(); 116 } 117 118 /** 119 * Replies true if the user selected to download GPX data 120 * 121 * @return true if the user selected to download GPX data 122 */ 123 public boolean isDownloadGpxData() { 124 return cbDownloadGpxData.isSelected(); 125 } 126 127 /** 128 * Remembers the current settings in the download panel 129 */ 130 public final void rememberSettings() { 131 Main.pref.putDouble(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_DISTANCE, getDistance()); 132 Main.pref.putDouble(DownloadAlong.PREF_DOWNLOAD_ALONG_TRACK_AREA, getArea()); 133 Main.pref.put(DownloadAlong.PREF_DOWNLOAD_ALONG_OSM, isDownloadOsmData()); 134 Main.pref.put(DownloadAlong.PREF_DOWNLOAD_ALONG_GPS, isDownloadGpxData()); 135 } 136 137 /** 138 * Adds a change listener to comboboxes 139 * @param listener The listener that will be notified of each combobox change 140 */ 141 public final void addChangeListener(ChangeListener listener) { 142 cbDownloadGpxData.addChangeListener(listener); 143 cbDownloadOsmData.addChangeListener(listener); 144 } 82 145 }
Note:
See TracChangeset
for help on using the changeset viewer.