X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosConfigUI.java;h=cfa5d7b9ee7b5982d7b497d8aaeeb448ef35f38e;hp=37128573c966ea39cd57fba2c7f5fab6dc8da63a;hb=357826aa9c7b42c59f5d52b8eb016d73b6da0c7f;hpb=9c32b93ef5fb43558fb0179ea1b047e35b7ed6e8 diff --git a/ao-tools/altosui/AltosConfigUI.java b/ao-tools/altosui/AltosConfigUI.java index 37128573..cfa5d7b9 100644 --- a/ao-tools/altosui/AltosConfigUI.java +++ b/ao-tools/altosui/AltosConfigUI.java @@ -29,19 +29,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.Altos; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosFlightStatusTableModel; -import altosui.AltosFlightInfoTableModel; - import libaltosJNI.*; public class AltosConfigUI @@ -74,6 +61,7 @@ public class AltosConfigUI JButton save; JButton reset; + JButton reboot; JButton close; ActionListener listener; @@ -105,12 +93,12 @@ public class AltosConfigUI public void windowClosing(WindowEvent e) { ui.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, - "close")); + "Close")); } } /* Build the UI using a grid bag */ - public AltosConfigUI(JFrame in_owner) { + public AltosConfigUI(JFrame in_owner, boolean remote) { super (in_owner, "Configure TeleMetrum", false); owner = in_owner; @@ -125,7 +113,7 @@ public class AltosConfigUI /* Product */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -133,8 +121,8 @@ public class AltosConfigUI pane.add(product_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 0; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 0; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -145,7 +133,7 @@ public class AltosConfigUI /* Version */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -154,8 +142,8 @@ public class AltosConfigUI pane.add(version_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 1; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 1; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -167,7 +155,7 @@ public class AltosConfigUI /* Serial */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 2; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -176,8 +164,8 @@ public class AltosConfigUI pane.add(serial_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 2; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 2; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -189,7 +177,7 @@ public class AltosConfigUI /* Main deploy */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -198,8 +186,8 @@ public class AltosConfigUI pane.add(main_deploy_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 3; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -213,7 +201,7 @@ public class AltosConfigUI /* Apogee delay */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 4; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -222,8 +210,8 @@ public class AltosConfigUI pane.add(apogee_delay_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 4; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 4; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -237,7 +225,7 @@ public class AltosConfigUI /* Radio channel */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -246,8 +234,8 @@ public class AltosConfigUI pane.add(radio_channel_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 5; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 5; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -256,12 +244,14 @@ public class AltosConfigUI radio_channel_value = new JComboBox(radio_channel_values); radio_channel_value.setEditable(false); radio_channel_value.addItemListener(this); + if (remote) + radio_channel_value.setEnabled(false); pane.add(radio_channel_value, c); /* Radio Calibration */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 6; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -270,8 +260,8 @@ public class AltosConfigUI pane.add(radio_calibration_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 6; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 6; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -279,12 +269,14 @@ public class AltosConfigUI c.ipady = 5; radio_calibration_value = new JTextField(String.format("%d", 1186611)); radio_calibration_value.getDocument().addDocumentListener(this); + if (remote) + radio_calibration_value.setEnabled(false); pane.add(radio_calibration_value, c); /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 7; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -293,50 +285,61 @@ public class AltosConfigUI pane.add(callsign_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 7; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 7; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - callsign_value = new JTextField("N0CALL"); + callsign_value = new JTextField(AltosPreferences.callsign()); callsign_value.getDocument().addDocumentListener(this); pane.add(callsign_value, c); /* Buttons */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 8; - c.gridwidth = 6; + c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; save = new JButton("Save"); pane.add(save, c); save.addActionListener(this); - save.setActionCommand("save"); + save.setActionCommand("Save"); c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 8; - c.gridwidth = 6; + c.gridx = 2; c.gridy = 8; + c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = il; reset = new JButton("Reset"); pane.add(reset, c); reset.addActionListener(this); - reset.setActionCommand("reset"); + reset.setActionCommand("Reset"); c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 8; - c.gridwidth = 6; + c.gridx = 4; c.gridy = 8; + c.gridwidth = 2; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = il; + reboot = new JButton("Reboot"); + pane.add(reboot, c); + reboot.addActionListener(this); + reboot.setActionCommand("Reboot"); + + c = new GridBagConstraints(); + c.gridx = 6; c.gridy = 8; + c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_END; c.insets = il; close = new JButton("Close"); pane.add(close, c); close.addActionListener(this); - close.setActionCommand("close"); + close.setActionCommand("Close"); addWindowListener(new ConfigListener(this)); } @@ -349,12 +352,12 @@ public class AltosConfigUI } /* If any values have been changed, confirm before closing */ - public boolean check_dirty() { + public boolean check_dirty(String operation) { if (dirty) { - Object[] options = { "Close anyway", "Keep editing" }; + Object[] options = { String.format("%s anyway", operation), "Keep editing" }; int i; i = JOptionPane.showOptionDialog(this, - "Configuration modified, close anyway?", + String.format("Configuration modified. %s anyway?", operation), "Configuration Modified", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, @@ -369,11 +372,11 @@ public class AltosConfigUI public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); - if (cmd.equals("close")) - if (!check_dirty()) + if (cmd.equals("Close") || cmd.equals("Reboot")) + if (!check_dirty(cmd)) return; listener.actionPerformed(e); - if (cmd.equals("close")) { + if (cmd.equals("Close") || cmd.equals("Reboot")) { setVisible(false); dispose(); }