[#2456] Fix sim no data issues

This commit is contained in:
SiboVG 2024-02-20 15:51:20 +01:00
parent 80d82ad99d
commit cbc392ca70
4 changed files with 36 additions and 17 deletions

View File

@ -547,7 +547,9 @@ SimulationConfigDialog.CancelOperation.title = Cancel operation
SimulationConfigDialog.CancelOperation.checkbox.dontAskAgain = Don't ask me again
SimulationConfigDialog.tab.warnDis.ttip = Warnings not supported for multi-simulation editing
SimulationConfigDialog.tab.plotDis.ttip = Plotting not supported for multi-simulation editing
SimulationConfigDialog.tab.plotNoData.ttip = Simulation has no data to plot
SimulationConfigDialog.tab.expDis.ttip = Exporting not supported for multi-simulation editing
SimulationConfigDialog.tab.expNoData.ttip = Simulation has no data to export
! SimulationWarningsPanel
SimulationWarningsPanel.lbl.CriticalWarnings = Critical Warning(s)

View File

@ -790,6 +790,12 @@ public class SimulationPanel extends JPanel {
if (includeSimName) {
tip.append("<b>").append(sim.getName()).append("</b><br>");
}
if (data == null) {
tip.append(trans.get("simpanel.ttip.noData"));
return tip.toString();
}
switch (sim.getStatus()) {
case CANT_RUN:
tip.append(trans.get("simpanel.ttip.noData")).append("<br>");
@ -814,11 +820,6 @@ public class SimulationPanel extends JPanel {
return tip.toString();
}
if (data == null) {
tip.append(trans.get("simpanel.ttip.noData"));
return tip.toString();
}
for (int b = 0; b < data.getBranchCount(); b++) {
FlightEvent abortEvent = data.getBranch(b).getFirstEvent(FlightEvent.Type.SIM_ABORT);
if (abortEvent != null) {

View File

@ -118,19 +118,30 @@ public class SimulationConfigDialog extends JDialog {
}
//// Plot data
boolean hasData = simulationList[0].hasSimulationData();
if (hasData) {
this.plotTab = new SimulationPlotPanel(simulationList[0]);
} else {
this.plotTab = null;
}
tabbedPane.addTab(trans.get("SimulationConfigDialog.tab.Plotdata"), plotTab);
if (isMultiCompEdit()) {
if (isMultiCompEdit() || !hasData) {
tabbedPane.setEnabledAt(PLOT_IDX, false);
tabbedPane.setToolTipTextAt(PLOT_IDX, trans.get("SimulationConfigDialog.tab.plotDis.ttip"));
String ttip = hasData ? trans.get("SimulationConfigDialog.tab.plotDis.ttip") : trans.get("SimulationConfigDialog.tab.plotNoData.ttip");
tabbedPane.setToolTipTextAt(PLOT_IDX, ttip);
}
//// Export data
if (hasData) {
this.exportTab = new SimulationExportPanel(simulationList[0]);
} else {
this.exportTab = null;
}
tabbedPane.addTab(trans.get("SimulationConfigDialog.tab.Exportdata"), exportTab);
if (isMultiCompEdit()) {
if (isMultiCompEdit() || !hasData) {
tabbedPane.setEnabledAt(EXPORT_IDX, false);
tabbedPane.setToolTipTextAt(EXPORT_IDX, trans.get("SimulationConfigDialog.tab.expDis.ttip"));
String ttip = hasData ? trans.get("SimulationConfigDialog.tab.expDis.ttip") : trans.get("SimulationConfigDialog.tab.expNoData.ttip");
tabbedPane.setToolTipTextAt(EXPORT_IDX, ttip);
}
contentPanel.add(tabbedPane, "grow, wrap");
@ -354,6 +365,10 @@ public class SimulationConfigDialog extends JDialog {
int tabIdx = tabbedPane.getSelectedIndex();
if (tabIdx == PLOT_IDX) {
if (plotTab == null) {
closeDialog();
return;
}
JDialog plot = plotTab.doPlot(SimulationConfigDialog.this.parentWindow);
if (plot != null) {
plot.setVisible(true);
@ -361,7 +376,7 @@ public class SimulationConfigDialog extends JDialog {
closeDialog();
return;
} else if (tabIdx == EXPORT_IDX) {
if (exportTab.doExport()) {
if (exportTab == null || exportTab.doExport()) {
closeDialog();
}
return;

View File

@ -37,9 +37,9 @@ public class SimulationWarningsPanel extends JPanel {
super(new MigLayout("fill"));
WarningSet warnings = simulation.getSimulatedWarnings();
List<Warning> criticalWarnings = warnings.getCriticalWarnings();
List<Warning> normalWarnings = warnings.getNormalWarnings();
List<Warning> informativeWarnings = warnings.getInformativeWarnings();
List<Warning> criticalWarnings = warnings == null ? null : warnings.getCriticalWarnings();
List<Warning> normalWarnings = warnings == null ? null : warnings.getNormalWarnings();
List<Warning> informativeWarnings = warnings == null ? null : warnings.getInformativeWarnings();
// Critical warnings
JPanel criticalPanel = createWarningsPanel(criticalWarnings, Icons.WARNING_HIGH, trans.get("SimulationWarningsPanel.lbl.CriticalWarnings"), darkErrorColor);
@ -74,11 +74,12 @@ public class SimulationWarningsPanel extends JPanel {
// Title
float size = 1.1f;
StyledLabel title = new StyledLabel(warnings.size() + " " + titleText, size, StyledLabel.Style.BOLD);
int nrOfWarnings = warnings == null ? 0 : warnings.size();
StyledLabel title = new StyledLabel(nrOfWarnings + " " + titleText, size, StyledLabel.Style.BOLD);
title.setFontColor(textColor);
panel.add(title, "wrap, spanx");
if (warnings.isEmpty()) {
if (nrOfWarnings == 0) {
return panel;
}