altosui/telegps: Undo the frequency/telemetry menu changes
[fw/altos] / telegps / TeleGPSConfigUI.java
index 1fdfd70cdfc3978238401295fd8f9eac7bf21bbe..e5ac6d7ed4db9a3a22da6f3746af519130a4c014 100644 (file)
@@ -50,7 +50,7 @@ public class TeleGPSConfigUI
        JLabel                  product_value;
        JLabel                  version_value;
        JLabel                  serial_value;
-       AltosFreqList           radio_frequency_value;
+       AltosUIFreqList         radio_frequency_value;
        JTextField              radio_calibration_value;
        JRadioButton            radio_enable_value;
        JComboBox<String>       aprs_interval_value;
@@ -270,13 +270,9 @@ public class TeleGPSConfigUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = ir;
                c.ipady = 5;
-               radio_frequency_value = new AltosFreqList();
+               radio_frequency_value = new AltosUIFreqList();
                radio_frequency_value.addItemListener(this);
-
-               JMenuBar menu_bar = new JMenuBar();
-               menu_bar.add(radio_frequency_value);
-
-               pane.add(menu_bar, c);
+               pane.add(radio_frequency_value, c);
                radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
                row++;
 
@@ -612,12 +608,16 @@ public class TeleGPSConfigUI
        }
 
        public void units_changed(boolean imperial_units) {
+               boolean was_dirty = dirty;
+
                if (tracker_motion_value.isEnabled()) {
                        String motion = tracker_motion_value.getSelectedItem().toString();
                        tracker_motion_label.setText(get_tracker_motion_label());
                        set_tracker_motion_values();
                        set_tracker_motion((int) (AltosConvert.height.parse(motion, !imperial_units) + 0.5));
                }
+               if (!was_dirty)
+                       set_clean();
        }
 
        /* set and get all of the dialog values */
@@ -794,7 +794,12 @@ public class TeleGPSConfigUI
        }
 
        public void set_tracker_motion(int tracker_motion) {
-               tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
+               if (tracker_motion < 0) {
+                       tracker_motion_value.setEnabled(false);
+               } else {
+                       tracker_motion_value.setEnabled(true);
+                       tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
+               }
        }
 
        public int tracker_motion() throws AltosConfigDataException {
@@ -802,7 +807,12 @@ public class TeleGPSConfigUI
        }
 
        public void set_tracker_interval(int tracker_interval) {
-               tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
+               if (tracker_interval< 0) {
+                       tracker_interval_value.setEnabled(false);
+               } else {
+                       tracker_interval_value.setEnabled(true);
+                       tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
+               }
        }
 
        public int tracker_interval() throws AltosConfigDataException {