doc: Update all docs to 1.9. Note this in doc/RELNOTES
[fw/altos] / altosuilib / AltosEepromManage.java
index 81dd3d13e4eb50a01bb50a6d0408f91f741cc1fc..cab3e8c70f1249428d59ecf4515a66ce8c826fdf 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altosuilib_3;
+package org.altusmetrum.altosuilib_13;
 
 import java.awt.event.*;
 import javax.swing.*;
 import java.io.*;
 import java.util.concurrent.*;
-import org.altusmetrum.altoslib_5.*;
+import org.altusmetrum.altoslib_13.*;
 
 public class AltosEepromManage implements ActionListener {
 
@@ -32,6 +33,7 @@ public class AltosEepromManage implements ActionListener {
        AltosEepromList         flights;
        AltosEepromDownload     download;
        AltosEepromDelete       delete;
+       AltosEepromGrapher      grapher;
 
        public void finish() {
                if (serial_line != null) {
@@ -47,7 +49,7 @@ public class AltosEepromManage implements ActionListener {
        private int countDeletedFlights() {
                int count = 0;
                for (AltosEepromLog flight : flights) {
-                       if (flight.selected)
+                       if (flight.delete_selected)
                                count++;
                }
                return count;
@@ -57,7 +59,7 @@ public class AltosEepromManage implements ActionListener {
                String  result = "";
 
                for (AltosEepromLog flight : flights) {
-                       if (flight.selected) {
+                       if (flight.delete_selected) {
                                if (result.equals(""))
                                        result = String.format("%d", flight.flight);
                                else
@@ -67,38 +69,49 @@ public class AltosEepromManage implements ActionListener {
                return result;
        }
 
-       public boolean download_done() {
-               AltosEepromSelect       select = new AltosEepromSelect(frame, flights, "Delete");
-
-               if (select.run()) {
-                       boolean any_selected = false;
-                       for (AltosEepromLog flight : flights)
-                               any_selected = any_selected || flight.selected;
-                       if (any_selected) {
-                               delete = new AltosEepromDelete(frame,
-                                                              serial_line,
-                                                              remote,
-                                                              flights);
-                               delete.addActionListener(this);
-                               /*
-                                * Start flight log delete
-                                */
-
-                               delete.start();
-                               return true;
-                       }
+       public boolean delete_start() {
+
+               boolean any_selected = false;
+               for (AltosEepromLog flight : flights)
+                       any_selected = any_selected || flight.delete_selected;
+               if (any_selected) {
+                       delete = new AltosEepromDelete(frame,
+                                                      serial_line,
+                                                      remote,
+                                                      flights);
+                       delete.addActionListener(this);
+                       /*
+                        * Start flight log delete
+                        */
+
+                       delete.start();
+                       return true;
                }
                return false;
        }
 
+       public void graph_start() {
+               boolean any_selected = false;
+               for (AltosEepromLog flight : flights) {
+                       if (!flight.download_selected)
+                               flight.graph_selected = false;
+                       any_selected = any_selected || flight.graph_selected;
+               }
+               if (any_selected && grapher != null)
+                       grapher.graph_flights(flights);
+       }
+
        public void actionPerformed(ActionEvent e) {
                String  cmd = e.getActionCommand();
                boolean success = e.getID() != 0;
                boolean running = false;
 
                if (cmd.equals("download")) {
-                       if (success)
-                               running = download_done();
+                       if (success) {
+                               running = delete_start();
+                               if (!running)
+                                       graph_start();
+                       }
                } else if (cmd.equals("delete")) {
                        if (success) {
                                JOptionPane.showMessageDialog(frame,
@@ -107,6 +120,7 @@ public class AltosEepromManage implements ActionListener {
                                                                            showDeletedFlights()),
                                                              serial_line.device.toShortString(),
                                                              JOptionPane.INFORMATION_MESSAGE);
+                               graph_start();
                        }
                }
                if (!running)
@@ -125,12 +139,12 @@ public class AltosEepromManage implements ActionListener {
                                                              serial_line.device.toShortString(),
                                                              JOptionPane.INFORMATION_MESSAGE);
                        } else {
-                               AltosEepromSelect       select = new AltosEepromSelect(frame, flights, "Download");
+                               AltosEepromSelect       select = new AltosEepromSelect(frame, flights, grapher != null);
 
                                if (select.run()) {
                                        boolean any_selected = false;
                                        for (AltosEepromLog flight : flights)
-                                               any_selected = any_selected || flight.selected;
+                                               any_selected = any_selected || flight.download_selected;
                                        if (any_selected) {
                                                AltosEepromMonitorUI monitor = new AltosEepromMonitorUI(frame);
                                                monitor.addActionListener(this);
@@ -146,7 +160,9 @@ public class AltosEepromManage implements ActionListener {
                                                download.start();
                                                running = true;
                                        } else {
-                                               running = download_done();
+                                               running = delete_start();
+                                               if (!running)
+                                                       graph_start();
                                        }
                                }
                        }
@@ -204,11 +220,12 @@ public class AltosEepromManage implements ActionListener {
                }
        }
 
-       public AltosEepromManage(JFrame given_frame, int product) {
+       public AltosEepromManage(JFrame given_frame, AltosEepromGrapher grapher, int product) {
 
                //boolean       running = false;
 
                frame = given_frame;
+               this.grapher = grapher;
                device = AltosDeviceUIDialog.show(frame, product);
 
                remote = false;