altosui: With --replay option, exit when replay window is closed
[fw/altos] / ao-tools / altosui / AltosFlightUI.java
index 3581c54c1ce8a6b14c5135ecb1839b656bc05ec6..5134a24ebd731ed09533e2c1f1e05bcf3f9866a8 100644 (file)
@@ -45,7 +45,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
        AltosDescent    descent;
        AltosLanded     landed;
 
-       private AltosStatusTable flightStatus;
+       private AltosFlightStatus flightStatus;
+       private JScrollPane flightInfoPane;
        private AltosInfoTable flightInfo;
 
        static final int tab_pad = 1;
@@ -55,6 +56,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
 
        int cur_tab = 0;
 
+       boolean exit_on_close = false;
+
        int which_tab(AltosState state) {
                if (state.state < Altos.ao_flight_boost)
                        return tab_pad;
@@ -117,12 +120,16 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                        }
                        cur_tab = tab;
                }
-               flightStatus.set(state);
+               flightStatus.show(state, crc_errors);
                flightInfo.show(state, crc_errors);
        }
 
+       public void set_exit_on_close() {
+               exit_on_close = true;
+       }
+
        public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
-        AltosPreferences.init(this);
+               AltosPreferences.init(this);
 
                voice = in_voice;
                reader = in_reader;
@@ -133,7 +140,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
 
                setTitle(String.format("AltOS %s", reader.name));
 
-               flightStatus = new AltosStatusTable();
+               flightStatus = new AltosFlightStatus();
 
                vbox = new Box (BoxLayout.Y_AXIS);
                vbox.add(flightStatus);
@@ -153,7 +160,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                pane.add("Landed", landed);
 
                flightInfo = new AltosInfoTable();
-               pane.add("Table", flightInfo.box());
+               flightInfoPane = new JScrollPane(flightInfo.box());
+               pane.add("Table", flightInfoPane);
 
                vbox.add(pane);
 
@@ -189,6 +197,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay {
                                disconnect();
                                setVisible(false);
                                dispose();
+                               if (exit_on_close)
+                                       System.exit(0);
                        }
                });