Present list of altos devices in nice format
authorKeith Packard <keithp@keithp.com>
Tue, 27 Jul 2010 00:03:47 +0000 (17:03 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 27 Jul 2010 00:03:47 +0000 (17:03 -0700)
ao-tools/altosui/AltosDevice.java
ao-tools/altosui/AltosDeviceDialog.java

index 8ebd3b991bb52486ea7faa46efc35307339bdbbb..0e7d01da757cf1f7e2729c6a4be038c2133fb873 100644 (file)
@@ -20,32 +20,34 @@ import java.lang.*;
 import java.util.*;
 import libaltosJNI.*;
 
-public class AltosDevice {
+public class AltosDevice extends altos_device {
+
+       public String toString() {
+               return String.format("%-20.20s %4d %s",
+                                    getProduct(), getSerial(), getPath());
+       }
 
        static {
                System.loadLibrary("altos");
                libaltos.altos_init();
        }
-       static altos_device[] list(String product) {
+       static AltosDevice[] list(String product) {
                SWIGTYPE_p_altos_list list = libaltos.altos_list_start();
 
-               ArrayList<altos_device> device_list = new ArrayList<altos_device>();
+               ArrayList<AltosDevice> device_list = new ArrayList<AltosDevice>();
                if (list != null) {
                        SWIGTYPE_p_altos_file file;
 
                        for (;;) {
-                               altos_device device = new altos_device();
+                               AltosDevice device = new AltosDevice();
                                if (libaltos.altos_list_next(list, device) == 0)
                                        break;
-                               System.out.printf("Found device %s %d %s\n",
-                                                 device.getProduct(), device.getSerial(), device.getPath());
-
                                device_list.add(device);
                        }
                        libaltos.altos_list_finish(list);
                }
 
-               altos_device[] devices = new altos_device[device_list.size()];
+               AltosDevice[] devices = new AltosDevice[device_list.size()];
                for (int i = 0; i < device_list.size(); i++)
                        devices[i] = device_list.get(i);
                return devices;
index b3a0f9bebd5d308c0067f3aadf93f572a93da8ab..eb70877c9b99f18559a83e81989e126623251d75 100644 (file)
@@ -29,7 +29,7 @@ import altosui.AltosDevice;
 public class AltosDeviceDialog {
 
        static altos_device show (JFrame frame, String product) {
-               altos_device[]  devices = null;
+               AltosDevice[]   devices;
                devices = AltosDevice.list(product);
                if (devices != null & devices.length > 0) {
                        Object o = JOptionPane.showInputDialog(frame,