telegps: Add scan UI
[fw/altos] / altosui / AltosEepromSelect.java
index ebafc4c87da3382f3f670035aea39a3bbc6f9f88..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) {
-               if (e.getSource() == download) {
-                       log.download = download.isSelected();
-               } else if (e.getSource() == delete) {
-                       log.delete = delete.isSelected();
-               }
+               log.selected = action.isSelected();
        }
 
        public AltosEepromItem(AltosEepromLog in_log) {
@@ -54,16 +46,13 @@ class AltosEepromItem implements ActionListener {
 
                label = new JLabel(text);
 
-               download = new JCheckBox("", log.download);
-               download.addActionListener(this);
-
-               delete = new JCheckBox("", log.delete);
-               delete.addActionListener(this);
+               action = new JCheckBox("", log.selected);
+               action.addActionListener(this);
        }
 }
 
-public class AltosEepromSelect extends AltosDialog implements ActionListener {
-       private JList                   list;
+public class AltosEepromSelect extends AltosUIDialog implements ActionListener {
+       //private JList                 list;
        private JFrame                  frame;
        JButton                         ok;
        JButton                         cancel;
@@ -86,7 +75,8 @@ public class AltosEepromSelect extends AltosDialog 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;
@@ -95,7 +85,7 @@ public class AltosEepromSelect extends AltosDialog 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));
@@ -132,19 +122,9 @@ public class AltosEepromSelect extends AltosDialog 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;
@@ -163,23 +143,14 @@ public class AltosEepromSelect extends AltosDialog 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++;
                }