I like it better when the close button copies the SimulationOptions.

Only SimulationOptions needs to be a little bit smarter about when to
fire the change event.
This commit is contained in:
kruland2607 2013-06-05 21:20:50 -05:00
parent 4cfc65fbe2
commit 7d30bcb67b
2 changed files with 66 additions and 19 deletions

View File

@ -213,6 +213,7 @@ public class SimulationEditDialog extends JDialog {
close.addActionListener(new ActionListener() { close.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
copyChangesToAllSims();
SimulationEditDialog.this.dispose(); SimulationEditDialog.this.dispose();
} }
}); });

View File

@ -452,25 +452,71 @@ public class SimulationOptions implements ChangeSource, Cloneable {
fireChangeEvent(); fireChangeEvent();
} }
public void copyConditionsFrom(SimulationOptions src) { public void copyConditionsFrom(SimulationOptions src) {
// Be a little smart about triggering the change event.
this.launchAltitude = src.launchAltitude; // only do it if one of the "important" (user specified) parameters has really changed.
this.launchLatitude = src.launchLatitude; boolean isChanged = false;
this.launchLongitude = src.launchLongitude; if (this.launchAltitude != src.launchAltitude) {
this.launchPressure = src.launchPressure; isChanged = true;
this.launchRodAngle = src.launchRodAngle; this.launchAltitude = src.launchAltitude;
this.launchRodDirection = src.launchRodDirection; }
this.launchRodLength = src.launchRodLength; if (this.launchLatitude != src.launchLatitude) {
this.launchTemperature = src.launchTemperature; isChanged = true;
this.maximumAngle = src.maximumAngle; this.launchLatitude = src.launchLatitude;
this.timeStep = src.timeStep; }
this.windAverage = src.windAverage; if (this.launchLongitude != src.launchLongitude) {
this.windTurbulence = src.windTurbulence; isChanged = true;
this.calculateExtras = src.calculateExtras; this.launchLongitude = src.launchLongitude;
this.randomSeed = src.randomSeed; }
if (this.launchPressure != src.launchPressure) {
fireChangeEvent(); isChanged = true;
} this.launchPressure = src.launchPressure;
}
if (this.launchRodAngle != src.launchRodAngle) {
isChanged = true;
this.launchRodAngle = src.launchRodAngle;
}
if (this.launchRodDirection != src.launchRodDirection) {
isChanged = true;
this.launchRodDirection = src.launchRodDirection;
}
if (this.launchRodLength != src.launchRodLength) {
isChanged = true;
this.launchRodLength = src.launchRodLength;
}
if (this.launchTemperature != src.launchTemperature) {
isChanged = true;
this.launchTemperature = src.launchTemperature;
}
if (this.maximumAngle != src.maximumAngle) {
isChanged = true;
this.maximumAngle = src.maximumAngle;
}
this.maximumAngle = src.maximumAngle;
if (this.timeStep != src.timeStep) {
isChanged = true;
this.timeStep = src.timeStep;
}
if (this.windAverage != src.windAverage) {
isChanged = true;
this.windAverage = src.windAverage;
}
if (this.windTurbulence != src.windTurbulence) {
isChanged = true;
this.windTurbulence = src.windTurbulence;
}
if (this.calculateExtras != src.calculateExtras) {
isChanged = true;
this.calculateExtras = src.calculateExtras;
}
if (isChanged) {
// Only copy the randomSeed if something else has changed.
// Honestly, I don't really see a need for that.
this.randomSeed = src.randomSeed;
fireChangeEvent();
}
}
/** /**