altosui: Delay mapping Flash UI until flashing actually starts
authorKeith Packard <keithp@keithp.com>
Tue, 24 Aug 2010 10:59:09 +0000 (03:59 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 24 Aug 2010 10:59:09 +0000 (03:59 -0700)
The flash operation may be abandoned before it even starts; this makes
sure the UI doesn't flash up on the screen.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/AltosFlash.java
ao-tools/altosui/AltosFlashUI.java

index 0f92d6e7bf2ffb82d27fa31aa0fde7cb240e73d5..7aeab89aadf426f56d92f5d2584fe3cc4362e9d6 100644 (file)
@@ -247,6 +247,7 @@ public class AltosFlash {
                int flash_addr = image.address;
                int image_start = 0;
 
+               action("start", 0);
                action(0, image.data.length);
                while (remain > 0 && !aborted) {
                        int this_time = remain;
index 0c2041e3cf338f9a8fbdf7adf3125549aaef13aa..b88a16b35b77bf6725e0091c064dbe2c4a0118c2 100644 (file)
@@ -57,8 +57,10 @@ public class AltosFlashUI
                } else {
                        String  cmd = e.getActionCommand();
                        if (cmd.equals("done"))
-                               dispose();
-                       else {
+                               ;
+                       else if (cmd.equals("start")) {
+                               setVisible(true);
+                       } else {
                                pbar.setValue(e.getID());
                                pbar.setString(cmd);
                        }
@@ -88,15 +90,14 @@ public class AltosFlashUI
                                                      "Cannot open image",
                                                      file.toString(),
                                                      JOptionPane.ERROR_MESSAGE);
-                       return;
                } catch (IOException e) {
                        JOptionPane.showMessageDialog(frame,
                                                      e.getMessage(),
                                                      file.toString(),
                                                      JOptionPane.ERROR_MESSAGE);
-                       return;
                } catch (InterruptedException ie) {
                }
+               dispose();
        }
 
        public void abort() {