[#2159] Add multi-sim edit indicators

This commit is contained in:
SiboVG 2023-03-30 18:57:58 +02:00
parent 26f6473446
commit 33e3c4314c
2 changed files with 29 additions and 5 deletions

View File

@ -409,6 +409,8 @@ simedtdlg.but.savedefault = Save as default
simedtdlg.but.add = Add simedtdlg.but.add = Add
simedtdlg.but.delete = Delete simedtdlg.but.delete = Delete
simedtdlg.title.Editsim = Edit simulation simedtdlg.title.Editsim = Edit simulation
simedtdlg.title.MultiSimEdit = Multi-simulation edit
simedtdlg.title.MultiSimEdit.ttip = <html>You are editing the following simulations:<br>
simedtdlg.lbl.Simname = Simulation name: simedtdlg.lbl.Simname = Simulation name:
simedtdlg.tab.Launchcond = Launch conditions simedtdlg.tab.Launchcond = Launch conditions
simedtdlg.tab.Simopt = Simulation options simedtdlg.tab.Simopt = Simulation options

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.gui.simulation;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -30,6 +31,7 @@ import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation; import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.document.events.DocumentChangeEvent; import net.sf.openrocket.document.events.DocumentChangeEvent;
import net.sf.openrocket.gui.components.ConfigurationComboBox; import net.sf.openrocket.gui.components.ConfigurationComboBox;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.widgets.SelectColorButton; import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
@ -62,7 +64,8 @@ public class SimulationEditDialog extends JDialog {
public SimulationEditDialog(Window parent, final OpenRocketDocument document, boolean isNewSimulation, Simulation... sims) { public SimulationEditDialog(Window parent, final OpenRocketDocument document, boolean isNewSimulation, Simulation... sims) {
//// Edit simulation //// Edit simulation
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL); super(parent, sims.length == 1 ? trans.get("simedtdlg.title.Editsim") : trans.get("simedtdlg.title.MultiSimEdit"),
JDialog.ModalityType.DOCUMENT_MODAL);
this.document = document; this.document = document;
this.parentWindow = parent; this.parentWindow = parent;
this.simulationList = sims; this.simulationList = sims;
@ -109,7 +112,9 @@ public class SimulationEditDialog extends JDialog {
} }
public void setEditMode() { public void setEditMode() {
setTitle((isModified ? "* " : "") + trans.get("simedtdlg.title.Editsim")); String baseTitle = simulationList.length == 1 ?
trans.get("simedtdlg.title.Editsim") : trans.get("simedtdlg.title.MultiSimEdit");
setTitle((isModified ? "* " : "") + baseTitle);
CardLayout cl = (CardLayout) (cards.getLayout()); CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, EDITMODE); cl.show(cards, EDITMODE);
cards.validate(); cards.validate();
@ -147,7 +152,7 @@ public class SimulationEditDialog extends JDialog {
} }
private void buildEditCard() { private void buildEditCard() {
JPanel simEditPanel = new JPanel(new MigLayout("fill")); JPanel simEditPanel = new JPanel(new MigLayout("fill, hidemode 1"));
if (isSingleEdit()) { if (isSingleEdit()) {
JPanel panel = new JPanel(new MigLayout("fill, ins 0")); JPanel panel = new JPanel(new MigLayout("fill, ins 0"));
@ -232,13 +237,30 @@ public class SimulationEditDialog extends JDialog {
} }
}); });
simEditPanel.add(button, "spanx, split 4, align left"); simEditPanel.add(button, "spanx, split 5, align left");
if (allowsPlotMode()) { if (allowsPlotMode()) {
button.setVisible(true); button.setVisible(true);
} else { } else {
button.setVisible(false); button.setVisible(false);
} }
//// Multi-simulation edit
if (simulationList.length > 1) {
StyledLabel multiSimEditLabel = new StyledLabel("", -1, StyledLabel.Style.BOLD);
multiSimEditLabel.setFontColor(new Color(170, 0, 100));
multiSimEditLabel.setText(trans.get("simedtdlg.title.MultiSimEdit"));
StringBuilder components = new StringBuilder(trans.get("simedtdlg.title.MultiSimEdit.ttip"));
for (int i = 0; i < simulationList.length; i++) {
if (i < simulationList.length - 1) {
components.append(simulationList[i].getName()).append(", ");
} else {
components.append(simulationList[i].getName());
}
}
multiSimEditLabel.setToolTipText(components.toString());
simEditPanel.add(multiSimEditLabel, "align left");
}
//// Run simulation button //// Run simulation button
button = new SelectColorButton(trans.get("SimulationEditDialog.btn.simulateAndPlot")); button = new SelectColorButton(trans.get("SimulationEditDialog.btn.simulateAndPlot"));
if (!isSingleEdit()) { if (!isSingleEdit()) {