altosui: Add callsign configuration in AltosUI configuration dialog
authorKeith Packard <keithp@keithp.com>
Tue, 16 Nov 2010 13:49:59 +0000 (21:49 +0800)
committerKeith Packard <keithp@keithp.com>
Tue, 16 Nov 2010 13:49:59 +0000 (21:49 +0800)
This callsign is used during packet communication.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/AltosConfigUI.java
ao-tools/altosui/AltosConfigureUI.java

index e04933eb87bc5c2ebb6317bb18cfd8b40014222f..ca89f58d39de23b6f9becc002336efe0e43639e3 100644 (file)
@@ -288,7 +288,7 @@ public class AltosConfigUI
                c.anchor = GridBagConstraints.LINE_START;
                c.insets = ir;
                c.ipady = 5;
-               callsign_value = new JTextField("N0CALL");
+               callsign_value = new JTextField(AltosPreferences.callsign());
                callsign_value.getDocument().addDocumentListener(this);
                pane.add(callsign_value, c);
 
index 88c180f1f07a1f487fa4b3ddc9f5ccb774b1e85d..64c17eaffd38937bfeda2b98a69283a5773f7333 100644 (file)
@@ -22,13 +22,17 @@ import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.table.*;
+import javax.swing.event.*;
 import java.io.*;
 import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
 
-public class AltosConfigureUI extends JDialog {
+public class AltosConfigureUI
+       extends JDialog
+       implements DocumentListener
+{
        JFrame          owner;
        AltosVoice      voice;
        Container       pane;
@@ -40,6 +44,22 @@ public class AltosConfigureUI extends JDialog {
        JButton         configure_log;
        JTextField      log_directory;
 
+       JLabel          callsign_label;
+       JTextField      callsign_value;
+
+       /* DocumentListener interface methods */
+       public void changedUpdate(DocumentEvent e) {
+               AltosPreferences.set_callsign(callsign_value.getText());
+       }
+
+       public void insertUpdate(DocumentEvent e) {
+               changedUpdate(e);
+       }
+
+       public void removeUpdate(DocumentEvent e) {
+               changedUpdate(e);
+       }
+
        public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) {
                super(in_owner, "Configure AltosUI", false);
 
@@ -83,17 +103,6 @@ public class AltosConfigureUI extends JDialog {
                        });
                pane.add(test_voice, c);
 
-               close = new JButton("Close");
-               close.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       setVisible(false);
-                               }
-                       });
-               c.gridx = 0;
-               c.gridy = 3;
-               c.gridwidth = 2;
-               pane.add(close, c);
-
                configure_log = new JButton("Configure Log");
                configure_log.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
@@ -113,6 +122,29 @@ public class AltosConfigureUI extends JDialog {
                c.fill = GridBagConstraints.BOTH;
                pane.add(log_directory, c);
 
+               callsign_label = new JLabel("Callsign");
+               c.gridx = 0;
+               c.gridy = 3;
+               pane.add(callsign_label, c);
+
+               callsign_value = new JTextField(AltosPreferences.callsign());
+               callsign_value.getDocument().addDocumentListener(this);
+               c.gridx = 1;
+               c.gridy = 3;
+               pane.add(callsign_value, c);
+
+               close = new JButton("Close");
+               close.addActionListener(new ActionListener() {
+                               public void actionPerformed(ActionEvent e) {
+                                       setVisible(false);
+                               }
+                       });
+               c.gridx = 0;
+               c.gridy = 4;
+               c.gridwidth = 2;
+               c.fill = GridBagConstraints.NONE;
+               pane.add(close, c);
+
                pack();
                setLocationRelativeTo(owner);
                setVisible(true);