X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosFlashUI.java;h=4ab73a6dbeb1d23a082c74e9e2ef7ffe1ff67a37;hb=55747ce210d7d80d5b4fdaaf9dc7ee0f7bc8b0a3;hp=3874b5004995cb0269a612005b2949783f2747de;hpb=2e7b7b80432bb251ac39efa1fa05d32b5f250e14;p=fw%2Faltos diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 3874b500..4ab73a6d 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -27,9 +27,10 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosFlashUI - extends JDialog + extends AltosDialog implements ActionListener { Container pane; @@ -161,7 +162,7 @@ public class AltosFlashUI boolean select_source_file() { JFileChooser hexfile_chooser = new JFileChooser(); - File firmwaredir = AltosPreferences.firmwaredir(); + File firmwaredir = AltosUIPreferences.firmwaredir(); if (firmwaredir != null) hexfile_chooser.setCurrentDirectory(firmwaredir); @@ -174,7 +175,7 @@ public class AltosFlashUI file = hexfile_chooser.getSelectedFile(); if (file == null) return false; - AltosPreferences.set_firmwaredir(file.getParentFile()); + AltosUIPreferences.set_firmwaredir(file.getParentFile()); return true; } @@ -200,8 +201,8 @@ public class AltosFlashUI void exception (Exception e) { if (e instanceof FileNotFoundException) { JOptionPane.showMessageDialog(frame, - "Cannot open image", - file.toString(), + ((FileNotFoundException) e).getMessage(), + "Cannot open file", JOptionPane.ERROR_MESSAGE); } else if (e instanceof AltosSerialInUseException) { JOptionPane.showMessageDialog(frame, @@ -247,7 +248,15 @@ public class AltosFlashUI flash.set_romconfig(ui.rom_config); flash.flash(); } - } catch (Exception ee) { + } catch (InterruptedException ee) { + final Exception e = ee; + System.out.printf("exception %s\n", e.toString()); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ui.exception(e); + } + }); + } catch (IOException ee) { final Exception e = ee; System.out.printf("exception %s\n", e.toString()); SwingUtilities.invokeLater(new Runnable() { @@ -255,9 +264,18 @@ public class AltosFlashUI ui.exception(e); } }); + } catch (AltosSerialInUseException ee) { + final Exception e = ee; + System.out.printf("exception %s\n", e.toString()); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ui.exception(e); + } + }); + } finally { + if (flash != null) + flash.close(); } - if (flash != null) - flash.close(); } public flash_task(AltosFlashUI in_ui) {