altosui: Use shared AltosDeviceDialog
authorKeith Packard <keithp@keithp.com>
Wed, 2 Jan 2013 17:31:35 +0000 (09:31 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 2 Jan 2013 17:31:35 +0000 (09:31 -0800)
Signed-off-by: Keith Packard <keithp@keithp.com>
21 files changed:
altosui/AltosBTDevice.java
altosui/AltosBTKnown.java
altosui/AltosConfig.java
altosui/AltosConfigTD.java
altosui/AltosDebug.java
altosui/AltosDeviceDialog.java [deleted file]
altosui/AltosDeviceUIDialog.java [new file with mode: 0644]
altosui/AltosEepromManage.java
altosui/AltosFlash.java
altosui/AltosFlashUI.java
altosui/AltosIdleMonitorUI.java
altosui/AltosIgniteUI.java
altosui/AltosLaunch.java
altosui/AltosLaunchUI.java
altosui/AltosScanUI.java
altosui/AltosSerial.java
altosui/AltosSerialInUseException.java
altosui/AltosUI.java
altosui/AltosUSBDevice.java
altosui/Makefile.am
altosuilib/AltosDeviceDialog.java

index 03e7cbeca929c97e4030b76c0346df4bd99f6b3d..222b3c97a1e6cb90b2ef50f899ff8d07fe9eba91 100644 (file)
@@ -17,6 +17,7 @@
 
 package altosui;
 import libaltosJNI.*;
 
 package altosui;
 import libaltosJNI.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosBTDevice extends altos_bt_device implements AltosDevice {
 
 
 public class AltosBTDevice extends altos_bt_device implements AltosDevice {
 
index ae04ac8ce010757c35fb06d91a227b47a66554e9..606c0349fe526ccf41ccfc008ce70c0af1af53d8 100644 (file)
@@ -18,6 +18,7 @@
 package altosui;
 import java.util.*;
 import org.altusmetrum.AltosLib.*;
 package altosui;
 import java.util.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosBTKnown implements Iterable<AltosBTDevice> {
        LinkedList<AltosBTDevice>       devices = new LinkedList<AltosBTDevice>();
 
 public class AltosBTKnown implements Iterable<AltosBTDevice> {
        LinkedList<AltosBTDevice>       devices = new LinkedList<AltosBTDevice>();
index e1ffebb4b95f1129144e1a86c70dadf2915ae78d..1cd61a89fa32b4d5c0006813f747d02c307bdb89 100644 (file)
@@ -21,8 +21,9 @@ import java.awt.event.*;
 import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
 import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
 import java.text.*;
 import java.text.*;
+import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosConfig implements ActionListener {
 
 
 public class AltosConfig implements ActionListener {
 
@@ -270,7 +271,7 @@ public class AltosConfig implements ActionListener {
        public AltosConfig(JFrame given_owner) {
                owner = given_owner;
 
        public AltosConfig(JFrame given_owner) {
                owner = given_owner;
 
-               device = AltosDeviceDialog.show(owner, Altos.product_any);
+               device = AltosDeviceUIDialog.show(owner, Altos.product_any);
                if (device != null) {
                        try {
                                serial_line = new AltosSerial(device);
                if (device != null) {
                        try {
                                serial_line = new AltosSerial(device);
index e7b9b81f691cbf085c5d73f50cc379664ac3fe15..794f8103c26e759f2be90a2a1161554a4588e2f7 100644 (file)
@@ -21,8 +21,8 @@ import java.awt.event.*;
 import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
 import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
-
 import org.altusmetrum.AltosLib.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosConfigTD implements ActionListener {
 
 
 public class AltosConfigTD implements ActionListener {
 
@@ -315,7 +315,7 @@ public class AltosConfigTD implements ActionListener {
                version = new string_ref("unknown");
                product = new string_ref("unknown");
 
                version = new string_ref("unknown");
                product = new string_ref("unknown");
 
-               device = AltosDeviceDialog.show(owner, Altos.product_basestation);
+               device = AltosDeviceUIDialog.show(owner, Altos.product_basestation);
                if (device != null) {
                        try {
                                serial_line = new AltosSerial(device);
                if (device != null) {
                        try {
                                serial_line = new AltosSerial(device);
index 16b10c3af2b07bf278a59f20952723ef2e8fb57b..482f4c3650d918a16c2651840196387e6c9b4960 100644 (file)
@@ -18,6 +18,7 @@
 package altosui;
 
 import java.io.*;
 package altosui;
 
 import java.io.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosDebug extends AltosSerial {
 
 
 public class AltosDebug extends AltosSerial {
 
diff --git a/altosui/AltosDeviceDialog.java b/altosui/AltosDeviceDialog.java
deleted file mode 100644 (file)
index 0aeadae..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * 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; 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 altosui;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
-
-public class AltosDeviceDialog extends AltosDialog implements ActionListener {
-
-       private AltosDevice     value;
-       private JList           list;
-       private JButton         cancel_button;
-       private JButton         select_button;
-       private JButton         manage_bluetooth_button;
-       private Frame           frame;
-       private int             product;
-
-       private AltosDevice getValue() {
-               return value;
-       }
-
-       private AltosDevice[] devices() {
-               java.util.List<AltosDevice>     usb_devices = AltosUSBDevice.list(product);
-               int                             num_devices = usb_devices.size();
-               java.util.List<AltosDevice>     bt_devices = AltosBTKnown.bt_known().list(product);
-               num_devices += bt_devices.size();
-               AltosDevice[]                   devices = new AltosDevice[num_devices];
-
-               for (int i = 0; i < usb_devices.size(); i++)
-                       devices[i] = usb_devices.get(i);
-               int off = usb_devices.size();
-               for (int j = 0; j < bt_devices.size(); j++)
-                       devices[off + j] = bt_devices.get(j);
-               return devices;
-       }
-
-       private void update_devices() {
-               AltosDevice[] devices = devices();
-               list.setListData(devices);
-               select_button.setEnabled(devices.length > 0);
-       }
-
-       private AltosDeviceDialog (Frame in_frame, Component location, int in_product) {
-               super(in_frame, "Device Selection", true);
-
-               product = in_product;
-               frame = in_frame;
-               value = null;
-
-               AltosDevice[]   devices = devices();
-
-               cancel_button = new JButton("Cancel");
-               cancel_button.setActionCommand("cancel");
-               cancel_button.addActionListener(this);
-
-               manage_bluetooth_button = new JButton("Manage Bluetooth");
-               manage_bluetooth_button.setActionCommand("manage");
-               manage_bluetooth_button.addActionListener(this);
-
-               select_button = new JButton("Select");
-               select_button.setActionCommand("select");
-               select_button.addActionListener(this);
-               if (devices.length == 0)
-                       select_button.setEnabled(false);
-               getRootPane().setDefaultButton(select_button);
-
-               list = new JList(devices) {
-                               //Subclass JList to workaround bug 4832765, which can cause the
-                               //scroll pane to not let the user easily scroll up to the beginning
-                               //of the list.  An alternative would be to set the unitIncrement
-                               //of the JScrollBar to a fixed value. You wouldn't get the nice
-                               //aligned scrolling, but it should work.
-                               public int getScrollableUnitIncrement(Rectangle visibleRect,
-                                                                     int orientation,
-                                                                     int direction) {
-                                       int row;
-                                       if (orientation == SwingConstants.VERTICAL &&
-                                           direction < 0 && (row = getFirstVisibleIndex()) != -1) {
-                                               Rectangle r = getCellBounds(row, row);
-                                               if ((r.y == visibleRect.y) && (row != 0))  {
-                                                       Point loc = r.getLocation();
-                                                       loc.y--;
-                                                       int prevIndex = locationToIndex(loc);
-                                                       Rectangle prevR = getCellBounds(prevIndex, prevIndex);
-
-                                                       if (prevR == null || prevR.y >= r.y) {
-                                                               return 0;
-                                                       }
-                                                       return prevR.height;
-                                               }
-                                       }
-                                       return super.getScrollableUnitIncrement(
-                                               visibleRect, orientation, direction);
-                               }
-                       };
-
-               list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-               list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
-               list.setVisibleRowCount(-1);
-               list.addMouseListener(new MouseAdapter() {
-                                public void mouseClicked(MouseEvent e) {
-                                        if (e.getClickCount() == 2) {
-                                                select_button.doClick(); //emulate button click
-                                        }
-                                }
-                       });
-               JScrollPane listScroller = new JScrollPane(list);
-               listScroller.setPreferredSize(new Dimension(400, 80));
-               listScroller.setAlignmentX(LEFT_ALIGNMENT);
-
-               //Create a container so that we can add a title around
-               //the scroll pane.  Can't add a title directly to the
-               //scroll pane because its background would be white.
-               //Lay out the label and scroll pane from top to bottom.
-               JPanel listPane = new JPanel();
-               listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
-
-               JLabel label = new JLabel("Select Device");
-               label.setLabelFor(list);
-               listPane.add(label);
-               listPane.add(Box.createRigidArea(new Dimension(0,5)));
-               listPane.add(listScroller);
-               listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
-               //Lay out the buttons from left to right.
-               JPanel buttonPane = new JPanel();
-               buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
-               buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
-               buttonPane.add(Box.createHorizontalGlue());
-               buttonPane.add(cancel_button);
-               buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
-               buttonPane.add(manage_bluetooth_button);
-               buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
-               buttonPane.add(select_button);
-
-               //Put everything together, using the content pane's BorderLayout.
-               Container contentPane = getContentPane();
-               contentPane.add(listPane, BorderLayout.CENTER);
-               contentPane.add(buttonPane, BorderLayout.PAGE_END);
-
-               //Initialize values.
-               if (devices != null && devices.length != 0)
-                       list.setSelectedValue(devices[0], true);
-               pack();
-               setLocationRelativeTo(location);
-       }
-
-       //Handle clicks on the Set and Cancel buttons.
-       public void actionPerformed(ActionEvent e) {
-               if ("select".equals(e.getActionCommand()))
-                       value = (AltosDevice)(list.getSelectedValue());
-               if ("manage".equals(e.getActionCommand())) {
-                       AltosBTManage.show(frame, AltosBTKnown.bt_known());
-                       update_devices();
-                       return;
-               }
-               setVisible(false);
-       }
-
-       public static AltosDevice show (Component frameComp, int product) {
-
-               Frame                           frame = JOptionPane.getFrameForComponent(frameComp);
-               AltosDeviceDialog       dialog;
-
-               dialog = new AltosDeviceDialog(frame, frameComp, product);
-               dialog.setVisible(true);
-               return dialog.getValue();
-       }
-}
diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java
new file mode 100644 (file)
index 0000000..7ed599a
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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; 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 altosui;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import org.altusmetrum.altosuilib.*;
+
+public class AltosDeviceUIDialog extends AltosDeviceDialog {
+
+       public AltosDevice[] devices() {
+               java.util.List<AltosDevice>     usb_devices = AltosUSBDevice.list(product);
+               int                             num_devices = usb_devices.size();
+               java.util.List<AltosDevice>     bt_devices = AltosBTKnown.bt_known().list(product);
+               num_devices += bt_devices.size();
+               AltosDevice[]                   devices = new AltosDevice[num_devices];
+
+               for (int i = 0; i < usb_devices.size(); i++)
+                       devices[i] = usb_devices.get(i);
+               int off = usb_devices.size();
+               for (int j = 0; j < bt_devices.size(); j++)
+                       devices[off + j] = bt_devices.get(j);
+               return devices;
+       }
+
+       public void add_bluetooth() {
+               JButton manage_bluetooth_button = new JButton("Manage Bluetooth");
+               manage_bluetooth_button.setActionCommand("manage");
+               manage_bluetooth_button.addActionListener(this);
+               buttonPane.add(manage_bluetooth_button);
+               buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
+       }
+       
+       public void actionPerformed(ActionEvent e) {
+               super.actionPerformed(e);
+               if ("manage".equals(e.getActionCommand())) {
+                       AltosBTManage.show(frame, AltosBTKnown.bt_known());
+                       update_devices();
+               }
+       }
+
+       public AltosDeviceUIDialog (Frame in_frame, Component location, int in_product) {
+               super(in_frame, location, in_product);
+       }
+
+       public static AltosDevice show (Component frameComp, int product) {
+               Frame                   frame = JOptionPane.getFrameForComponent(frameComp);
+               AltosDeviceUIDialog     dialog;
+
+               dialog = new AltosDeviceUIDialog(frame, frameComp, product);
+               dialog.setVisible(true);
+               return dialog.getValue();
+       }
+}
index b8de77dabbc93721437defb51cbe24cc545d101e..cc9adb0c4c504f334fdc1f76629b312cca4ebae6 100644 (file)
@@ -22,6 +22,7 @@ import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
 import java.io.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosEepromManage implements ActionListener {
 
 
 public class AltosEepromManage implements ActionListener {
 
@@ -197,7 +198,7 @@ public class AltosEepromManage implements ActionListener {
                //boolean       running = false;
 
                frame = given_frame;
                //boolean       running = false;
 
                frame = given_frame;
-               device = AltosDeviceDialog.show(frame, Altos.product_any);
+               device = AltosDeviceUIDialog.show(frame, Altos.product_any);
 
                remote = false;
 
 
                remote = false;
 
index 313af70bd90258f600a000a73a0791e58be13c36..7a98ee144cd2c4ee6391317e07862d57cdf86f98 100644 (file)
@@ -20,6 +20,7 @@ package altosui;
 import java.awt.event.*;
 import javax.swing.*;
 import java.io.*;
 import java.awt.event.*;
 import javax.swing.*;
 import java.io.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosFlash {
        File            file;
 
 public class AltosFlash {
        File            file;
index 3ccfa76c3f74334c39f6bd34b5ead0b6799935e3..878150f6603646b5d897282f59ff856def46ddfc 100644 (file)
@@ -23,6 +23,7 @@ import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import java.io.*;
 import java.util.concurrent.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import java.io.*;
 import java.util.concurrent.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosFlashUI
        extends AltosDialog
 
 public class AltosFlashUI
        extends AltosDialog
@@ -175,7 +176,7 @@ public class AltosFlashUI
        }
 
        boolean select_debug_dongle() {
        }
 
        boolean select_debug_dongle() {
-               debug_dongle = AltosDeviceDialog.show(frame, Altos.product_any);
+               debug_dongle = AltosDeviceUIDialog.show(frame, Altos.product_any);
 
                if (debug_dongle == null)
                        return false;
 
                if (debug_dongle == null)
                        return false;
index 6f69600997c6ab0d0bac505c01ecc85b5254f30e..6d3450b6a4302aa9744c5f356595d3a5b6309128 100644 (file)
@@ -23,6 +23,7 @@ import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
 import java.io.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener {
        AltosDevice             device;
 
 public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener {
        AltosDevice             device;
@@ -90,7 +91,7 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
        public AltosIdleMonitorUI(JFrame in_owner)
                throws FileNotFoundException, AltosSerialInUseException, TimeoutException, InterruptedException {
 
        public AltosIdleMonitorUI(JFrame in_owner)
                throws FileNotFoundException, AltosSerialInUseException, TimeoutException, InterruptedException {
 
-               device = AltosDeviceDialog.show(in_owner, Altos.product_any);
+               device = AltosDeviceUIDialog.show(in_owner, Altos.product_any);
                remote = false;
                if (!device.matchProduct(Altos.product_altimeter))
                        remote = true;
                remote = false;
                if (!device.matchProduct(Altos.product_altimeter))
                        remote = true;
index ec331259c73531d69946bdd1e00fe341e041bde5..f1742203308eb0e2b3dac8882dcf26e13acc7010 100644 (file)
@@ -24,6 +24,7 @@ import java.io.*;
 import java.text.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
 import java.text.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosIgniteUI
        extends AltosDialog
 
 public class AltosIgniteUI
        extends AltosDialog
@@ -304,7 +305,7 @@ public class AltosIgniteUI
        private boolean open() {
                command_queue = new LinkedBlockingQueue<String>();
 
        private boolean open() {
                command_queue = new LinkedBlockingQueue<String>();
 
-               device = AltosDeviceDialog.show(owner, Altos.product_any);
+               device = AltosDeviceUIDialog.show(owner, Altos.product_any);
                if (device != null) {
                                IgniteHandler   handler = new IgniteHandler(owner);
                                Thread          t = new Thread(handler);
                if (device != null) {
                                IgniteHandler   handler = new IgniteHandler(owner);
                                Thread          t = new Thread(handler);
index de19221e9f0c117a29c7899ca07af2c0eba8eade..0bad80aac459d16ada7b64207bf062e4e36eddc7 100644 (file)
@@ -20,6 +20,7 @@ package altosui;
 import java.io.*;
 import java.util.concurrent.*;
 import java.awt.*;
 import java.io.*;
 import java.util.concurrent.*;
 import java.awt.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosLaunch {
        AltosDevice     device;
 
 public class AltosLaunch {
        AltosDevice     device;
index 39b986c0a129f0dde62a7533be54027bd9bb3ea9..68c978dc5e01dc4b91a50560f37032c8d9ce020d 100644 (file)
@@ -23,6 +23,7 @@ import javax.swing.*;
 import java.io.*;
 import java.text.*;
 import java.util.concurrent.*;
 import java.io.*;
 import java.text.*;
 import java.util.concurrent.*;
+import org.altusmetrum.altosuilib.*;
 
 class FireButton extends JButton {
        protected void processMouseEvent(MouseEvent e) {
 
 class FireButton extends JButton {
        protected void processMouseEvent(MouseEvent e) {
@@ -370,7 +371,7 @@ public class AltosLaunchUI
        private boolean open() {
                command_queue = new LinkedBlockingQueue<String>();
 
        private boolean open() {
                command_queue = new LinkedBlockingQueue<String>();
 
-               device = AltosDeviceDialog.show(owner, Altos.product_any);
+               device = AltosDeviceUIDialog.show(owner, Altos.product_any);
                if (device != null) {
                                LaunchHandler   handler = new LaunchHandler(owner);
                                Thread          t = new Thread(handler);
                if (device != null) {
                                LaunchHandler   handler = new LaunchHandler(owner);
                                Thread          t = new Thread(handler);
index 2a6e140ac34f786e5f363b6a3c73ab949847c677..6a8db0e05aeeb915ce9b311beaa929e3c707dce8 100644 (file)
@@ -26,6 +26,7 @@ import java.util.*;
 import java.text.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
 import java.text.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 class AltosScanResult {
        String          callsign;
 
 class AltosScanResult {
        String          callsign;
@@ -327,7 +328,7 @@ public class AltosScanUI
        }
 
        private boolean open() {
        }
 
        private boolean open() {
-               device = AltosDeviceDialog.show(owner, Altos.product_basestation);
+               device = AltosDeviceUIDialog.show(owner, Altos.product_basestation);
                if (device == null)
                        return false;
                try {
                if (device == null)
                        return false;
                try {
index 771fdd5dfe14326ae5a30b29284a676eac024f13..78d862d03645ccd7eae99eb1acfd1bbc17d19682 100644 (file)
@@ -26,6 +26,7 @@ import java.util.*;
 import java.awt.*;
 import javax.swing.*;
 import org.altusmetrum.AltosLib.*;
 import java.awt.*;
 import javax.swing.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 import libaltosJNI.*;
 
 
 import libaltosJNI.*;
 
index 7380f331b2d561b46b39943554735461af57acc0..932a3684ee0eb5709eb8c05ef59d6822e094f21f 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 package altosui;
  */
 
 package altosui;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosSerialInUseException extends Exception {
        public AltosDevice      device;
 
 public class AltosSerialInUseException extends Exception {
        public AltosDevice      device;
index dcc0de600817aab22666705581ffe42afa8de996..a385b8b3923d4b842ac03951ce7575a436c59ea7 100644 (file)
@@ -23,6 +23,7 @@ import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
 import java.io.*;
 import java.util.concurrent.*;
 import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosUI extends AltosFrame {
        public AltosVoice voice = new AltosVoice();
 
 public class AltosUI extends AltosFrame {
        public AltosVoice voice = new AltosVoice();
@@ -241,7 +242,7 @@ public class AltosUI extends AltosFrame {
        }
 
        private void ConnectToDevice() {
        }
 
        private void ConnectToDevice() {
-               AltosDevice     device = AltosDeviceDialog.show(AltosUI.this,
+               AltosDevice     device = AltosDeviceUIDialog.show(AltosUI.this,
                                                                Altos.product_basestation);
 
                if (device != null)
                                                                Altos.product_basestation);
 
                if (device != null)
index 3af7a7fa4895d952af6dd60328c91cb6cb90b187..5c6a89766cdac20f800a20e43b6e194b952727ce 100644 (file)
@@ -18,6 +18,7 @@
 package altosui;
 import java.util.*;
 import libaltosJNI.*;
 package altosui;
 import java.util.*;
 import libaltosJNI.*;
+import org.altusmetrum.altosuilib.*;
 
 public class AltosUSBDevice  extends altos_device implements AltosDevice {
 
 
 public class AltosUSBDevice  extends altos_device implements AltosDevice {
 
index b3aa1f558f7803b55d69e91aa3b2dbe1451794b1..593eeb0a4600d10bfcd45a842cd92fabf4d8ab0b 100644 (file)
@@ -32,8 +32,7 @@ altosui_JAVA = \
        AltosCSVUI.java \
        AltosDebug.java \
        AltosDescent.java \
        AltosCSVUI.java \
        AltosDebug.java \
        AltosDescent.java \
-       AltosDeviceDialog.java \
-       AltosDevice.java \
+       AltosDeviceUIDialog.java \
        AltosUSBDevice.java \
        AltosDisplayThread.java \
        AltosEepromDelete.java \
        AltosUSBDevice.java \
        AltosDisplayThread.java \
        AltosEepromDelete.java \
index 82620b8b387a58580120a5a95c876c3d9414fae3..cde545a72b10852ca0be857a87a0d8c1876b83ec 100644 (file)
@@ -27,22 +27,24 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL
        private JList           list;
        private JButton         cancel_button;
        private JButton         select_button;
        private JList           list;
        private JButton         cancel_button;
        private JButton         select_button;
-       private JButton         manage_bluetooth_button;
-       private Frame           frame;
-       private int             product;
-
+       public Frame            frame;
+       public int              product;
+       public JPanel           buttonPane;
+       
        public AltosDevice getValue() {
                return value;
        }
 
        public abstract AltosDevice[] devices();
 
        public AltosDevice getValue() {
                return value;
        }
 
        public abstract AltosDevice[] devices();
 
-       private void update_devices() {
+       public void update_devices() {
                AltosDevice[] devices = devices();
                list.setListData(devices);
                select_button.setEnabled(devices.length > 0);
        }
 
                AltosDevice[] devices = devices();
                list.setListData(devices);
                select_button.setEnabled(devices.length > 0);
        }
 
+       public void add_bluetooth() { }
+
        public AltosDeviceDialog (Frame in_frame, Component location, int in_product) {
                super(in_frame, "Device Selection", true);
 
        public AltosDeviceDialog (Frame in_frame, Component location, int in_product) {
                super(in_frame, "Device Selection", true);
 
@@ -56,10 +58,6 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL
                cancel_button.setActionCommand("cancel");
                cancel_button.addActionListener(this);
 
                cancel_button.setActionCommand("cancel");
                cancel_button.addActionListener(this);
 
-//             manage_bluetooth_button = new JButton("Manage Bluetooth");
-//             manage_bluetooth_button.setActionCommand("manage");
-//             manage_bluetooth_button.addActionListener(this);
-
                select_button = new JButton("Select");
                select_button.setActionCommand("select");
                select_button.addActionListener(this);
                select_button = new JButton("Select");
                select_button.setActionCommand("select");
                select_button.addActionListener(this);
@@ -126,14 +124,15 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL
                listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
 
                //Lay out the buttons from left to right.
                listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
 
                //Lay out the buttons from left to right.
-               JPanel buttonPane = new JPanel();
+               buttonPane = new JPanel();
                buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
                buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
                buttonPane.add(Box.createHorizontalGlue());
                buttonPane.add(cancel_button);
                buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
                buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
                buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
                buttonPane.add(Box.createHorizontalGlue());
                buttonPane.add(cancel_button);
                buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
-//             buttonPane.add(manage_bluetooth_button);
-//             buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
+
+               add_bluetooth();
+
                buttonPane.add(select_button);
 
                //Put everything together, using the content pane's BorderLayout.
                buttonPane.add(select_button);
 
                //Put everything together, using the content pane's BorderLayout.
@@ -150,14 +149,12 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL
 
        //Handle clicks on the Set and Cancel buttons.
        public void actionPerformed(ActionEvent e) {
 
        //Handle clicks on the Set and Cancel buttons.
        public void actionPerformed(ActionEvent e) {
-               if ("select".equals(e.getActionCommand()))
+               if ("select".equals(e.getActionCommand())) {
                        value = (AltosDevice)(list.getSelectedValue());
                        value = (AltosDevice)(list.getSelectedValue());
-//             if ("manage".equals(e.getActionCommand())) {
-//                     AltosBTManage.show(frame, AltosBTKnown.bt_known());
-//                     update_devices();
-//                     return;
-//             }
-               setVisible(false);
+                       setVisible(false);
+               }
+               if ("cancel".equals(e.getActionCommand()))
+                       setVisible(false);
        }
 
 }
        }
 
 }