altosui: Make teledongle callsign configurable
[fw/altos] / ao-tools / altosui / AltosUI.java
index b96e16a612d0c05e2d39a7c273b1bb5ca7ac1a16..33ce274a26d7393f31e2fc2f43f150fcb82b3e8d 100644 (file)
@@ -420,6 +420,7 @@ public class AltosUI extends JFrame {
                                serial_line.open(device);
                                DeviceThread thread = new DeviceThread(serial_line);
                                serial_line.set_channel(AltosPreferences.channel());
+                               serial_line.set_callsign(AltosPreferences.callsign());
                                run_display(thread);
                        } catch (FileNotFoundException ee) {
                                JOptionPane.showMessageDialog(AltosUI.this,
@@ -440,6 +441,18 @@ public class AltosUI extends JFrame {
                stop_display();
        }
 
+       void ConfigureCallsign() {
+               String  result;
+               result = JOptionPane.showInputDialog(AltosUI.this,
+                                                    "Configure Callsign",
+                                                    AltosPreferences.callsign());
+               if (result != null) {
+                       AltosPreferences.set_callsign(result);
+                       if (serial_line != null)
+                               serial_line.set_callsign(result);
+               }
+       }
+
        /*
         * Open an existing telemetry file and replay it in realtime
         */
@@ -556,6 +569,22 @@ public class AltosUI extends JFrame {
                        menu.setMnemonic(KeyEvent.VK_F);
                        menubar.add(menu);
 
+                       item = new JMenuItem("Replay File",KeyEvent.VK_R);
+                       item.addActionListener(new ActionListener() {
+                                       public void actionPerformed(ActionEvent e) {
+                                               Replay();
+                                       }
+                               });
+                       menu.add(item);
+
+                       item = new JMenuItem("Save Flight Data",KeyEvent.VK_S);
+                       item.addActionListener(new ActionListener() {
+                                       public void actionPerformed(ActionEvent e) {
+                                               SaveFlightData();
+                                       }
+                               });
+                       menu.add(item);
+
                        item = new JMenuItem("Quit",KeyEvent.VK_Q);
                        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
                                                                   ActionEvent.CTRL_MASK));
@@ -591,20 +620,13 @@ public class AltosUI extends JFrame {
 
                        menu.addSeparator();
 
-                       item = new JMenuItem("Save Flight Data",KeyEvent.VK_S);
+                       item = new JMenuItem("Set Callsign",KeyEvent.VK_S);
                        item.addActionListener(new ActionListener() {
                                        public void actionPerformed(ActionEvent e) {
-                                               SaveFlightData();
+                                               ConfigureCallsign();
                                        }
                                });
-                       menu.add(item);
 
-                       item = new JMenuItem("Replay",KeyEvent.VK_R);
-                       item.addActionListener(new ActionListener() {
-                                       public void actionPerformed(ActionEvent e) {
-                                               Replay();
-                                       }
-                               });
                        menu.add(item);
                }
                // Log menu