import java.io.*;
import java.util.concurrent.*;
import java.util.Arrays;
-import org.altusmetrum.altoslib_5.*;
-import org.altusmetrum.altosuilib_3.*;
+import org.altusmetrum.altoslib_7.*;
+import org.altusmetrum.altosuilib_7.*;
public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosIdleMonitorListener, DocumentListener {
AltosDevice device;
AltosFlightStatus flightStatus;
AltosIgnitor ignitor;
AltosIdleMonitor thread;
+ AltosUIMapNew sitemap;
int serial;
boolean remote;
boolean has_ignitor;
+ boolean has_map;
void stop_display() {
if (thread != null) {
has_ignitor = false;
}
}
+ if (state.gps != null && state.gps.connected) {
+ if (!has_map) {
+ pane.add("Site Map", sitemap);
+ has_map = true;
+ }
+ } else {
+ if (has_map) {
+ pane.remove(sitemap);
+ has_map = false;
+ }
+ }
+
// try {
pad.show(state, listener_state);
flightStatus.show(state, listener_state);
flightInfo.show(state, listener_state);
- ignitor.show(state, listener_state);
+ if (has_ignitor)
+ ignitor.show(state, listener_state);
+ if (has_map)
+ sitemap.show(state, listener_state);
// } catch (Exception e) {
// System.out.print("Show exception " + e);
// }
SwingUtilities.invokeLater(r);
}
+ public void failed() {
+ Runnable r = new Runnable() {
+ public void run() {
+ close();
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
Container bag;
AltosUIFreqList frequencies;
JTextField callsign_value;
}
}
+ private void close() {
+ try {
+ disconnect();
+ } catch (Exception ex) {
+ System.out.printf("Exception %s\n", ex.toString());
+ for (StackTraceElement el : ex.getStackTrace())
+ System.out.printf("%s\n", el.toString());
+ }
+ setVisible(false);
+ dispose();
+ AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
+ }
+
public AltosIdleMonitorUI(JFrame in_owner)
throws FileNotFoundException, TimeoutException, InterruptedException {
serial = device.getSerial();
- AltosLink link;
+ AltosSerial link;
try {
link = new AltosSerial(device);
+ link.set_frame(this);
} catch (Exception ex) {
idle_exception(in_owner, ex);
return;
ignitor = new AltosIgnitor();
+ sitemap = new AltosUIMapNew();
+
/* Make the tabbed pane use the rest of the window space */
bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH));
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
- try {
- disconnect();
- } catch (Exception ex) {
- System.out.printf("Exception %s\n", ex.toString());
- for (StackTraceElement el : ex.getStackTrace())
- System.out.printf("%s\n", el.toString());
- }
- setVisible(false);
- dispose();
- AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
+ close();
}
});