public class AltosFlashUI
extends JDialog
- implements Runnable, ActionListener
+ implements ActionListener
{
Container pane;
Box box;
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cancel) {
- abort();
+ setVisible(false);
dispose();
} else {
String cmd = e.getActionCommand();
- if (cmd.equals("done"))
- ;
- else if (cmd.equals("start")) {
+ if (e.getID() == -1) {
+ JOptionPane.showMessageDialog(frame,
+ e.getActionCommand(),
+ file.toString(),
+ JOptionPane.ERROR_MESSAGE);
+ setVisible(false);
+ dispose();
+ } else if (cmd.equals("done")) {
+ setVisible(false);
+ dispose();
+ } else if (cmd.equals("start")) {
setVisible(true);
} else {
pbar.setValue(e.getID());
}
}
- 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();
- }
-
public void build_dialog() {
GridBagConstraints c;
Insets il = new Insets(4,4,4,4);
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();
+ }
+ } 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) {
+ }
}
}
\ No newline at end of file