X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosuilib%2FAltosRomconfigUI.java;h=8f002c4a2a4b3ff96e47e5342c38d6ce92c88ed5;hb=debian;hp=743232180bb3dea9ccb1d21d9f0f36a0d6022324;hpb=a61217f0a6d0ef48b6471f632c4600255867e831;p=fw%2Faltos diff --git a/altosuilib/AltosRomconfigUI.java b/altosuilib/AltosRomconfigUI.java index 74323218..44d3a9f8 100644 --- a/altosuilib/AltosRomconfigUI.java +++ b/altosuilib/AltosRomconfigUI.java @@ -16,12 +16,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_12; +package org.altusmetrum.altosuilib_14; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_12.*; +import org.altusmetrum.altoslib_14.*; public class AltosRomconfigUI extends AltosUIDialog @@ -29,9 +29,11 @@ public class AltosRomconfigUI { Container pane; Box box; + JLabel product_label; JLabel serial_label; JLabel radio_calibration_label; + JLabel product_value; JFrame owner; JTextField serial_value; JTextField radio_calibration_value; @@ -40,63 +42,97 @@ public class AltosRomconfigUI JButton cancel; /* Build the UI using a grid bag */ - public AltosRomconfigUI(JFrame in_owner) { - super (in_owner, "Configure TeleMetrum Rom Values", true); + public AltosRomconfigUI(JFrame frame, AltosRomconfig config) { + super (frame, "Configure Rom Values", true); - owner = in_owner; + owner = frame; GridBagConstraints c; Insets il = new Insets(4,4,4,4); Insets ir = new Insets(4,4,4,4); - pane = getContentPane(); + pane = getScrollablePane(); pane.setLayout(new GridBagLayout()); + int y = 0; + + /* Product name */ /* Serial */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 0; + c.gridx = 0; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; - serial_label = new JLabel("Serial:"); - pane.add(serial_label, c); + product_label = new JLabel("Product:"); + pane.add(product_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 0; + c.gridx = 3; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = ir; - serial_value = new JTextField("00000000"); - pane.add(serial_value, c); + String product = "unknown"; + if (config != null) + product = config.usb_product; + product_value = new JLabel(product); + pane.add(product_value, c); + + y++; - /* Radio calibration value */ + /* Serial */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 1; + c.gridx = 0; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; - c.ipady = 5; - radio_calibration_label = new JLabel("Radio Calibration:"); - pane.add(radio_calibration_label, c); + serial_label = new JLabel("Serial:"); + pane.add(serial_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 1; + c.gridx = 3; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = ir; - c.ipady = 5; - radio_calibration_value = new JTextField("00000000"); - pane.add(radio_calibration_value, c); + serial_value = new JTextField("00000000"); + pane.add(serial_value, c); + + y++; + + if (config == null || AltosLib.has_radio(config.usb_id.pid)) { + /* Radio calibration value */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = y; + c.gridwidth = 3; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + radio_calibration_label = new JLabel("Radio Calibration:"); + pane.add(radio_calibration_label, c); + + c = new GridBagConstraints(); + c.gridx = 3; c.gridy = y; + c.gridwidth = 3; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + radio_calibration_value = new JTextField("00000000"); + pane.add(radio_calibration_value, c); + + y++; + } /* Buttons */ c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 2; + c.gridx = 0; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; @@ -107,7 +143,7 @@ public class AltosRomconfigUI ok.setActionCommand("ok"); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 2; + c.gridx = 3; c.gridy = y; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; @@ -117,12 +153,10 @@ public class AltosRomconfigUI cancel.addActionListener(this); cancel.setActionCommand("cancel"); + y++; + pack(); setLocationRelativeTo(owner); - } - - public AltosRomconfigUI(JFrame frame, AltosRomconfig config) { - this(frame); set(config); } @@ -155,10 +189,15 @@ public class AltosRomconfigUI } int radio_calibration() { + if (radio_calibration_value == null) + return 0; + return Integer.parseInt(radio_calibration_value.getText()); } void set_radio_calibration(int calibration) { + if (radio_calibration_value == null) + return; radio_calibration_value.setText(String.format("%d", calibration)); }