telegps: Add scan UI
[fw/altos] / altosui / AltosEepromSelect.java
index f0066aac51e9fa85b4fa8c28c91d8ab97b9ec3b3..66a197c9af5ac300e102121ae81078909a123a4d 100644 (file)
 
 package altosui;
 
-import java.lang.*;
-import java.util.*;
 import javax.swing.*;
 import javax.swing.border.*;
 import java.awt.*;
 import java.awt.event.*;
-import libaltosJNI.libaltos;
-import libaltosJNI.altos_device;
-import libaltosJNI.SWIGTYPE_p_altos_file;
-import libaltosJNI.SWIGTYPE_p_altos_list;
+import org.altusmetrum.altoslib_4.*;
+import org.altusmetrum.altosuilib_2.*;
 
 class AltosEepromItem implements ActionListener {
        AltosEepromLog  log;
        JLabel          label;
-       JCheckBox       download;
+       JCheckBox       action;
        JCheckBox       delete;
 
        public void actionPerformed(ActionEvent e) {
-               System.out.printf("eeprom item action %s %d\n", e.getActionCommand(), e.getID());
-               if (e.getSource() == download) {
-                       log.download = download.isSelected();
-                       System.out.printf("download for flight %d set to %b\n", log.flight, log.download);
-               } else if (e.getSource() == delete) {
-                       log.delete = delete.isSelected();
-                       System.out.printf("delete for flight %d set to %b\n", log.flight, log.delete);
-               }
+               log.selected = action.isSelected();
        }
 
        public AltosEepromItem(AltosEepromLog in_log) {
                log = in_log;
 
-               label = new JLabel(String.format("Flight #%02d - %04d-%02d-%02d",
-                                                log.flight, log.year, log.month, log.day));
+               String  text;
+               if (log.year != 0)
+                       text = String.format("Flight #%02d - %04d-%02d-%02d",
+                                            log.flight, log.year, log.month, log.day);
+               else
+                       text = String.format("Flight #%02d", log.flight);
 
-               download = new JCheckBox("", log.download);
-               download.addActionListener(this);
+               label = new JLabel(text);
 
-               delete = new JCheckBox("", log.delete);
-               delete.addActionListener(this);
+               action = new JCheckBox("", log.selected);
+               action.addActionListener(this);
        }
 }
 
-public class AltosEepromSelect extends JDialog implements ActionListener {
-       private JList                   list;
+public class AltosEepromSelect extends AltosUIDialog implements ActionListener {
+       //private JList                 list;
        private JFrame                  frame;
        JButton                         ok;
        JButton                         cancel;
@@ -83,7 +75,8 @@ public class AltosEepromSelect extends JDialog implements ActionListener {
        }
 
        public AltosEepromSelect (JFrame in_frame,
-                                 AltosEepromList flights) {
+                                 AltosEepromList flights,
+                                 String action) {
 
                super(in_frame, String.format("Flight list for serial %d", flights.config_data.serial), true);
                frame = in_frame;
@@ -92,7 +85,7 @@ public class AltosEepromSelect extends JDialog implements ActionListener {
                Container contentPane = getContentPane();
 
                /* First, we create a pane containing the dialog's header/title */
-               JLabel  selectLabel = new JLabel("Select flights to download and/or delete", SwingConstants.CENTER);
+               JLabel  selectLabel = new JLabel(String.format ("Select flights to %s", action), SwingConstants.CENTER);
 
                JPanel  labelPane = new JPanel();
                labelPane.setLayout(new BoxLayout(labelPane, BoxLayout.X_AXIS));
@@ -119,7 +112,7 @@ public class AltosEepromSelect extends JDialog implements ActionListener {
                c.weightx = 0.5;
                c.anchor = GridBagConstraints.CENTER;
                c.insets = i;
-               JLabel flightHeaderLabel = new JLabel("Flight:");
+               JLabel flightHeaderLabel = new JLabel("Flight");
                flightPane.add(flightHeaderLabel, c);
 
                /* Download Header */
@@ -129,19 +122,9 @@ public class AltosEepromSelect extends JDialog implements ActionListener {
                c.weightx = 0.5;
                c.anchor = GridBagConstraints.CENTER;
                c.insets = i;
-               JLabel downloadHeaderLabel = new JLabel("Download:");
+               JLabel downloadHeaderLabel = new JLabel(action);
                flightPane.add(downloadHeaderLabel, c);
 
-               /* Delete Header */
-               c = new GridBagConstraints();
-               c.gridx = 2; c.gridy = 0;
-               c.fill = GridBagConstraints.NONE;
-               c.weightx = 0.5;
-               c.anchor = GridBagConstraints.CENTER;
-               c.insets = i;
-               JLabel deleteHeaderLabel = new JLabel("Delete:");
-               flightPane.add(deleteHeaderLabel, c);
-
                /* Add the flights to the GridBag */
                AltosEepromItem item;
                int itemNumber = 1;
@@ -160,23 +143,14 @@ public class AltosEepromSelect extends JDialog implements ActionListener {
                        c.insets = i;
                        flightPane.add(item.label, c);
 
-                       /* Add a download checkbox for the flight */
+                       /* Add action checkbox for the flight */
                        c = new GridBagConstraints();
                        c.gridx = 1; c.gridy = itemNumber;
                        c.fill = GridBagConstraints.NONE;
                        c.weightx = 0.5;
                        c.anchor = GridBagConstraints.CENTER;
                        c.insets = i;
-                       flightPane.add(item.download, c);
-
-                       /* Add a delete checkbox for the flight */
-                       c = new GridBagConstraints();
-                       c.gridx = 2; c.gridy = itemNumber;
-                       c.fill = GridBagConstraints.NONE;
-                       c.weightx = 0.5;
-                       c.anchor = GridBagConstraints.CENTER;
-                       c.insets = i;
-                       flightPane.add(item.delete, c);
+                       flightPane.add(item.action, c);
 
                        itemNumber++;
                }