X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosFlashUI.java;h=5913e50699c2f390a597b1b828407476f608661f;hp=7e4cddb12dd0b1cd31b42082b08467cd1c76cb2a;hb=b89fb51a963635e2effe3a31f803bfc29c2c46b7;hpb=2cdb90d9214f8e66b3574cbd9c5ed073a7861681 diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 7e4cddb1..5913e506 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_2.*; +import org.altusmetrum.altoslib_3.*; import org.altusmetrum.altosuilib_1.*; public class AltosFlashUI @@ -69,9 +69,18 @@ public class AltosFlashUI }; private boolean is_pair_programmed() { - String name = file.getName(); - for (int i = 0; i < pair_programmed.length; i++) { - if (name.startsWith(pair_programmed[i])) + + if (file != null) { + String name = file.getName(); + for (int i = 0; i < pair_programmed.length; i++) { + if (name.startsWith(pair_programmed[i])) + return true; + } + } + if (device != null) { + if (!device.matchProduct(AltosLib.product_altusmetrum) && + (device.matchProduct(AltosLib.product_teledongle) || + device.matchProduct(AltosLib.product_telebt))) return true; } return false; @@ -192,7 +201,7 @@ public class AltosFlashUI } public boolean accept(File file) { - return file.getName().startsWith(head) && file.getName().endsWith(".ihx"); + return !file.isFile() || (file.getName().startsWith(head) && file.getName().endsWith(".ihx")); } public String getDescription() { @@ -223,13 +232,10 @@ public class AltosFlashUI hexfile_chooser.addChoosableFileFilter(ihx_filter); hexfile_chooser.setFileFilter(ihx_filter); - if (!device.matchProduct(AltosLib.product_altusmetrum)) { + if (!is_pair_programmed() && !device.matchProduct(AltosLib.product_altusmetrum)) { for (int i = 0; i < filters.length; i++) { - System.out.printf ("device %s filter %d\n", device, filters[i].product); - if (device != null && device.matchProduct(filters[i].product)) { - System.out.printf ("select filter %s\n", filters[i].head); + if (device != null && device.matchProduct(filters[i].product)) hexfile_chooser.setFileFilter(filters[i]); - } } } @@ -359,7 +365,7 @@ public class AltosFlashUI flash_task flasher; - private boolean open_device() { + private boolean open_device() throws InterruptedException { try { link = new AltosSerial(device); if (is_pair_programmed()) @@ -402,8 +408,12 @@ public class AltosFlashUI return; if (!select_source_file()) return; - if (!open_device()) + try { + if (!open_device()) + return; + } catch (InterruptedException ie) { return; + } build_dialog(); flash_task f = new flash_task(this); }