2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 import javax.swing.border.*;
25 import java.awt.event.*;
26 import libaltosJNI.libaltos;
27 import libaltosJNI.altos_device;
28 import libaltosJNI.SWIGTYPE_p_altos_file;
29 import libaltosJNI.SWIGTYPE_p_altos_list;
31 class AltosEepromItem extends JPanel implements ActionListener {
37 public void actionPerformed(ActionEvent e) {
38 System.out.printf("eeprom item action %s %d\n", e.getActionCommand(), e.getID());
39 if (e.getSource() == download) {
40 log.download = download.isSelected();
41 System.out.printf("download set to %b\n", log.download);
42 } else if (e.getSource() == delete) {
43 log.delete = delete.isSelected();
44 System.out.printf("delete set to %b\n", log.delete);
48 public AltosEepromItem(AltosEepromLog in_log) {
51 download = new JCheckBox("Download", log.download);
52 download.addActionListener(this);
54 delete = new JCheckBox("Delete", log.delete);
55 delete.addActionListener(this);
57 label = new JLabel(String.format("Flight %d %4d-%02d-%02d",
58 log.flight, log.year, log.month, log.day));
63 public class AltosEepromSelect extends JDialog implements ActionListener {
70 /* Listen for events from our buttons */
71 public void actionPerformed(ActionEvent e) {
72 String cmd = e.getActionCommand();
79 public boolean run() {
81 setLocationRelativeTo(frame);
86 public AltosEepromSelect (JFrame in_frame,
87 AltosEepromList flights) {
89 super(in_frame, String.format("Flight list for serial %d", flights.config_data.serial), true);
92 JLabel selectLabel = new JLabel("Select flights to download and/or delete", SwingConstants.CENTER);
94 JPanel labelPane = new JPanel();
95 labelPane.setLayout(new BoxLayout(labelPane, BoxLayout.X_AXIS));
96 labelPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
97 labelPane.add(Box.createHorizontalGlue());
98 labelPane.add(selectLabel);
99 labelPane.add(Box.createHorizontalGlue());
101 JPanel flightPane = new JPanel();
102 flightPane.setLayout(new BoxLayout(flightPane, BoxLayout.Y_AXIS));
103 flightPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
104 for (AltosEepromLog flight : flights) {
105 flightPane.add(new AltosEepromItem(flight));
108 ok = new JButton("OK");
109 ok.addActionListener(this);
110 ok.setActionCommand("ok");
112 cancel = new JButton("Cancel");
113 cancel.addActionListener(this);
114 cancel.setActionCommand("cancel");
116 JPanel buttonPane = new JPanel();
117 buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
118 buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
119 buttonPane.add(Box.createHorizontalGlue());
120 buttonPane.add(cancel);
121 buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
124 Container contentPane = getContentPane();
126 contentPane.add(labelPane, BorderLayout.PAGE_START);
127 contentPane.add(flightPane, BorderLayout.CENTER);
128 contentPane.add(buttonPane, BorderLayout.PAGE_END);