diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 7dafb51f5..0402303dc 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -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) diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index 218447971..8bf0faca8 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -790,6 +790,12 @@ public class SimulationPanel extends JPanel { if (includeSimName) { tip.append("").append(sim.getName()).append("
"); } + + 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("
"); @@ -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) { diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationConfigDialog.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationConfigDialog.java index 2fdcd8ea9..0c60befd5 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationConfigDialog.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationConfigDialog.java @@ -118,19 +118,30 @@ public class SimulationConfigDialog extends JDialog { } //// Plot data - this.plotTab = new SimulationPlotPanel(simulationList[0]); + 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 - this.exportTab = new SimulationExportPanel(simulationList[0]); + 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; diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationWarningsPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationWarningsPanel.java index ffcc75763..5084c6cb0 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationWarningsPanel.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationWarningsPanel.java @@ -37,9 +37,9 @@ public class SimulationWarningsPanel extends JPanel { super(new MigLayout("fill")); WarningSet warnings = simulation.getSimulatedWarnings(); - List criticalWarnings = warnings.getCriticalWarnings(); - List normalWarnings = warnings.getNormalWarnings(); - List informativeWarnings = warnings.getInformativeWarnings(); + List criticalWarnings = warnings == null ? null : warnings.getCriticalWarnings(); + List normalWarnings = warnings == null ? null : warnings.getNormalWarnings(); + List 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; }