X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosRomconfigUI.java;h=f8dcc3e1fe9ba83e8f21ca819b5673407a7c0d68;hp=481ce6565087d8b018d70ab8db062b81c499cd53;hb=9abacdaacf5ad1211da4fc72f5320ba9c43ff509;hpb=c8078d352a7f54a4a97d25af080155d3f875536a diff --git a/altosuilib/AltosRomconfigUI.java b/altosuilib/AltosRomconfigUI.java index 481ce656..f8dcc3e1 100644 --- a/altosuilib/AltosRomconfigUI.java +++ b/altosuilib/AltosRomconfigUI.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,12 +16,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_3; +package org.altusmetrum.altosuilib_13; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_5.*; +import org.altusmetrum.altoslib_13.*; public class AltosRomconfigUI extends AltosUIDialog @@ -39,10 +40,10 @@ 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); @@ -51,9 +52,11 @@ public class AltosRomconfigUI pane = getContentPane(); pane.setLayout(new GridBagLayout()); + int y = 0; + /* 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; @@ -62,7 +65,7 @@ public class AltosRomconfigUI pane.add(serial_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; @@ -71,31 +74,37 @@ public class AltosRomconfigUI serial_value = new JTextField("00000000"); pane.add(serial_value, c); - /* Radio calibration value */ - c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 1; - 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 = 1; - 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++; + + 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; @@ -106,7 +115,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; @@ -116,12 +125,10 @@ public class AltosRomconfigUI cancel.addActionListener(this); cancel.setActionCommand("cancel"); + y++; + pack(); setLocationRelativeTo(owner); - } - - public AltosRomconfigUI(JFrame frame, AltosRomconfig config) { - this(frame); set(config); } @@ -154,10 +161,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)); }