altosui: Separate out log file choosing dialog to share with CSV generator
[fw/altos] / ao-tools / altosui / AltosUI.java
index 49d1f11a67f23e04c52d69ea768d9d0a9aff8393..64f96cddce15139cfdf00e696bc90e9242eb2941 100644 (file)
@@ -41,6 +41,8 @@ import altosui.AltosVoice;
 import altosui.AltosFlightStatusTableModel;
 import altosui.AltosFlightInfoTableModel;
 import altosui.AltosChannelMenu;
+import altosui.AltosFlashUI;
+import altosui.AltosLogfileChooser;
 
 import libaltosJNI.*;
 
@@ -457,6 +459,11 @@ public class AltosUI extends JFrame {
        void ConfigureTeleMetrum() {
                new AltosConfig(AltosUI.this);
        }
+
+       void FlashImage() {
+               new AltosFlashUI(AltosUI.this);
+       }
+
        /*
         * Open an existing telemetry file and replay it in realtime
         */
@@ -523,17 +530,12 @@ public class AltosUI extends JFrame {
         * Replay a flight from telemetry data
         */
        private void Replay() {
-               JFileChooser    logfile_chooser = new JFileChooser();
+               AltosLogfileChooser chooser = new AltosLogfileChooser(
+                       AltosUI.this);
 
-               logfile_chooser.setDialogTitle("Select Flight Record File");
-               logfile_chooser.setFileFilter(new FileNameExtensionFilter("Flight data file", "eeprom", "telem"));
-               logfile_chooser.setCurrentDirectory(AltosPreferences.logdir());
-               int returnVal = logfile_chooser.showOpenDialog(AltosUI.this);
+               File file = chooser.runDialog();
 
-               if (returnVal == JFileChooser.APPROVE_OPTION) {
-                       File file = logfile_chooser.getSelectedFile();
-                       if (file == null)
-                               System.out.println("No file selected?");
+               if (file != null) {
                        String  filename = file.getName();
                        try {
                                FileInputStream replay = new FileInputStream(file);
@@ -589,6 +591,14 @@ public class AltosUI extends JFrame {
                                });
                        menu.add(item);
 
+                       item = new JMenuItem("Flash Image",KeyEvent.VK_F);
+                       item.addActionListener(new ActionListener() {
+                                       public void actionPerformed(ActionEvent e) {
+                                               FlashImage();
+                                       }
+                               });
+                       menu.add(item);
+
                        item = new JMenuItem("Quit",KeyEvent.VK_Q);
                        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
                                                                   ActionEvent.CTRL_MASK));