Add undo positions to motor & recovery actions
This commit is contained in:
parent
bb01c859f6
commit
ea0a6aefca
@ -88,15 +88,15 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
tabs = new JTabbedPane();
|
||||
|
||||
//// Motor tabs
|
||||
motorConfigurationPanel = new MotorConfigurationPanel(this, rocket);
|
||||
motorConfigurationPanel = new MotorConfigurationPanel(this, document, rocket);
|
||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Motortab"), motorConfigurationPanel);
|
||||
|
||||
//// Recovery tab
|
||||
recoveryConfigurationPanel = new RecoveryConfigurationPanel(this, rocket);
|
||||
recoveryConfigurationPanel = new RecoveryConfigurationPanel(this, document, rocket);
|
||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Recoverytab"), recoveryConfigurationPanel);
|
||||
|
||||
//// Stage tab
|
||||
separationConfigurationPanel = new SeparationConfigurationPanel(this, rocket);
|
||||
separationConfigurationPanel = new SeparationConfigurationPanel(this, document, rocket);
|
||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Stagetab"), separationConfigurationPanel);
|
||||
|
||||
//// New configuration
|
||||
@ -239,6 +239,8 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
FlightConfigurationId initFcId = fcIds.get(0);
|
||||
String initName = rocket.getFlightConfiguration(initFcId).getNameRaw();
|
||||
|
||||
document.addUndoPosition("Rename configuration(s)");
|
||||
|
||||
// Launch the rename dialog
|
||||
RenameConfigDialog dialog = new RenameConfigDialog(SwingUtilities.getWindowAncestor(this), rocket, initFcId);
|
||||
dialog.setVisible(true);
|
||||
@ -246,8 +248,6 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
// Get the name of the (potentially renamed) config
|
||||
String newName = rocket.getFlightConfiguration(initFcId).getNameRaw();
|
||||
|
||||
document.addUndoPosition("Rename configuration(s)");
|
||||
|
||||
boolean update = !newName.equals(initName);
|
||||
for (int i = 1; i < fcIds.size(); i++) {
|
||||
FlightConfiguration config = rocket.getFlightConfiguration(fcIds.get(i));
|
||||
@ -267,6 +267,8 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
if (fcIds == null || fcIds.size() == 0)
|
||||
return;
|
||||
|
||||
document.addUndoPosition("Remove configuration(s)");
|
||||
|
||||
for (FlightConfigurationId fcId : fcIds) {
|
||||
document.removeFlightConfigurationAndSimulations(fcId);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.gui.main.FlightConfigurationPanel;
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.util.ArrayList;
|
||||
@ -51,12 +52,14 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
||||
protected RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||
|
||||
protected final FlightConfigurationPanel flightConfigurationPanel;
|
||||
protected final OpenRocketDocument document;
|
||||
protected final Rocket rocket;
|
||||
protected final JTable table;
|
||||
|
||||
public FlightConfigurablePanel(final FlightConfigurationPanel flightConfigurationPanel, Rocket rocket) {
|
||||
public FlightConfigurablePanel(final FlightConfigurationPanel flightConfigurationPanel, OpenRocketDocument document, Rocket rocket) {
|
||||
super(new MigLayout("fill"));
|
||||
this.flightConfigurationPanel = flightConfigurationPanel;
|
||||
this.document = document;
|
||||
this.rocket = rocket;
|
||||
table = doTableInitialization();
|
||||
|
||||
|
@ -28,6 +28,7 @@ import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.IgnitionSelectionDialog;
|
||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.MotorMountConfigurationPanel;
|
||||
import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog;
|
||||
@ -64,8 +65,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
private final JPopupMenu popupMenuFull; // popup menu containing all the options
|
||||
|
||||
|
||||
public MotorConfigurationPanel(final FlightConfigurationPanel flightConfigurationPanel, Rocket rocket) {
|
||||
super(flightConfigurationPanel, rocket);
|
||||
public MotorConfigurationPanel(final FlightConfigurationPanel flightConfigurationPanel, OpenRocketDocument document, Rocket rocket) {
|
||||
super(flightConfigurationPanel, document, rocket);
|
||||
|
||||
motorChooserDialog = new MotorChooserDialog(SwingUtilities.getWindowAncestor(flightConfigurationPanel));
|
||||
|
||||
@ -306,6 +307,9 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
|
||||
double initDelay = initMount.getMotorConfig(initFcId).getEjectionDelay();
|
||||
|
||||
document.addUndoPosition("Select motor");
|
||||
|
||||
// Open the motor chooser dialog
|
||||
motorChooserDialog.setMotorMountAndConfig(initFcId, initMount);
|
||||
motorChooserDialog.open();
|
||||
|
||||
@ -343,6 +347,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
return;
|
||||
}
|
||||
|
||||
document.addUndoPosition("Delete motor(s)");
|
||||
|
||||
for (MotorMount mount : mounts) {
|
||||
for (FlightConfigurationId fcId : fcIds) {
|
||||
mount.setMotorConfig(null, fcId);
|
||||
@ -367,6 +373,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
IgnitionEvent initialIgnitionEvent = initConfig.getIgnitionEvent();
|
||||
double initialIgnitionDelay = initConfig.getIgnitionDelay();
|
||||
|
||||
document.addUndoPosition("Select ignition");
|
||||
|
||||
// this call also performs the update changes
|
||||
IgnitionSelectionDialog ignitionDialog = new IgnitionSelectionDialog(
|
||||
SwingUtilities.getWindowAncestor(this.flightConfigurationPanel),
|
||||
@ -410,6 +418,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
return;
|
||||
}
|
||||
|
||||
document.addUndoPosition("Reset ignition");
|
||||
|
||||
boolean update = false;
|
||||
for (MotorMount mount : mounts) {
|
||||
for (FlightConfigurationId fcId : fcIds) {
|
||||
|
@ -21,6 +21,7 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.DeploymentSelectionDialog;
|
||||
import net.sf.openrocket.gui.main.FlightConfigurationPanel;
|
||||
@ -42,8 +43,8 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
||||
private final JPopupMenu popupMenuFull; // popup menu containing all the options
|
||||
|
||||
|
||||
public RecoveryConfigurationPanel(FlightConfigurationPanel flightConfigurationPanel, Rocket rocket) {
|
||||
super(flightConfigurationPanel,rocket);
|
||||
public RecoveryConfigurationPanel(FlightConfigurationPanel flightConfigurationPanel, OpenRocketDocument document, Rocket rocket) {
|
||||
super(flightConfigurationPanel, document, rocket);
|
||||
|
||||
JScrollPane scroll = new JScrollPane(table);
|
||||
this.add(scroll, "span, grow, pushy, wrap");
|
||||
@ -176,7 +177,11 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
||||
FlightConfigurationId initFcId = fcIds.get(0);
|
||||
|
||||
DeploymentConfiguration initialConfig = initDevice.getDeploymentConfigurations().get(initFcId).copy(initFcId);
|
||||
JDialog d = new DeploymentSelectionDialog(SwingUtilities.getWindowAncestor(this), rocket, initDevice);
|
||||
|
||||
document.addUndoPosition("Select deployment");
|
||||
|
||||
// Open the configuration dialog
|
||||
JDialog d = new DeploymentSelectionDialog(SwingUtilities.getWindowAncestor(this), rocket, initFcId, initDevice);
|
||||
d.setVisible(true);
|
||||
|
||||
final DeploymentConfiguration modifiedConfig = initDevice.getDeploymentConfigurations().get(initFcId);
|
||||
@ -221,6 +226,8 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
||||
return;
|
||||
}
|
||||
|
||||
document.addUndoPosition("Reset deployment");
|
||||
|
||||
boolean update = false;
|
||||
for (RecoveryDevice device : devices) {
|
||||
for (FlightConfigurationId fcId : fcIds) {
|
||||
|
@ -21,6 +21,7 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.SeparationSelectionDialog;
|
||||
import net.sf.openrocket.gui.main.FlightConfigurationPanel;
|
||||
@ -47,8 +48,8 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
||||
private final JPopupMenu popupMenuFull; // popup menu containing all the options
|
||||
|
||||
|
||||
public SeparationConfigurationPanel(FlightConfigurationPanel flightConfigurationPanel, Rocket rocket) {
|
||||
super(flightConfigurationPanel,rocket);
|
||||
public SeparationConfigurationPanel(FlightConfigurationPanel flightConfigurationPanel, OpenRocketDocument document, Rocket rocket) {
|
||||
super(flightConfigurationPanel, document, rocket);
|
||||
|
||||
JScrollPane scroll = new JScrollPane(table);
|
||||
this.add(scroll, "span, grow, pushy, wrap");
|
||||
@ -187,6 +188,8 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
||||
// Store the initial configuration so we can check later whether something changed
|
||||
StageSeparationConfiguration initialConfig = initStage.getSeparationConfigurations().get(initFcId).copy(initFcId);
|
||||
|
||||
document.addUndoPosition("Select separation");
|
||||
|
||||
// Launch the separation config dialog
|
||||
JDialog d = new SeparationSelectionDialog(SwingUtilities.getWindowAncestor(this), rocket, initStage);
|
||||
d.setVisible(true);
|
||||
@ -198,7 +201,7 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
||||
double separationDelay = initStage.getSeparationConfigurations().get(initFcId).getSeparationDelay();
|
||||
SeparationEvent separationEvent= initStage.getSeparationConfigurations().get(initFcId).getSeparationEvent();
|
||||
|
||||
// Parse all stages anc flight configurations to check whether we need to update
|
||||
// Parse all stages and flight configurations to check whether we need to update
|
||||
for (int i = 0; i < stages.size(); i++) {
|
||||
for (int j = 0; j < fcIds.size(); j++) {
|
||||
if ((i == 0) && (j == 0)) break;
|
||||
@ -236,6 +239,8 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
||||
return;
|
||||
}
|
||||
|
||||
document.addUndoPosition("Reset separation");
|
||||
|
||||
boolean update = false;
|
||||
for (AxialStage stage : stages) {
|
||||
for (FlightConfigurationId fcId : fcIds) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user