summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
257e971)
This lets you reconfigure and reboot telemetrum, including over the
radio link.
Signed-off-by: Keith Packard <keithp@keithp.com>
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
- if (cmd.equals("save")) {
+ if (cmd.equals("Save")) {
- } else if (cmd.equals("reset")) {
+ } else if (cmd.equals("Reset")) {
- } else if (cmd.equals("close")) {
+ } else if (cmd.equals("Reboot")) {
+ if (serial_line != null) {
+ try {
+ start_serial();
+ serial_line.printf("r eboot\n");
+ } catch (InterruptedException ie) {
+ } finally {
+ try {
+ stop_serial();
+ } catch (InterruptedException ie) {
+ }
+ }
+ serial_line.close();
+ }
+ } else if (cmd.equals("Close")) {
if (serial_line != null)
serial_line.close();
}
if (serial_line != null)
serial_line.close();
}
JButton save;
JButton reset;
JButton save;
JButton reset;
JButton close;
ActionListener listener;
JButton close;
ActionListener listener;
public void windowClosing(WindowEvent e) {
ui.actionPerformed(new ActionEvent(e.getSource(),
ActionEvent.ACTION_PERFORMED,
public void windowClosing(WindowEvent e) {
ui.actionPerformed(new ActionEvent(e.getSource(),
ActionEvent.ACTION_PERFORMED,
/* Product */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 0;
/* Product */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(product_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Version */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 1;
/* Version */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(version_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Serial */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 2;
/* Serial */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(serial_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Main deploy */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 3;
/* Main deploy */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 3;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(main_deploy_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Apogee delay */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 4;
/* Apogee delay */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(apogee_delay_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Radio channel */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 5;
/* Radio channel */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 5;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(radio_channel_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Radio Calibration */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 6;
/* Radio Calibration */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 6;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(radio_calibration_label, c);
c = new GridBagConstraints();
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;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Callsign */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 7;
/* Callsign */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 7;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(callsign_label, c);
c = new GridBagConstraints();
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.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Buttons */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 8;
/* Buttons */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 8;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
save = new JButton("Save");
pane.add(save, c);
save.addActionListener(this);
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 = 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);
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 = 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);
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));
}
addWindowListener(new ConfigListener(this));
}
}
/* If any values have been changed, confirm before closing */
}
/* If any values have been changed, confirm before closing */
- public boolean check_dirty() {
+ public boolean check_dirty(String operation) {
- Object[] options = { "Close anyway", "Keep editing" };
+ Object[] options = { String.format("%s anyway", operation), "Keep editing" };
int i;
i = JOptionPane.showOptionDialog(this,
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,
"Configuration Modified",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
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);
return;
listener.actionPerformed(e);
- if (cmd.equals("close")) {
+ if (cmd.equals("Close") || cmd.equals("Reboot")) {
setVisible(false);
dispose();
}
setVisible(false);
dispose();
}