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.
22 import java.awt.event.*;
23 import org.altusmetrum.altosuilib_1.*;
25 public class AltosDeviceUIDialog extends AltosDeviceDialog {
27 public AltosDevice[] devices() {
28 java.util.List<AltosDevice> usb_devices = AltosUSBDevice.list(product);
29 int num_devices = usb_devices.size();
30 java.util.List<AltosDevice> bt_devices = AltosBTKnown.bt_known().list(product);
31 num_devices += bt_devices.size();
32 AltosDevice[] devices = new AltosDevice[num_devices];
34 for (int i = 0; i < usb_devices.size(); i++)
35 devices[i] = usb_devices.get(i);
36 int off = usb_devices.size();
37 for (int j = 0; j < bt_devices.size(); j++)
38 devices[off + j] = bt_devices.get(j);
42 public void add_bluetooth() {
43 JButton manage_bluetooth_button = new JButton("Manage Bluetooth");
44 manage_bluetooth_button.setActionCommand("manage");
45 manage_bluetooth_button.addActionListener(this);
46 buttonPane.add(manage_bluetooth_button);
47 buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
50 public void actionPerformed(ActionEvent e) {
51 super.actionPerformed(e);
52 if ("manage".equals(e.getActionCommand())) {
53 AltosBTManage.show(frame, AltosBTKnown.bt_known());
58 public AltosDeviceUIDialog (Frame in_frame, Component location, int in_product) {
59 super(in_frame, location, in_product);
62 public static AltosDevice show (Component frameComp, int product) {
63 Frame frame = JOptionPane.getFrameForComponent(frameComp);
64 AltosDeviceUIDialog dialog;
66 dialog = new AltosDeviceUIDialog(frame, frameComp, product);
67 dialog.setVisible(true);
68 return dialog.getValue();