Bump java lib versions in preparation for 1.9.2
[fw/altos] / telegps / TeleGPS.java
index 3646f000a450d2b65a8c1304520a7a84098f248c..77ed0da7ae5b7b48dad0a683a9d8813ff26881bb 100644 (file)
@@ -25,12 +25,12 @@ import java.io.*;
 import java.util.concurrent.*;
 import java.util.*;
 import java.text.*;
-import org.altusmetrum.altoslib_12.*;
-import org.altusmetrum.altosuilib_12.*;
+import org.altusmetrum.altoslib_14.*;
+import org.altusmetrum.altosuilib_14.*;
 
 public class TeleGPS
        extends AltosUIFrame
-       implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener
+       implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener, AltosEepromGrapher
 {
 
        static String[] telegps_icon_names = {
@@ -280,7 +280,7 @@ public class TeleGPS
        }
 
        void download(){
-               new AltosEepromManage(this, AltosLib.product_telegps);
+               new AltosEepromManage(this, this, AltosLib.product_telegps);
        }
 
        void configure() {
@@ -307,12 +307,15 @@ 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);
+                               graph_file(this, set, log.file);
+                       }
                }
        }
 
@@ -635,18 +638,32 @@ 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) {
+               } catch (IOException e) {
+                       System.out.printf("Exception %s\n", e.toString());
+               } catch (InterruptedException e) {
+                       System.out.printf("Exception %s\n", e.toString());
                        return false;
                }
                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)