[bugfix] 'remove motor' button now works correctly

This commit is contained in:
Daniel_M_Williams 2015-11-26 09:05:08 -05:00
parent a32b303069
commit a43fbe79bc
4 changed files with 12 additions and 33 deletions

View File

@ -1,6 +1,9 @@
package net.sf.openrocket.rocketcomponent;
package net.sf.openrocket.motor;
import net.sf.openrocket.motor.MotorInstance;
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
import net.sf.openrocket.rocketcomponent.ParameterSet;
import net.sf.openrocket.rocketcomponent.RocketComponent;
/**
* FlightConfigurationSet for motors.

View File

@ -6,6 +6,7 @@ import java.util.Iterator;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.MotorConfigurationSet;
import net.sf.openrocket.motor.MotorInstance;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.startup.Application;
@ -373,8 +374,8 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
@Override
public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance){
if( null == newMotorInstance){
throw new NullPointerException(" null passed as MotorInstance to add to MotorSet ... bug ");
if((null == newMotorInstance)||(newMotorInstance.equals( MotorInstance.EMPTY_INSTANCE ))){
this.motors.set( fcid, null);
}else{
if( null == newMotorInstance.getMount()){
newMotorInstance.setMount(this);

View File

@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.MotorConfigurationSet;
import net.sf.openrocket.motor.MotorInstance;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.startup.Application;
@ -237,30 +238,6 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return newArray;
}
// @Override
// public Coordinate[] getLocations(){
// if (null == this.parent) {
// throw new BugException(" Attempted to get absolute position Vector of a Stage without a parent. ");
// }
//
// final Coordinate center = parentInstances[0].add( this.position);
// Coordinate[] instanceLocations = this.getInstanceOffsets();
// Coordinate[] toReturn = new Coordinate[ instanceLocations.length];
// for( int i = 0; i < toReturn.length; i++){
// toReturn[i] = center.add( instanceLocations[i]);
// }
//
// return toReturn;
//
// Coordinate[] parentInstances = this.parent.getLocations();
// for( int i=0; i< parentInstances.length; i++){
// parentInstances[i] = parentInstances[i].add( this.position );
// }
// Coordinate[] toReturn = this.shiftCoordinates(parentInstances);
//
// return toReturn;
// }
// @Override
// protected Coordinate[] shiftCoordinates(Coordinate[] array) {
// array = super.shiftCoordinates(array);
@ -298,8 +275,8 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
@Override
public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance){
if( null == newMotorInstance){
throw new NullPointerException(" null passed as MotorInstance to add to MotorSet ... bug ");
if((null == newMotorInstance)||(newMotorInstance.equals( MotorInstance.EMPTY_INSTANCE ))){
this.motors.set( fcid, null);
}else{
if( null == newMotorInstance.getMount()){
newMotorInstance.setMount(this);

View File

@ -236,9 +236,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
return;
}
MotorInstance curInstance = MotorInstance.EMPTY_INSTANCE;
curMount.setMotorInstance( fcid, curInstance);
curMount.setMotorInstance( fcid, null);
fireTableDataChanged();
}