2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 package org.altusmetrum.telegps;
22 import java.awt.event.*;
25 import javax.swing.event.*;
26 import org.altusmetrum.altosuilib_14.*;
28 public class TeleGPSPreferences
29 extends AltosUIConfigure
30 implements DocumentListener
34 public JTextField callsign_value;
35 public JComboBox<String> position_value;
37 /* DocumentListener interface methods */
38 public void insertUpdate(DocumentEvent e) {
42 public void removeUpdate(DocumentEvent e) {
46 public void changedUpdate(DocumentEvent e) {
47 if (callsign_value != null)
48 AltosUIPreferences.set_callsign(callsign_value.getText());
51 public void add_voice() {
54 pane.add(new JLabel("Voice"), constraints(0, 1));
56 JRadioButton enable_voice = new JRadioButton("Enable", AltosUIPreferences.voice());
57 enable_voice.addActionListener(new ActionListener() {
58 public void actionPerformed(ActionEvent e) {
59 JRadioButton item = (JRadioButton) e.getSource();
60 boolean enabled = item.isSelected();
61 AltosUIPreferences.set_voice(enabled);
63 voice.speak_always("Enable voice.");
65 voice.speak_always("Disable voice.");
68 pane.add(enable_voice, constraints(1, 1));
69 enable_voice.setToolTipText("Enable/Disable all audio in-flight announcements");
71 JButton test_voice = new JButton("Test Voice");
72 test_voice.addActionListener(new ActionListener() {
73 public void actionPerformed(ActionEvent e) {
74 voice.speak("That's one small step for man; one giant leap for mankind.");
77 pane.add(test_voice, constraints(2, 1));
78 test_voice.setToolTipText("Play a stock audio clip to check volume");
82 public void add_callsign() {
83 /* Callsign setting */
84 pane.add(new JLabel("Callsign"), constraints(0, 1));
86 callsign_value = new JTextField(AltosUIPreferences.callsign());
87 callsign_value.getDocument().addDocumentListener(this);
88 callsign_value.setToolTipText("Callsign sent in packet mode");
89 pane.add(callsign_value, constraints(1, 2, GridBagConstraints.BOTH));
93 public void add_bluetooth() {
94 JButton manage_bluetooth = new JButton("Manage Bluetooth");
95 manage_bluetooth.addActionListener(new ActionListener() {
96 public void actionPerformed(ActionEvent e) {
97 AltosBTManage.show(owner, AltosBTKnown.bt_known());
100 pane.add(manage_bluetooth, constraints(0, 2));
101 /* in the same row as add_frequencies, so don't bump row */
104 public void add_frequencies() {
105 JButton manage_frequencies = new JButton("Manage Frequencies");
106 manage_frequencies.addActionListener(new ActionListener() {
107 public void actionPerformed(ActionEvent e) {
108 AltosConfigFreqUI.show(owner);
111 manage_frequencies.setToolTipText("Configure which values are shown in frequency menus");
112 pane.add(manage_frequencies, constraints(2, 1));
116 public TeleGPSPreferences(JFrame owner, AltosVoice voice) {
117 super(owner, "TeleGPS Preferences", "Configure TeleGPS");