X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosConfig.java;h=40f7ebecb4c4635809dfdec7ebc9d068edca3af5;hp=e1ffebb4b95f1129144e1a86c70dadf2915ae78d;hb=5a51efd7f9b49ffadc91ccaf7a0d69566301c009;hpb=bd05421991b596fe9cf73ee25c9046b0fb4e32f7 diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index e1ffebb4..40f7ebec 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -21,8 +21,9 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; import java.text.*; +import org.altusmetrum.altoslib_5.*; +import org.altusmetrum.altosuilib_3.*; public class AltosConfig implements ActionListener { @@ -160,9 +161,9 @@ public class AltosConfig implements ActionListener { } finally { try { stop_serial(); + serial_line.close(); } catch (InterruptedException ie) { } - serial_line.close(); } } @@ -228,22 +229,28 @@ public class AltosConfig implements ActionListener { void save_data() { - /* bounds check stuff */ - if (config_ui.flight_log_max() > data.log_limit()) { + try { + /* bounds check stuff */ + if (config_ui.flight_log_max() > data.log_space() / 1024) { + JOptionPane.showMessageDialog(owner, + String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", + config_ui.flight_log_max(), + data.log_space() / 1024), + "Maximum Flight Log Too Large", + JOptionPane.ERROR_MESSAGE); + return; + } + + /* Pull data out of the UI and stuff back into our local data record */ + + data.get_values(config_ui); + run_serial_thread(serial_mode_save); + } catch (AltosConfigDataException ae) { JOptionPane.showMessageDialog(owner, - String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", - config_ui.flight_log_max(), - data.log_limit()), - "Maximum Flight Log Too Large", + ae.getMessage(), + "Configuration Data Error", JOptionPane.ERROR_MESSAGE); - return; } - - /* Pull data out of the UI and stuff back into our local data record */ - - data.get_values(config_ui); - - run_serial_thread(serial_mode_save); } public void actionPerformed(ActionEvent e) { @@ -270,7 +277,7 @@ public class AltosConfig implements ActionListener { public AltosConfig(JFrame given_owner) { owner = given_owner; - device = AltosDeviceDialog.show(owner, Altos.product_any); + device = AltosDeviceUIDialog.show(owner, Altos.product_any); if (device != null) { try { serial_line = new AltosSerial(device); @@ -297,4 +304,4 @@ public class AltosConfig implements ActionListener { } } } -} \ No newline at end of file +}