altosui/telegps: Undo the frequency/telemetry menu changes
authorKeith Packard <keithp@keithp.com>
Sat, 5 Jul 2014 06:38:53 +0000 (23:38 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 5 Jul 2014 07:38:09 +0000 (00:38 -0700)
Using menus for these items isn't what we want; we want to show the
current value on the screen, which is what a combo box is for. Switch
back to those and remove the frequency and telemetry config from the
TeleGPS menu bar so that Mac OS X is happy.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosConfigTDUI.java
altosui/AltosConfigUI.java
altosui/AltosFlightUI.java
altosui/AltosIdleMonitorUI.java
altosuilib/AltosFreqList.java [deleted file]
altosuilib/AltosUIFreqList.java [new file with mode: 0644]
altosuilib/AltosUITelemetryList.java [new file with mode: 0644]
altosuilib/AltosUITelemetryMenu.java [deleted file]
altosuilib/Makefile.am
telegps/TeleGPS.java
telegps/TeleGPSConfigUI.java

index ca3657183e037f339cd46ed8e1a69cebc29484c0..947d78ee1815adf8ef8c9e2ffcf81a408a68224f 100644 (file)
@@ -44,8 +44,7 @@ public class AltosConfigTDUI
        JLabel          product_value;
        JLabel          version_value;
        JLabel          serial_value;
-       JMenuBar        radio_frequency_menu_bar;
-       AltosFreqList   radio_frequency_value;
+       AltosUIFreqList radio_frequency_value;
        JLabel          radio_calibration_value;
 
        JButton         save;
@@ -55,7 +54,6 @@ public class AltosConfigTDUI
 
        ActionListener  listener;
 
-
        /* A window listener to catch closing events and tell the config code */
        class ConfigListener extends WindowAdapter {
                AltosConfigTDUI ui;
@@ -167,11 +165,9 @@ public class AltosConfigTDUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = ir;
                c.ipady = 5;
-               radio_frequency_value = new AltosFreqList(false);
+               radio_frequency_value = new AltosUIFreqList();
                radio_frequency_value.addItemListener(this);
-               radio_frequency_menu_bar = new JMenuBar();
-               radio_frequency_menu_bar.add(radio_frequency_value);
-               pane.add(radio_frequency_menu_bar, c);
+               pane.add(radio_frequency_value, c);
                radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
 
                /* Radio Calibration */
@@ -311,7 +307,28 @@ public class AltosConfigTDUI
        }
 
        public void set_radio_frequency(double new_radio_frequency) {
-               radio_frequency_value.set_frequency(new_radio_frequency);
+               int i;
+               for (i = 0; i < radio_frequency_value.getItemCount(); i++) {
+                       AltosFrequency  f = (AltosFrequency) radio_frequency_value.getItemAt(i);
+
+                       if (f.close(new_radio_frequency)) {
+                               radio_frequency_value.setSelectedIndex(i);
+                               return;
+                       }
+               }
+               for (i = 0; i < radio_frequency_value.getItemCount(); i++) {
+                       AltosFrequency  f = (AltosFrequency) radio_frequency_value.getItemAt(i);
+
+                       if (new_radio_frequency < f.frequency)
+                               break;
+               }
+               String  description = String.format("%s serial %s",
+                                                   product_value.getText(),
+                                                   serial_value.getText());
+               AltosFrequency  new_frequency = new AltosFrequency(new_radio_frequency, description);
+               AltosPreferences.add_common_frequency(new_frequency);
+               radio_frequency_value.insertItemAt(new_frequency, i);
+               radio_frequency_value.setSelectedIndex(i);
        }
 
        public double radio_frequency() {
index de1b582ef80d6130d491ad6ac2bf5c7108720001..91c37fd530f5d19c6259c8e5866c525325051511 100644 (file)
@@ -59,7 +59,7 @@ public class AltosConfigUI
        JComboBox<String>       main_deploy_value;
        JComboBox<String>       apogee_delay_value;
        JComboBox<String>       apogee_lockout_value;
-       AltosFreqList           radio_frequency_value;
+       AltosUIFreqList         radio_frequency_value;
        JTextField              radio_calibration_value;
        JRadioButton            radio_enable_value;
        JComboBox<String>       aprs_interval_value;
@@ -432,12 +432,9 @@ public class AltosConfigUI
                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++;
 
index 5aff1817144ee993b08167baa64c1f4c313679f0..5db0ee92864641e273e5ee80c31828ccb195d627 100644 (file)
@@ -169,18 +169,14 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
                exit_on_close = true;
        }
 
-       Container       bag;
-
-       JMenuBar                menu_bar;
-       AltosFreqList           frequencies;
-       AltosUITelemetryMenu    telemetries;
+       Container               bag;
+       AltosUIFreqList         frequencies;
+       AltosUITelemetryList    telemetries;
        JLabel                  telemetry;
 
        ActionListener  show_timer;
 
        public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) {
-               super();
-
                AltosUIPreferences.set_component(this);
 
                displays = new LinkedList<AltosFlightDisplay>();
@@ -197,12 +193,8 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
 
                /* Stick channel selector at top of table for telemetry monitoring */
                if (serial >= 0) {
-
-                       menu_bar = new JMenuBar();
-                       setJMenuBar(menu_bar);
-
-                       // Channel menu
-                       frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
+                       // Frequency menu
+                       frequencies = new AltosUIFreqList(AltosUIPreferences.frequency(serial));
                        frequencies.set_product("Monitor");
                        frequencies.set_serial(serial);
                        frequencies.addActionListener(new ActionListener() {
@@ -216,19 +208,43 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
                                                reader.save_frequency();
                                        }
                        });
-                       menu_bar.add (frequencies);
-
-                       // Telemetry format menu
-                       if (reader.supports_telemetry(AltosLib.ao_telemetry_standard)) {
-                               telemetries = new AltosUITelemetryMenu(serial);
+                       c.gridx = 0;
+                       c.gridy = 0;
+                       c.weightx = 0;
+                       c.weighty = 0;
+                       c.insets = new Insets(3, 3, 3, 3);
+                       c.fill = GridBagConstraints.NONE;
+                       c.anchor = GridBagConstraints.WEST;
+                       bag.add (frequencies, c);
+
+                       // Telemetry format list
+                       if (reader.supports_telemetry(Altos.ao_telemetry_standard)) {
+                               telemetries = new JComboBox<String>();
+                               for (int i = 1; i <= Altos.ao_telemetry_max; i++)
+                                       telemetries.addItem(Altos.telemetry_name(i));
+                               int telemetry = AltosPreferences.telemetry(serial);
+                               if (telemetry <= Altos.ao_telemetry_off ||
+                                   telemetry > Altos.ao_telemetry_max)
+                                       telemetry = Altos.ao_telemetry_standard;
+                               telemetries.setSelectedIndex(telemetry - 1);
+                               telemetries.setMaximumRowCount(Altos.ao_telemetry_max);
+                               telemetries.setPreferredSize(null);
+                               telemetries.revalidate();
                                telemetries.addActionListener(new ActionListener() {
                                                public void actionPerformed(ActionEvent e) {
-                                                       int telemetry = telemetries.get_selected();
+                                                       int telemetry = telemetries.getSelectedIndex() + 1;
                                                        reader.set_telemetry(telemetry);
                                                        reader.save_telemetry();
                                                }
                                        });
-                               menu_bar.add(telemetries);
+                               c.gridx = 1;
+                               c.gridy = 0;
+                               c.weightx = 0;
+                               c.weighty = 0;
+                               c.fill = GridBagConstraints.NONE;
+                               c.anchor = GridBagConstraints.WEST;
+                               bag.add (telemetries, c);
+                               c.insets = new Insets(0, 0, 0, 0);
                        } else {
                                String  version;
 
@@ -240,7 +256,14 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay {
                                        version = "Telemetry: None";
 
                                telemetry = new JLabel(version);
-                               menu_bar.add(telemetry);
+                               c.gridx = 1;
+                               c.gridy = 0;
+                               c.weightx = 0;
+                               c.weighty = 0;
+                               c.fill = GridBagConstraints.NONE;
+                               c.anchor = GridBagConstraints.WEST;
+                               bag.add (telemetry, c);
+                               c.insets = new Insets(0, 0, 0, 0);
                        }
                }
 
index 63d862918ae8cc467eafadfe4d7d586d71d65af0..67b7a9897717a2aea529ae383916babb946ffdda 100644 (file)
@@ -103,7 +103,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
        }
 
        Container       bag;
-       AltosFreqList   frequencies;
+       AltosUIFreqList frequencies;
        JTextField      callsign_value;
 
        /* DocumentListener interface methods */
@@ -200,7 +200,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
                /* Stick frequency selector at top of table for telemetry monitoring */
                if (remote && serial >= 0) {
                        // Frequency menu
-                       frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
+                       frequencies = new AltosUIFreqList(AltosUIPreferences.frequency(serial));
                        frequencies.addActionListener(new ActionListener() {
                                        public void actionPerformed(ActionEvent e) {
                                                double frequency = frequencies.frequency();
diff --git a/altosuilib/AltosFreqList.java b/altosuilib/AltosFreqList.java
deleted file mode 100644 (file)
index 293ce03..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright © 2011 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.altosuilib_3;
-
-import java.util.*;
-import javax.swing.*;
-import java.awt.event.*;
-import org.altusmetrum.altoslib_5.*;
-
-class FreqEntry extends JMenuItem {
-       AltosFrequency  frequency;
-
-       public FreqEntry(AltosFrequency frequency) {
-               super(frequency.toShortString());
-               this.frequency = frequency;
-       }
-}
-
-public class AltosFreqList extends JMenu implements ActionListener {
-
-       String  product;
-       int     serial;
-       int     calibrate;
-
-       AltosFrequency[]        frequencies = new AltosFrequency[0];
-
-       int     selected = -1;
-
-       LinkedList<ActionListener> action_listeners = new LinkedList<ActionListener>();
-
-       public void addActionListener(ActionListener listener) {
-               action_listeners.add(listener);
-       }
-
-       public void removeActionListener(ActionListener listener) {
-               action_listeners.remove(listener);
-       }
-
-       public void actionPerformed(ActionEvent ev) {
-               FreqEntry e = (FreqEntry) ev.getSource();
-               set_selected(e.frequency);
-               ActionEvent event = new ActionEvent(e.frequency, 0, "selected");
-               for (ActionListener l : action_listeners)
-                       l.actionPerformed(event);
-       }
-
-       boolean label = true;
-
-       public void set_label(boolean label) {
-               this.label = label;
-               set_label();
-       }
-
-       private void set_label() {
-               String  new_text = "";
-               if (0 <= selected && selected < frequencies.length) {
-                       AltosFrequency  frequency = frequencies[selected];
-                       new_text = String.format("%s%7.3f MHz (%s) ▾",
-                                                label ? "Frequency: " : "",
-                                                frequency.frequency,
-                                                frequency.description);
-               }
-               setText(new_text);
-       }
-
-       private void set_selected(AltosFrequency frequency) {
-               for (int i = 0; i < frequencies.length; i++) {
-                       if (frequencies[i].frequency == frequency.frequency) {
-                               selected = i;
-                               set_label();
-                       }
-               }
-       }
-
-       private AltosFrequency get_selected() {
-               if (0 <= selected && selected < frequencies.length)
-                       return frequencies[selected];
-               return null;
-       }
-
-       private void add(AltosFrequency add) {
-               int insert;
-
-               for (insert = 0; insert < frequencies.length; insert++) {
-                       if (frequencies[insert].frequency == add.frequency)
-                               return;
-                       if (add.frequency < frequencies[insert].frequency)
-                               break;
-               }
-
-               AltosFrequency[]        new_frequencies = new AltosFrequency[frequencies.length + 1];
-
-               for (int before = 0; before < insert; before++)
-                       new_frequencies[before] = frequencies[before];
-               new_frequencies[insert] = add;
-
-               for (int after = insert; after < frequencies.length; after++)
-                       new_frequencies[after+1] = frequencies[after];
-
-               frequencies = new_frequencies;
-
-               FreqEntry       e = new FreqEntry(add);
-               add(e, insert);
-               e.addActionListener(this);
-       }
-
-       private void remove(AltosFrequency remove) {
-               int delete;
-               for (delete = 0; delete < frequencies.length; delete++) {
-                       if (frequencies[delete].frequency == remove.frequency)
-                               break;
-                       if (remove.frequency < frequencies[delete].frequency)
-                               return;
-               }
-
-               remove(delete);
-
-               AltosFrequency[]        new_frequencies = new AltosFrequency[frequencies.length - 1];
-
-               for (int before = 0; before < delete; before++)
-                       new_frequencies[before] = frequencies[before];
-
-               for (int after = delete + 1; after < frequencies.length; after++)
-                       new_frequencies[after-1] = frequencies[after];
-               frequencies = new_frequencies;
-       }
-
-       public void set_frequency(double new_frequency) {
-               int i;
-
-               if (new_frequency < 0) {
-                       setVisible(false);
-                       return;
-               }
-
-               for (i = 0; i < frequencies.length; i++) {
-                       AltosFrequency  f = frequencies[i];
-
-                       if (f.close(new_frequency)) {
-                               set_selected(f);
-                               return;
-                       }
-               }
-
-               String  description = String.format("%s serial %d", product, serial);
-               AltosFrequency  frequency = new AltosFrequency(new_frequency, description);
-               AltosUIPreferences.add_common_frequency(frequency);
-
-               add(frequency);
-               set_selected(frequency);
-       }
-
-       public void set_product(String new_product) {
-               product = new_product;
-       }
-
-       public void set_serial(int new_serial) {
-               serial = new_serial;
-       }
-
-       public double frequency() {
-               AltosFrequency  f = get_selected();
-               if (f != null)
-                       return f.frequency;
-               return 434.550;
-       }
-
-       public AltosFreqList(double in_frequency, boolean label) {
-               super();
-               this.label = label;
-
-               for (AltosFrequency frequency: AltosUIPreferences.common_frequencies())
-                       add(frequency);
-               product = "Unknown";
-               serial = 0;
-
-               if (in_frequency != 0)
-                       set_frequency(in_frequency);
-       }
-       public AltosFreqList(double in_frequency) {
-               this(in_frequency, true);
-       }
-
-       public AltosFreqList (boolean label) {
-               this(0, label);
-       }
-
-       public AltosFreqList () {
-               this(0, true);
-       }
-}
diff --git a/altosuilib/AltosUIFreqList.java b/altosuilib/AltosUIFreqList.java
new file mode 100644 (file)
index 0000000..f1f83dd
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altosuilib_3;
+
+import javax.swing.*;
+import org.altusmetrum.altoslib_5.*;
+
+public class AltosUIFreqList extends JComboBox<AltosFrequency> {
+
+       String  product;
+       int     serial;
+       int     calibrate;
+
+       public void set_frequency(double new_frequency) {
+               int i;
+
+               if (new_frequency < 0) {
+                       setVisible(false);
+                       return;
+               }
+
+               for (i = 0; i < getItemCount(); i++) {
+                       AltosFrequency  f = (AltosFrequency) getItemAt(i);
+
+                       if (f.close(new_frequency)) {
+                               setSelectedIndex(i);
+                               return;
+                       }
+               }
+               for (i = 0; i < getItemCount(); i++) {
+                       AltosFrequency  f = (AltosFrequency) getItemAt(i);
+
+                       if (new_frequency < f.frequency)
+                               break;
+               }
+               String  description = String.format("%s serial %d", product, serial);
+               AltosFrequency  frequency = new AltosFrequency(new_frequency, description);
+               AltosUIPreferences.add_common_frequency(frequency);
+               insertItemAt(frequency, i);
+               setMaximumRowCount(getItemCount());
+       }
+
+       public void set_product(String new_product) {
+               product = new_product;
+       }
+
+       public void set_serial(int new_serial) {
+               serial = new_serial;
+       }
+
+       public double frequency() {
+               AltosFrequency  f = (AltosFrequency) getSelectedItem();
+               if (f != null)
+                       return f.frequency;
+               return 434.550;
+       }
+
+       public AltosUIFreqList () {
+               super(AltosUIPreferences.common_frequencies());
+               setMaximumRowCount(getItemCount());
+               setEditable(false);
+               product = "Unknown";
+               serial = 0;
+       }
+
+       public AltosUIFreqList(double in_frequency) {
+               this();
+               set_frequency(in_frequency);
+       }
+}
diff --git a/altosuilib/AltosUITelemetryList.java b/altosuilib/AltosUITelemetryList.java
new file mode 100644 (file)
index 0000000..facfdcd
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2014 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altosuilib_3;
+
+import java.util.*;
+import javax.swing.*;
+import org.altusmetrum.altoslib_5.*;
+
+
+public class AltosUITelemetryList extends JComboBox<String> {
+       public int get_selected() {
+               return getSelectedIndex() + 1;
+       }
+
+       public void set_selected(int telemetry) {
+               setSelectedIndex(telemetry-1);
+       }
+
+       public AltosUITelemetryList(int serial) {
+               super();
+               for (int i = AltosLib.ao_telemetry_min; i <= AltosLib.ao_telemetry_max; i++)
+                       addItem(AltosLib.telemetry_name(i));
+
+               int telemetry = AltosPreferences.telemetry(serial);
+               if (telemetry < AltosLib.ao_telemetry_min || AltosLib.ao_telemetry_max < telemetry)
+                       telemetry = AltosLib.ao_telemetry_standard;
+               setMaximumRowCount(AltosLib.ao_telemetry_max);
+               set_selected(telemetry);
+               revalidate();
+       }
+}
+
diff --git a/altosuilib/AltosUITelemetryMenu.java b/altosuilib/AltosUITelemetryMenu.java
deleted file mode 100644 (file)
index 893c3c4..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright © 2014 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.altosuilib_3;
-
-import java.util.*;
-import javax.swing.*;
-import java.awt.event.*;
-import org.altusmetrum.altoslib_5.*;
-
-class TelemetryMenuItem extends JMenuItem {
-       public int      telemetry;
-
-       public TelemetryMenuItem (int telemetry) {
-               super(AltosLib.telemetry_name(telemetry));
-               this.telemetry = telemetry;
-       }
-}
-
-public class AltosUITelemetryMenu extends JMenu implements ActionListener {
-       TelemetryMenuItem       selected = null;
-
-       public int get_selected() {
-               if (selected == null)
-                       return AltosLib.ao_telemetry_off;
-               return selected.telemetry;
-       }
-
-       public void set_selected(int telemetry) {
-               for (int i = 0; i < getItemCount(); i++) {
-                       TelemetryMenuItem       item = (TelemetryMenuItem) getItem(i);
-                       if (item.telemetry == telemetry) {
-                               selected = item;
-                               String new_text = String.format("Format: %s ▾", AltosLib.telemetry_name(telemetry));
-                               setText(new_text);
-                               break;
-                       }
-               }
-       }
-
-       private LinkedList<ActionListener> action_listeners = new LinkedList<ActionListener>();
-
-       public void addActionListener(ActionListener l) {
-               action_listeners.add(l);
-       }
-
-       public void removeActionListener(ActionListener l) {
-               action_listeners.remove(l);
-       }
-
-       public void actionPerformed(ActionEvent e) {
-               TelemetryMenuItem item = (TelemetryMenuItem) e.getSource();
-               set_selected(item.telemetry);
-               ActionEvent my_e = new ActionEvent(selected, 0, "selected");
-               for (ActionListener l : action_listeners)
-                       l.actionPerformed(my_e);
-       }
-
-       public AltosUITelemetryMenu(int serial) {
-               super();
-               for (int i = AltosLib.ao_telemetry_min; i <= AltosLib.ao_telemetry_max; i++) {
-                       TelemetryMenuItem       item = new TelemetryMenuItem(i);
-
-                       item.addActionListener(this);
-                       add(item);
-               }
-
-               int telemetry = AltosPreferences.telemetry(serial);
-               if (telemetry < AltosLib.ao_telemetry_min || AltosLib.ao_telemetry_max < telemetry)
-                       telemetry = AltosLib.ao_telemetry_standard;
-               set_selected(telemetry);
-       }
-}
-
index 56b01ec53fbf182c78739a6bf888d2eec1708221..40e6dda52ac80e28738a544e95bd8f291dd08bd5 100644 (file)
@@ -36,7 +36,6 @@ altosuilib_JAVA = \
        AltosVoice.java \
        AltosDisplayThread.java \
        AltosDeviceUIDialog.java \
-       AltosFreqList.java \
        AltosSerial.java \
        AltosSerialInUseException.java \
        AltosConfigFreqUI.java \
@@ -82,7 +81,8 @@ altosuilib_JAVA = \
        AltosUIIndicator.java \
        AltosUIUnitsIndicator.java \
        AltosUIVoltageIndicator.java \
-       AltosUITelemetryMenu.java \
+       AltosUIFreqList.java \
+       AltosUITelemetryList.java \
        OSXAdapter.java
 
 JAR=altosuilib_$(ALTOSUILIB_VERSION).jar
index e78c2124ab5142102b7a6da44fc55e49b720dc19..7e5ff42aa86c0696445c719da12e2745980dac06 100644 (file)
@@ -58,7 +58,7 @@ public class TeleGPS
        JMenu                   file_menu;
        JMenu                   monitor_menu;
        JMenu                   device_menu;
-       AltosFreqList           frequencies;
+       AltosUIFreqList         frequencies;
        ActionListener          frequency_listener;
 
        Container               bag;
@@ -351,18 +351,17 @@ public class TeleGPS
                frequencies.set_product("Monitor");
                frequencies.set_serial(serial);
                frequencies.set_frequency(AltosUIPreferences.frequency(serial));
+               frequencies.setEnabled(true);
 
-               menu_bar.add(frequencies);
-               menu_bar.repaint();
        }
 
        void disable_frequency_menu() {
-               if (frequency_listener == null)
-                       return;
-               frequencies.removeActionListener(frequency_listener);
-               menu_bar.remove(frequencies);
-               menu_bar.repaint();
-               frequency_listener = null;
+               if (frequency_listener != null) {
+                       frequencies.removeActionListener(frequency_listener);
+                       frequencies.setEnabled(false);
+                       frequency_listener = null;
+               }
+
        }
 
        public void set_reader(AltosFlightReader reader, AltosDevice device) {
@@ -457,7 +456,16 @@ public class TeleGPS
                file_menu = make_menu("File", file_menu_entries);
                monitor_menu = make_menu("Monitor", monitor_menu_entries);
                device_menu = make_menu("Device", device_menu_entries);
-               frequencies = new AltosFreqList();
+
+               frequencies = new AltosUIFreqList();
+               frequencies.setEnabled(false);
+               c.gridx = 0;
+               c.gridy = 0;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.WEST;
+               c.weightx = 0;
+               c.gridwidth = 1;
+               bag.add(frequencies, c);
 
                displays = new LinkedList<AltosFlightDisplay>();
 
index ee2fbd2dfea39a43afa6b771fb4aac9aab14ebd1..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++;