Use the selectMotor method to update the whole ui and ensure that one
can add a new motor.
This commit is contained in:
parent
730abea70b
commit
b61ee0c5ab
@ -304,25 +304,25 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
this.add(rightSide);
|
this.add(rightSide);
|
||||||
|
|
||||||
// Update the panel data
|
// Update the panel data
|
||||||
scrollSelectionVisible();
|
|
||||||
updateData();
|
updateData();
|
||||||
setDelays(false);
|
setDelays(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotorMountAndConfig( MotorMount mount, String currentConfig ) {
|
public void setMotorMountAndConfig( MotorMount mount, String currentConfig ) {
|
||||||
|
ThrustCurveMotor motorToSelect = null;
|
||||||
if (currentConfig != null && mount != null) {
|
if (currentConfig != null && mount != null) {
|
||||||
MotorConfiguration motorConf = mount.getMotorConfiguration().get(currentConfig);
|
MotorConfiguration motorConf = mount.getMotorConfiguration().get(currentConfig);
|
||||||
selectedMotor = (ThrustCurveMotor) motorConf.getMotor();
|
motorToSelect = (ThrustCurveMotor) motorConf.getMotor();
|
||||||
selectedDelay = motorConf.getEjectionDelay();
|
selectedDelay = motorConf.getEjectionDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedMotorSet = null;
|
selectedMotorSet = null;
|
||||||
|
|
||||||
// If current motor is not found in db, add a new ThrustCurveMotorSet containing it
|
// If current motor is not found in db, add a new ThrustCurveMotorSet containing it
|
||||||
if (selectedMotor != null) {
|
if (motorToSelect != null) {
|
||||||
for (ThrustCurveMotorSet motorSet : database) {
|
for (ThrustCurveMotorSet motorSet : database) {
|
||||||
if (motorSet.getMotors().contains(selectedMotor)) {
|
if (motorSet.getMotors().contains(motorToSelect)) {
|
||||||
selectedMotorSet = motorSet;
|
selectedMotorSet = motorSet;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -330,15 +330,14 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
if (selectedMotorSet == null) {
|
if (selectedMotorSet == null) {
|
||||||
database = new ArrayList<ThrustCurveMotorSet>(database);
|
database = new ArrayList<ThrustCurveMotorSet>(database);
|
||||||
ThrustCurveMotorSet extra = new ThrustCurveMotorSet();
|
ThrustCurveMotorSet extra = new ThrustCurveMotorSet();
|
||||||
extra.addMotor(selectedMotor);
|
extra.addMotor(motorToSelect);
|
||||||
selectedMotorSet = extra;
|
selectedMotorSet = extra;
|
||||||
database.add(extra);
|
database.add(extra);
|
||||||
Collections.sort(database);
|
Collections.sort(database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData();
|
select(motorToSelect);
|
||||||
setDelays(true);
|
|
||||||
|
|
||||||
motorFilterPanel.setMotorMount(mount);
|
motorFilterPanel.setMotorMount(mount);
|
||||||
scrollSelectionVisible();
|
scrollSelectionVisible();
|
||||||
@ -394,7 +393,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
* Called when a different motor is selected from within the panel.
|
* Called when a different motor is selected from within the panel.
|
||||||
*/
|
*/
|
||||||
private void select(ThrustCurveMotor motor) {
|
private void select(ThrustCurveMotor motor) {
|
||||||
if (selectedMotor == motor)
|
if (selectedMotor == motor || motor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ThrustCurveMotorSet set = findMotorSet(motor);
|
ThrustCurveMotorSet set = findMotorSet(motor);
|
||||||
@ -410,6 +409,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
if (updateDelays) {
|
if (updateDelays) {
|
||||||
setDelays(true);
|
setDelays(true);
|
||||||
}
|
}
|
||||||
|
scrollSelectionVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user