summaryrefslogtreecommitdiff
path: root/telegps/TeleGPS.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2019-06-18 14:50:18 -0700
committerKeith Packard <keithp@keithp.com>2019-06-18 14:50:18 -0700
commit6529fd623f0e4b921aea1110c723d7dc03954def (patch)
treef7aa046f87f45c1feecfc37f2390dfb9fcc2ff84 /telegps/TeleGPS.java
parentbd351b9e3b1ba21851b2c87f5202ac3bf5c479c0 (diff)
altosui/telegps: Display error message when attempting to graph unknown files
Instead of presenting an empty graph window. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'telegps/TeleGPS.java')
-rw-r--r--telegps/TeleGPS.java31
1 files changed, 15 insertions, 16 deletions
diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java
index 24cc379f..af6d01b4 100644
--- a/telegps/TeleGPS.java
+++ b/telegps/TeleGPS.java
@@ -307,26 +307,14 @@ public class TeleGPS
void graph() {
AltosDataChooser chooser = new AltosDataChooser(this);
AltosRecordSet set = chooser.runDialog();
- if (set == null)
- return;
- try {
- new TeleGPSGraphUI(set, chooser.file());
- } catch (InterruptedException ie) {
- } catch (IOException ie) {
- }
+ graph_file(this, set, chooser.file());
}
public void graph_flights(AltosEepromList list) {
for (AltosEepromLog log : list) {
if (log.file != null) {
AltosRecordSet set = record_set(log.file);
- if (set != null) {
- try {
- new TeleGPSGraphUI(set, log.file);
- } catch (InterruptedException ie) {
- } catch (IOException ie) {
- }
- }
+ graph_file(this, set, log.file);
}
}
}
@@ -650,10 +638,16 @@ public class TeleGPS
return new AltosReplayReader(set, file);
}
- static boolean process_graph(File file) {
- AltosRecordSet set = record_set(file);
+ private static boolean graph_file(TeleGPS telegps, AltosRecordSet set, File file) {
if (set == null)
return false;
+ if (!set.valid()) {
+ JOptionPane.showMessageDialog(telegps,
+ String.format("Failed to parse file %s", file),
+ "Graph Failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
try {
new TeleGPSGraphUI(set, file);
} catch (Exception e) {
@@ -662,6 +656,11 @@ public class TeleGPS
return true;
}
+ static boolean process_graph(File file) {
+ AltosRecordSet set = record_set(file);
+ return graph_file(null, set, file);
+ }
+
static boolean process_replay(File file) {
AltosReplayReader new_reader = replay_file(file);
if (new_reader == null)