altosui: Catch errors opening USB devices. Limit list to relevant devices
[fw/altos] / ao-tools / altosui / AltosDeviceDialog.java
index b3a0f9bebd5d308c0067f3aadf93f572a93da8ab..08921c3d044d308680106b529b96f2c0b4abad8e 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,
@@ -41,6 +41,10 @@ public class AltosDeviceDialog {
                                                               devices[0]);
                        return (altos_device) o;
                } else {
+                       JOptionPane.showMessageDialog(frame,
+                                                     "No AltOS devices available",
+                                                     "No AltOS devices",
+                                                     JOptionPane.ERROR_MESSAGE);
                        return null;
                }
        }