altosui: Show dialog after successful delete or when no flights
authorKeith Packard <keithp@keithp.com>
Sat, 15 Jan 2011 00:44:50 +0000 (16:44 -0800)
committerKeith Packard <keithp@keithp.com>
Sat, 15 Jan 2011 00:48:29 +0000 (16:48 -0800)
Make sure the user always sees confirmation for flight log management.

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

index b64ee52597b9bf643f242fd31fb8dc66bc8b00a8..2704f883c46d4b1869a8532b8aa9c5b87c8a286c 100644 (file)
@@ -50,6 +50,20 @@ public class AltosEepromManage implements ActionListener {
                }
        }
 
+       private String showDeletedFlights() {
+               String  result = "";
+
+               for (AltosEepromLog flight : flights) {
+                       if (flight.delete) {
+                               if (result.equals(""))
+                                       result = String.format("%d", flight.flight);
+                               else
+                                       result = String.format("%s, %d", result, flight.flight);
+                       }
+               }
+               return result;
+       }
+
        public void actionPerformed(ActionEvent e) {
                String  cmd = e.getActionCommand();
                boolean success = e.getID() != 0;
@@ -57,15 +71,19 @@ public class AltosEepromManage implements ActionListener {
                System.out.printf("Eeprom manager action %s %d\n", cmd, e.getID());
                if (cmd.equals("download")) {
                        if (success) {
-                               System.out.printf("Download succeeded\n");
                                if (any_delete)
                                        delete.start();
                                else
                                        finish();
                        }
                } else if (cmd.equals("delete")) {
-                       if (success)
-                               System.out.printf("Delete succeeded\n");
+                       if (success) {
+                               JOptionPane.showMessageDialog(frame,
+                                                             String.format("Flights erased: %s",
+                                                                           showDeletedFlights()),
+                                                             serial_line.device.toShortString(),
+                                                             JOptionPane.INFORMATION_MESSAGE);
+                       }
                        finish();
                }
        }
@@ -88,6 +106,11 @@ public class AltosEepromManage implements ActionListener {
                                flights = new AltosEepromList(serial_line, remote);
 
                                if (flights.size() == 0) {
+                                       JOptionPane.showMessageDialog(frame,
+                                                                     String.format("No flights available on %d",
+                                                                                   device.getSerial()),
+                                                                     serial_line.device.toShortString(),
+                                               JOptionPane.INFORMATION_MESSAGE);
                                } else {
                                        AltosEepromSelect       select = new AltosEepromSelect(frame, flights);