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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.awt.event.*;
23 import javax.swing.filechooser.FileNameExtensionFilter;
24 import javax.swing.table.*;
25 import javax.swing.event.*;
29 import java.util.prefs.*;
30 import java.util.concurrent.LinkedBlockingQueue;
32 public class AltosConfigureUI
34 implements DocumentListener
40 JRadioButton enable_voice;
44 JButton configure_log;
45 JTextField log_directory;
47 JLabel callsign_label;
48 JTextField callsign_value;
50 /* DocumentListener interface methods */
51 public void changedUpdate(DocumentEvent e) {
52 AltosPreferences.set_callsign(callsign_value.getText());
55 public void insertUpdate(DocumentEvent e) {
59 public void removeUpdate(DocumentEvent e) {
63 public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) {
64 super(in_owner, "Configure AltosUI", false);
68 Insets insets = new Insets(4, 4, 4, 4);
72 pane = getContentPane();
73 pane.setLayout(new GridBagLayout());
75 c = new GridBagConstraints();
77 c.fill = GridBagConstraints.NONE;
78 c.anchor = GridBagConstraints.WEST;
80 /* Nice label at the top */
84 c.fill = GridBagConstraints.NONE;
85 c.anchor = GridBagConstraints.CENTER;
86 pane.add(new JLabel ("Configure AltOS UI"), c);
92 c.fill = GridBagConstraints.NONE;
93 c.anchor = GridBagConstraints.WEST;
94 pane.add(new JLabel("Voice"), c);
96 enable_voice = new JRadioButton("Enable", AltosPreferences.voice());
97 enable_voice.addActionListener(new ActionListener() {
98 public void actionPerformed(ActionEvent e) {
99 JRadioButton item = (JRadioButton) e.getSource();
100 boolean enabled = item.isSelected();
101 AltosPreferences.set_voice(enabled);
103 voice.speak_always("Enable voice.");
105 voice.speak_always("Disable voice.");
112 c.fill = GridBagConstraints.NONE;
113 c.anchor = GridBagConstraints.WEST;
114 pane.add(enable_voice, c);
120 c.fill = GridBagConstraints.NONE;
121 c.anchor = GridBagConstraints.EAST;
122 test_voice = new JButton("Test Voice");
123 test_voice.addActionListener(new ActionListener() {
124 public void actionPerformed(ActionEvent e) {
125 voice.speak("That's one small step for man; one giant leap for mankind.");
128 pane.add(test_voice, c);
130 /* Log directory settings */
134 c.fill = GridBagConstraints.NONE;
135 c.anchor = GridBagConstraints.WEST;
136 pane.add(new JLabel("Log Directory"), c);
138 configure_log = new JButton(AltosPreferences.logdir().getPath());
139 configure_log.addActionListener(new ActionListener() {
140 public void actionPerformed(ActionEvent e) {
141 AltosPreferences.ConfigureLog();
142 configure_log.setText(AltosPreferences.logdir().getPath());
148 c.fill = GridBagConstraints.BOTH;
149 c.anchor = GridBagConstraints.WEST;
150 pane.add(configure_log, c);
152 /* Callsign setting */
156 c.fill = GridBagConstraints.NONE;
157 c.anchor = GridBagConstraints.WEST;
158 pane.add(new JLabel("Callsign"), c);
160 callsign_value = new JTextField(AltosPreferences.callsign());
161 callsign_value.getDocument().addDocumentListener(this);
165 c.fill = GridBagConstraints.BOTH;
166 c.anchor = GridBagConstraints.WEST;
167 pane.add(callsign_value, c);
169 /* And a close button at the bottom */
170 close = new JButton("Close");
171 close.addActionListener(new ActionListener() {
172 public void actionPerformed(ActionEvent e) {
179 c.fill = GridBagConstraints.NONE;
180 c.anchor = GridBagConstraints.CENTER;
184 setLocationRelativeTo(owner);