Add possibility to copy simulation extensions from other simulations
This commit is contained in:
parent
79fd36dc9f
commit
78d282f56f
@ -387,6 +387,7 @@ simedtdlg.border.SimExt = Simulation extensions
|
|||||||
simedtdlg.SimExt.desc = <html><i>Simulation extensions</i> enable advanced features and custom functionality during flight simulations. You can for example do hardware-in-the-loop testing with them.
|
simedtdlg.SimExt.desc = <html><i>Simulation extensions</i> enable advanced features and custom functionality during flight simulations. You can for example do hardware-in-the-loop testing with them.
|
||||||
simedtdlg.SimExt.noExtensions = No simulation extensions defined
|
simedtdlg.SimExt.noExtensions = No simulation extensions defined
|
||||||
simedtdlg.SimExt.add = Add extension
|
simedtdlg.SimExt.add = Add extension
|
||||||
|
simedtdlg.SimExt.copyExtension = Copy extension
|
||||||
simedtdlg.lbl.Noflightdata = No flight data available.
|
simedtdlg.lbl.Noflightdata = No flight data available.
|
||||||
simedtdlg.lbl.runsimfirst = Please run the simulation first.
|
simedtdlg.lbl.runsimfirst = Please run the simulation first.
|
||||||
simedtdlg.chart.Simflight = Simulated flight
|
simedtdlg.chart.Simflight = Simulated flight
|
||||||
|
@ -170,7 +170,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
//// Launch conditions
|
//// Launch conditions
|
||||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Launchcond"), new SimulationConditionsPanel(simulation[0]));
|
tabbedPane.addTab(trans.get("simedtdlg.tab.Launchcond"), new SimulationConditionsPanel(simulation[0]));
|
||||||
//// Simulation options
|
//// Simulation options
|
||||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Simopt"), new SimulationOptionsPanel(simulation[0]));
|
tabbedPane.addTab(trans.get("simedtdlg.tab.Simopt"), new SimulationOptionsPanel(document, simulation[0]));
|
||||||
|
|
||||||
tabbedPane.setSelectedIndex(0);
|
tabbedPane.setSelectedIndex(0);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import javax.swing.MenuElement;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
import net.sf.openrocket.gui.SpinnerEditor;
|
import net.sf.openrocket.gui.SpinnerEditor;
|
||||||
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
||||||
@ -51,12 +52,14 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
|
private OpenRocketDocument document;
|
||||||
final Simulation simulation;
|
final Simulation simulation;
|
||||||
|
|
||||||
private JPanel currentExtensions;
|
private JPanel currentExtensions;
|
||||||
|
|
||||||
SimulationOptionsPanel(final Simulation simulation) {
|
SimulationOptionsPanel(OpenRocketDocument document, final Simulation simulation) {
|
||||||
super(new MigLayout("fill"));
|
super(new MigLayout("fill"));
|
||||||
|
this.document = document;
|
||||||
this.simulation = simulation;
|
this.simulation = simulation;
|
||||||
|
|
||||||
final SimulationOptions conditions = simulation.getOptions();
|
final SimulationOptions conditions = simulation.getOptions();
|
||||||
@ -233,6 +236,38 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JMenu copyMenu = null;
|
||||||
|
for (Simulation sim : document.getSimulations()) {
|
||||||
|
if (!sim.getSimulationExtensions().isEmpty()) {
|
||||||
|
JMenu menu = new JMenu(sim.getName());
|
||||||
|
for (final SimulationExtension ext : sim.getSimulationExtensions()) {
|
||||||
|
JMenuItem item = new JMenuItem(ext.getName());
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
SimulationExtension e = ext.clone();
|
||||||
|
simulation.getSimulationExtensions().add(e);
|
||||||
|
updateCurrentExtensions();
|
||||||
|
SwingSimulationExtensionConfigurator configurator = findConfigurator(e);
|
||||||
|
if (configurator != null) {
|
||||||
|
configurator.configure(e, simulation, SwingUtilities.windowForComponent(SimulationOptionsPanel.this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copyMenu == null) {
|
||||||
|
copyMenu = new JMenu(trans.get("simedtdlg.SimExt.copyExtension"));
|
||||||
|
}
|
||||||
|
copyMenu.add(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (copyMenu != null) {
|
||||||
|
basemenu.add(copyMenu);
|
||||||
|
}
|
||||||
|
|
||||||
return basemenu;
|
return basemenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user