telegps: Shuffle menu entries around
[fw/altos] / telegps / TeleGPS.java
index 2503d53e4d92b47d658868976c6fbb27f6156196..eddb47d8f2975fc496bd1817aa14c63025a210f5 100644 (file)
@@ -69,48 +69,49 @@ public class TeleGPS
 
        AltosUIMap              map;
        TeleGPSInfo             gps_info;
+       TeleGPSState            gps_state;
        AltosInfoTable          info_table;
 
        LinkedList<AltosFlightDisplay>  displays;
 
        /* File menu */
        final static String     new_command = "new";
-       final static String     preferences_command = "preferences";
+       final static String     graph_command = "graph";
+       final static String     export_command = "export";
        final static String     load_maps_command = "loadmaps";
+       final static String     preferences_command = "preferences";
        final static String     close_command = "close";
        final static String     exit_command = "exit";
 
        static final String[][] file_menu_entries = new String[][] {
                { "New Window",         new_command },
-               { "Preferences",        preferences_command },
+               { "Graph Data",         graph_command },
+               { "Export Data",        export_command },
                { "Load Maps",          load_maps_command },
+               { "Preferences",        preferences_command },
                { "Close",              close_command },
                { "Exit",               exit_command },
        };
 
        /* Monitor menu */
-       final static String     monitor_command = "monitor";
+       final static String     connect_command = "connect";
        final static String     disconnect_command = "disconnect";
        final static String     scan_command = "scan";
 
        static final String[][] monitor_menu_entries = new String[][] {
-               { "Monitor Device",     monitor_command },
+               { "Connect Device",     connect_command },
                { "Disconnect",         disconnect_command },
                { "Scan Channels",      scan_command },
        };
 
        /* Device menu */
        final static String     download_command = "download";
-       final static String     export_command = "export";
-       final static String     graph_command = "graph";
        final static String     configure_command = "configure";
        final static String     flash_command = "flash";
 
        static final String[][] device_menu_entries = new String[][] {
                { "Download Data",      download_command },
                { "Configure Device",   configure_command },
-               { "Export Data",        export_command },
-               { "Graph Data",         graph_command },
                { "Flash Device",       flash_command },
        };
 
@@ -212,7 +213,7 @@ public class TeleGPS
                }
        }
 
-       void monitor() {
+       void connect() {
                AltosDevice     device = AltosDeviceUIDialog.show(this,
                                                                  AltosLib.product_basestation);
                if (device == null)
@@ -285,8 +286,8 @@ public class TeleGPS
                        System.exit(0);
 
                /* Monitor menu */
-               if (monitor_command.equals(ev.getActionCommand())) {
-                       monitor();
+               if (connect_command.equals(ev.getActionCommand())) {
+                       connect();
                        return;
                }
                if (disconnect_command.equals(ev.getActionCommand())) {
@@ -323,6 +324,9 @@ public class TeleGPS
 
        void add_frequency_menu(int serial, final AltosFlightReader reader) {
                // Channel menu
+               if (frequencies != null)
+                       return;
+
                frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
                frequencies.set_product("Monitor");
                frequencies.set_serial(serial);
@@ -343,6 +347,7 @@ public class TeleGPS
        void remove_frequency_menu() {
                if (frequencies != null) {
                        menu_bar.remove(frequencies);
+                       menu_bar.repaint();
                        frequencies = null;
                }
        }
@@ -366,6 +371,7 @@ public class TeleGPS
        }
 
        private void close() {
+               disconnect();
                AltosUIPreferences.unregister_font_listener(this);
                AltosPreferences.unregister_units_listener(this);
                setVisible(false);
@@ -439,13 +445,17 @@ public class TeleGPS
                bag.add(pane, c);
 
                map = new AltosUIMap();
-               pane.add("Map", map);
+               pane.add(map.getName(), map);
                displays.add(map);
 
                gps_info = new TeleGPSInfo();
-               pane.add("Info", gps_info);
+               pane.add(gps_info.getName(), gps_info);
                displays.add(gps_info);
 
+               gps_state = new TeleGPSState();
+               pane.add(gps_state.getName(), gps_state);
+               displays.add(gps_state);
+
                info_table = new AltosInfoTable();
                pane.add("Table", info_table);
                displays.add(info_table);