altosui: Remove gratuitous threading from device flashing UI
authorKeith Packard <keithp@keithp.com>
Fri, 26 Nov 2010 00:28:04 +0000 (16:28 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 26 Nov 2010 00:30:19 +0000 (16:30 -0800)
There's no need for a thread here, and swing doesn't want us to use
one anyways.

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

index f63097ac408ad1f71356311365b487203ce8788f..0b61f041f16cb0dd7fa03800d2482804c1d06816 100644 (file)
@@ -30,7 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 
 public class AltosFlashUI
        extends JDialog
-       implements Runnable, ActionListener
+       implements ActionListener
 {
        Container       pane;
        Box             box;
@@ -64,47 +64,6 @@ public class AltosFlashUI
                }
        }
 
-       public void run() {
-               try {
-                       flash = new AltosFlash(file, debug_dongle);
-                       flash.addActionListener(this);
-                       AltosRomconfigUI romconfig_ui = new AltosRomconfigUI (frame);
-
-                       romconfig_ui.set(flash.romconfig());
-                       AltosRomconfig romconfig = romconfig_ui.showDialog();
-
-                       if (romconfig != null && romconfig.valid()) {
-                               flash.set_romconfig(romconfig);
-                               serial_value.setText(String.format("%d",
-                                                                  flash.romconfig().serial_number));
-                               file_value.setText(file.toString());
-                               setVisible(true);
-                               flash.flash();
-                               flash = null;
-                       }
-               } catch (FileNotFoundException ee) {
-                       JOptionPane.showMessageDialog(frame,
-                                                     "Cannot open image",
-                                                     file.toString(),
-                                                     JOptionPane.ERROR_MESSAGE);
-               } catch (AltosSerialInUseException si) {
-                       JOptionPane.showMessageDialog(frame,
-                                                     String.format("Device \"%s\" already in use",
-                                                                   debug_dongle.toShortString()),
-                                                     "Device in use",
-                                                     JOptionPane.ERROR_MESSAGE);
-               } catch (IOException e) {
-                       JOptionPane.showMessageDialog(frame,
-                                                     e.getMessage(),
-                                                     file.toString(),
-                                                     JOptionPane.ERROR_MESSAGE);
-               } catch (InterruptedException ie) {
-               } finally {
-                       abort();
-               }
-               dispose();
-       }
-
        public void abort() {
                if (flash != null)
                        flash.abort();
@@ -212,7 +171,43 @@ public class AltosFlashUI
                if (file != null)
                        AltosPreferences.set_firmwaredir(file.getParentFile());
 
-               thread = new Thread(this);
-               thread.start();
+               try {
+                       flash = new AltosFlash(file, debug_dongle);
+                       flash.addActionListener(this);
+                       AltosRomconfigUI romconfig_ui = new AltosRomconfigUI (frame);
+
+                       romconfig_ui.set(flash.romconfig());
+                       AltosRomconfig romconfig = romconfig_ui.showDialog();
+
+                       if (romconfig != null && romconfig.valid()) {
+                               flash.set_romconfig(romconfig);
+                               serial_value.setText(String.format("%d",
+                                                                  flash.romconfig().serial_number));
+                               file_value.setText(file.toString());
+                               setVisible(true);
+                               flash.flash();
+                               flash = null;
+                       }
+               } catch (FileNotFoundException ee) {
+                       JOptionPane.showMessageDialog(frame,
+                                                     "Cannot open image",
+                                                     file.toString(),
+                                                     JOptionPane.ERROR_MESSAGE);
+               } catch (AltosSerialInUseException si) {
+                       JOptionPane.showMessageDialog(frame,
+                                                     String.format("Device \"%s\" already in use",
+                                                                   debug_dongle.toShortString()),
+                                                     "Device in use",
+                                                     JOptionPane.ERROR_MESSAGE);
+               } catch (IOException e) {
+                       JOptionPane.showMessageDialog(frame,
+                                                     e.getMessage(),
+                                                     file.toString(),
+                                                     JOptionPane.ERROR_MESSAGE);
+               } catch (InterruptedException ie) {
+               } finally {
+                       abort();
+               }
+               dispose();
        }
 }
\ No newline at end of file