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