X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fsave%2FGpsSaver.java;h=6179a5c1346db75b829467e9e4925206776d0232;hb=79f3ca2954d7feb6052c21b3aa974c89b2b101d6;hp=5c74a7a3894d22dd7c06d9e3e3bdb4b3fca7f1c3;hpb=4d5796d02a15808311c09448d79e6e7d1de9d636;p=GpsPrune.git diff --git a/tim/prune/save/GpsSaver.java b/tim/prune/save/GpsSaver.java index 5c74a7a..6179a5c 100644 --- a/tim/prune/save/GpsSaver.java +++ b/tim/prune/save/GpsSaver.java @@ -42,6 +42,7 @@ public class GpsSaver extends GenericFunction implements Runnable private JTextField _deviceField = null, _formatField = null; private JTextField _trackNameField = null; private JCheckBox _waypointCheckbox = null, _trackCheckbox = null; + private boolean _switchedWaypointsOff = false, _switchedTrackpointsOff = false; private JButton _okButton = null; private JProgressBar _progressBar = null; private boolean _cancelled = false; @@ -84,8 +85,10 @@ public class GpsSaver extends GenericFunction implements Runnable _dialog.pack(); } // Initialise progress bars, buttons + enableCheckboxes(); enableOkButton(); setupProgressBar(true); + _trackNameField.requestFocus(); _dialog.setVisible(true); } } @@ -197,6 +200,42 @@ public class GpsSaver extends GenericFunction implements Runnable _progressBar.setValue(0); } + /** + * Enable or disable the waypoints and trackpoints checkboxes + */ + private void enableCheckboxes() + { + // Enable or disable waypoints checkbox depending on whether data is available + if (_waypointCheckbox.isSelected()) + { + if (!_app.getTrackInfo().getTrack().hasWaypoints()) + { + _waypointCheckbox.setSelected(false); + _switchedWaypointsOff = true; + } + else _switchedWaypointsOff = false; + } + else if (_app.getTrackInfo().getTrack().hasWaypoints() && _switchedWaypointsOff) + { + _waypointCheckbox.setSelected(true); + _switchedWaypointsOff = false; + } + // ... and the same for track points + if (_trackCheckbox.isSelected()) + { + if (!_app.getTrackInfo().getTrack().hasTrackPoints()) + { + _trackCheckbox.setSelected(false); + _switchedTrackpointsOff = true; + } + else _switchedTrackpointsOff = false; + } + else if (_app.getTrackInfo().getTrack().hasTrackPoints() && _switchedTrackpointsOff) + { + _trackCheckbox.setSelected(true); + _switchedTrackpointsOff = false; + } + } /** * Enable or disable the ok button @@ -269,11 +308,12 @@ public class GpsSaver extends GenericFunction implements Runnable Process process = Runtime.getRuntime().exec(commands); String trackName = _trackNameField.getText(); - if (trackName == null || trackName.equals("")) {trackName = "prune";} + if (trackName == null || trackName.equals("")) {trackName = "gpsprune";} // Generate the GPX file and send to the GPS OutputStreamWriter writer = new OutputStreamWriter(process.getOutputStream()); - boolean[] saveFlags = {true, true, true, true, false, true}; // export everything - GpxExporter.exportData(writer, _app.getTrackInfo(), trackName, null, saveFlags, null); + SettingsForExport settings = new SettingsForExport(); + settings.setExportMissingAltitudesAsZero(true); + GpxExporter.exportData(writer, _app.getTrackInfo(), trackName, null, settings, null); writer.close(); // Read the error stream to see if there's a better error message there