1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/*
* Copyright © 2010 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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 altosui;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.event.*;
import org.altusmetrum.altosuilib_14.*;
public class AltosConfigureUI
extends AltosUIConfigure
implements DocumentListener
{
AltosVoice voice;
public JTextField callsign_value;
public JComboBox<String> position_value;
/* DocumentListener interface methods */
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
}
public void changedUpdate(DocumentEvent e) {
if (callsign_value != null)
AltosUIPreferences.set_callsign(callsign_value.getText());
}
public void add_voice() {
/* Voice settings */
pane.add(new JLabel("Voice"), constraints(0, 1));
JRadioButton enable_voice = new JRadioButton("Enable", AltosUIPreferences.voice());
enable_voice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JRadioButton item = (JRadioButton) e.getSource();
boolean enabled = item.isSelected();
AltosUIPreferences.set_voice(enabled);
if (enabled)
voice.speak_always("Enable voice.");
else
voice.speak_always("Disable voice.");
}
});
pane.add(enable_voice, constraints(1, 1));
enable_voice.setToolTipText("Enable/Disable all audio in-flight announcements");
JButton test_voice = new JButton("Test Voice");
test_voice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
voice.speak("That's one small step for man; one giant leap for mankind.");
}
});
pane.add(test_voice, constraints(2, 1));
test_voice.setToolTipText("Play a stock audio clip to check volume");
row++;
}
public void add_callsign() {
/* Callsign setting */
pane.add(new JLabel("Callsign"), constraints(0, 1));
callsign_value = new JTextField(AltosUIPreferences.callsign());
callsign_value.getDocument().addDocumentListener(this);
callsign_value.setToolTipText("Callsign sent in packet mode");
pane.add(callsign_value, constraints(1, 2, GridBagConstraints.BOTH));
row++;
}
boolean has_bluetooth;
public void add_bluetooth() {
JButton manage_bluetooth = new JButton("Manage Bluetooth");
manage_bluetooth.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AltosBTManage.show(owner, AltosBTKnown.bt_known());
}
});
pane.add(manage_bluetooth, constraints(0, 2));
/* in the same row as add_frequencies, so don't bump row */
has_bluetooth = true;
}
public void add_frequencies() {
JButton manage_frequencies = new JButton("Manage Frequencies");
manage_frequencies.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AltosConfigFreqUI.show(owner);
}
});
manage_frequencies.setToolTipText("Configure which values are shown in frequency menus");
if (has_bluetooth)
pane.add(manage_frequencies, constraints(2, 1));
else
pane.add(manage_frequencies, constraints(0, 3));
row++;
}
final static String[] position_names = {
"Top left",
"Top",
"Top right",
"Left",
"Center",
"Right",
"Bottom left",
"Bottom",
"Bottom right",
};
public void add_position() {
pane.add(new JLabel ("Menu position"), constraints(0, 1));
position_value = new JComboBox<String>(position_names);
position_value.setMaximumRowCount(position_names.length);
int position = AltosUIPreferences.position();
position_value.setSelectedIndex(position);
position_value.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int position = position_value.getSelectedIndex();
AltosUIPreferences.set_position(position);
}
});
pane.add(position_value, constraints(1, 2, GridBagConstraints.BOTH));
position_value.setToolTipText("Position of main AltosUI window");
row++;
}
public AltosConfigureUI(JFrame owner, AltosVoice voice) {
super(owner);
this.voice = voice;
}
}
|