X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosUI.java;h=9977e82b2483d83d93f4cdd63132c4bf97cb8191;hp=8399b7c8440e101a1d271c5c00ed4542fe0b6786;hb=1b5340c2b75c500011355c4889da443c4b9c4891;hpb=02df2141e5a67afc16acd01a6c60f3cc61052b93 diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 8399b7c8..9977e82b 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -27,10 +27,11 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; -public class AltosUI extends JFrame { +public class AltosUI extends AltosFrame { public AltosVoice voice = new AltosVoice(); public static boolean load_library(Frame frame) { @@ -47,13 +48,12 @@ public class AltosUI extends JFrame { void telemetry_window(AltosDevice device) { try { - AltosFlightReader reader = new AltosTelemetryReader(device); + AltosFlightReader reader = new AltosTelemetryReader(new AltosSerial(device)); if (reader != null) new AltosFlightUI(voice, reader, device.getSerial()); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(AltosUI.this, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ee.getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } catch (AltosSerialInUseException si) { @@ -105,11 +105,7 @@ public class AltosUI extends JFrame { load_library(null); - java.net.URL imgURL = AltosUI.class.getResource("/altus-metrum-16x16.jpg"); - if (imgURL != null) - setIconImage(new ImageIcon(imgURL).getImage()); - - AltosPreferences.set_component(this); + AltosUIPreferences.set_component(this); pane = getContentPane(); gridbag = new GridBagLayout(); @@ -166,28 +162,29 @@ public class AltosUI extends JFrame { } }); b.setToolTipText("Global AltosUI settings"); - b = addButton(2, 1, "Flash Image"); + + b = addButton(2, 1, "Configure Ground Station"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - FlashImage(); + ConfigureTeleDongle(); } }); - b.setToolTipText("Replace the firmware in any AltusMetrum product"); - b = addButton(3, 1, "Fire Igniter"); + b = addButton(3, 1, "Flash Image"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - FireIgniter(); + FlashImage(); } }); - b.setToolTipText("Remote control of igniters for deployment testing"); - b = addButton(4, 1, "Quit"); + b.setToolTipText("Replace the firmware in any AltusMetrum product"); + + b = addButton(4, 1, "Fire Igniter"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - System.exit(0); + FireIgniter(); } }); - b.setToolTipText("Close all active windows and terminate AltosUI"); + b.setToolTipText("Remote control of igniters for deployment testing"); b = addButton(0, 2, "Scan Channels"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -210,12 +207,20 @@ public class AltosUI extends JFrame { }); b.setToolTipText("Check flight readiness of altimeter in idle mode"); - b = addButton(2, 2, "Launch Controller"); +// b = addButton(3, 2, "Launch Controller"); +// b.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// LaunchController(); +// } +// }); + + b = addButton(4, 2, "Quit"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - LaunchController(); + System.exit(0); } }); + b.setToolTipText("Close all active windows and terminate AltosUI"); setTitle("AltOS"); @@ -254,15 +259,19 @@ public class AltosUI extends JFrame { String result; result = JOptionPane.showInputDialog(AltosUI.this, "Configure Callsign", - AltosPreferences.callsign()); + AltosUIPreferences.callsign()); if (result != null) - AltosPreferences.set_callsign(result); + AltosUIPreferences.set_callsign(result); } void ConfigureTeleMetrum() { new AltosConfig(AltosUI.this); } + void ConfigureTeleDongle() { + new AltosConfigTD(AltosUI.this); + } + void FlashImage() { AltosFlashUI.show(AltosUI.this); } @@ -353,10 +362,12 @@ public class AltosUI extends JFrame { in = new FileInputStream(file); if (filename.endsWith("eeprom")) return new AltosEepromIterable(in); + else if (filename.endsWith("mega")) + return new AltosEepromMegaIterable(in); else return new AltosTelemetryIterable(in); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -366,7 +377,7 @@ public class AltosUI extends JFrame { try { return new AltosCSV(file); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -376,7 +387,7 @@ public class AltosUI extends JFrame { try { return new AltosKML(file); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -424,17 +435,17 @@ public class AltosUI extends JFrame { } } - static AltosRecordIterable record_iterable_file(String filename) { + static AltosRecordIterable record_iterable(File file) { FileInputStream in; try { - in = new FileInputStream(filename); + in = new FileInputStream(file); } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", filename); + System.out.printf("Failed to open file '%s'\n", file); return null; } AltosRecordIterable recs; AltosReplayReader reader; - if (filename.endsWith("eeprom")) { + if (file.getName().endsWith("eeprom")) { recs = new AltosEepromIterable(in); } else { recs = new AltosTelemetryIterable(in); @@ -442,6 +453,10 @@ public class AltosUI extends JFrame { return recs; } + static AltosRecordIterable record_iterable_file(String filename) { + return record_iterable (new File(filename)); + } + static AltosReplayReader replay_file(String filename) { AltosRecordIterable recs = record_iterable_file(filename); if (recs == null) @@ -467,9 +482,9 @@ public class AltosUI extends JFrame { } static void process_summary(String filename) { - AltosReplayReader reader = replay_file(filename); + AltosRecordIterable iterable = record_iterable_file(filename); try { - AltosFlightStats stats = new AltosFlightStats(reader); + AltosFlightStats stats = new AltosFlightStats(iterable); if (stats.serial > 0) System.out.printf("Serial: %5d\n", stats.serial); if (stats.flight > 0) @@ -519,8 +534,9 @@ public class AltosUI extends JFrame { } public static void main(final String[] args) { + load_library(null); try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + UIManager.setLookAndFeel(AltosUIPreferences.look_and_feel()); } catch (Exception e) { } /* Handle batch-mode */