Fix some ui update and data entry issues.
This commit is contained in:
parent
9d44df1af3
commit
a0b3ccae08
@ -32,6 +32,7 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
private final JButton renameConfButton, removeConfButton, copyConfButton;
|
||||
|
||||
private final MotorConfigurationPanel motorConfigurationPanel;
|
||||
private final RecoveryConfigurationPanel recoveryConfigurationPanel;
|
||||
|
||||
private String currentID = null;
|
||||
|
||||
@ -108,7 +109,8 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Motortab"), motorConfigurationPanel);
|
||||
|
||||
//// Recovery tab
|
||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Recoverytab"), new RecoveryConfigurationPanel(this,rocket));
|
||||
recoveryConfigurationPanel = new RecoveryConfigurationPanel(this,rocket);
|
||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Recoverytab"), recoveryConfigurationPanel );
|
||||
|
||||
//// Close button
|
||||
JButton close = new JButton(trans.get("dlg.but.close"));
|
||||
@ -147,7 +149,7 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
currentID = id;
|
||||
rocket.getDefaultConfiguration().setFlightConfigurationID(currentID);
|
||||
motorConfigurationPanel.fireTableDataChanged();
|
||||
// FIXME - update data in recovery configuration panel
|
||||
recoveryConfigurationPanel.fireTableDataChanged();
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
@ -155,15 +157,13 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
currentID = rocket.newFlightConfigurationID();
|
||||
rocket.getDefaultConfiguration().setFlightConfigurationID(currentID);
|
||||
motorConfigurationPanel.fireTableDataChanged();
|
||||
// FIXME - update data in recovery configuration panel
|
||||
flightConfigurationModel.fireContentsUpdated();
|
||||
recoveryConfigurationPanel.fireTableDataChanged();
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
public void changeConfigurationName( String newName ) {
|
||||
rocket.setFlightConfigurationName(currentID, newName);
|
||||
motorConfigurationPanel.fireTableDataChanged();
|
||||
// FIXME - update data in recovery configuration panel
|
||||
flightConfigurationModel.fireContentsUpdated();
|
||||
}
|
||||
|
||||
@ -173,8 +173,8 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
rocket.removeFlightConfigurationID(currentID);
|
||||
rocket.getDefaultConfiguration().setFlightConfigurationID(null);
|
||||
motorConfigurationPanel.fireTableDataChanged();
|
||||
// FIXME - update data in recovery configuration panel
|
||||
flightConfigurationModel.fireContentsUpdated();
|
||||
recoveryConfigurationPanel.fireTableDataChanged();
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ public class FlightConfigurationDialog extends JDialog {
|
||||
removeConfButton.setEnabled(currentID != null);
|
||||
renameConfButton.setEnabled(currentID != null);
|
||||
motorConfigurationPanel.updateButtonState();
|
||||
// FIXME - update button state in recovery configuration panel
|
||||
recoveryConfigurationPanel.updateButtonState();
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,10 +20,10 @@ import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog;
|
||||
import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.rocketcomponent.MotorConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
|
||||
import net.sf.openrocket.util.Chars;
|
||||
|
||||
public class MotorConfigurationPanel extends JPanel {
|
||||
@ -135,7 +135,9 @@ public class MotorConfigurationPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void fireTableDataChanged() {
|
||||
currentMount = null;
|
||||
configurationTableModel.fireTableDataChanged();
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
public void updateButtonState() {
|
||||
@ -238,7 +240,7 @@ public class MotorConfigurationPanel extends JPanel {
|
||||
if (motor == null)
|
||||
//// None
|
||||
return null;
|
||||
IgnitionEvent ignition = mount.getIgnitionEvent();
|
||||
MotorConfiguration.IgnitionEvent ignition = mount.getIgnitionEvent();
|
||||
return ignition.toString();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ public class RecoveryConfigurationPanel extends JPanel {
|
||||
|
||||
private final FlightConfigurationDialog flightConfigurationDialog;
|
||||
private final Rocket rocket;
|
||||
|
||||
private final RecoveryTableModel recoveryTableModel;
|
||||
private final JButton selectDeploymentButton;
|
||||
private final JButton resetDeploymentButton;
|
||||
|
||||
@ -35,7 +37,8 @@ public class RecoveryConfigurationPanel extends JPanel {
|
||||
this.rocket = rocket;
|
||||
|
||||
//// Recovery selection
|
||||
JTable table = new JTable( new RecoveryTableModel() );
|
||||
recoveryTableModel = new RecoveryTableModel();
|
||||
JTable table = new JTable( recoveryTableModel );
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.setCellSelectionEnabled(true);
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@ -89,19 +92,31 @@ public class RecoveryConfigurationPanel extends JPanel {
|
||||
|
||||
}
|
||||
|
||||
public void fireTableDataChanged() {
|
||||
selectedComponent = null;
|
||||
recoveryTableModel.fireTableDataChanged();
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
private void selectDeployment() {
|
||||
JDialog d = new SelectDeploymentConfigDialog( flightConfigurationDialog, rocket, selectedComponent );
|
||||
d.setVisible(true);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
private void resetDeployment() {
|
||||
selectedComponent.setFlightConfiguration(rocket.getDefaultConfiguration().getFlightConfigurationID(), null);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
private void updateButtonState() {
|
||||
boolean buttonsEnabled = selectedComponent != null;
|
||||
selectDeploymentButton.setEnabled(buttonsEnabled);
|
||||
resetDeploymentButton.setEnabled(buttonsEnabled);
|
||||
public void updateButtonState() {
|
||||
boolean componentSelected = selectedComponent != null;
|
||||
boolean isDefaulted = true;
|
||||
if ( componentSelected ) {
|
||||
isDefaulted = selectedComponent.getFlightConfiguration(rocket.getDefaultConfiguration().getFlightConfigurationID()) == null;
|
||||
}
|
||||
selectDeploymentButton.setEnabled(componentSelected);
|
||||
resetDeploymentButton.setEnabled(componentSelected & ! isDefaulted);
|
||||
}
|
||||
|
||||
private RecoveryDevice findRecoveryDevice( int count ) {
|
||||
|
@ -110,7 +110,7 @@ public class SelectDeploymentConfigDialog extends JDialog {
|
||||
newConfiguration.setDeployDelay(deployDelay);
|
||||
|
||||
//// extract altitude;
|
||||
double deployAltitude = alt.getCurrentUnit().fromUnit( alt.getValue() );
|
||||
double deployAltitude = alt.getValue();
|
||||
newConfiguration.setDeployAltitude(deployAltitude);
|
||||
|
||||
component.setFlightConfiguration(configId, newConfiguration);
|
||||
|
Loading…
x
Reference in New Issue
Block a user