Merge pull request #1059 from SiboVG/issue-1058
[fixes #1058] Launch info dialog for no simulations GeneralOptimizer
This commit is contained in:
commit
459d4ab4ae
@ -1877,7 +1877,8 @@ optimization.modifier.motormount.delay.desc = Optimize the motor ignition delay.
|
||||
|
||||
|
||||
! General rocket design optimization dialog
|
||||
|
||||
GeneralOptimizationDialog.info.noSims.title = No simulations
|
||||
GeneralOptimizationDialog.info.noSims.message = No simulations created yet to optimize
|
||||
GeneralOptimizationDialog.title = Rocket optimization
|
||||
GeneralOptimizationDialog.goal.maximize = Maximize value
|
||||
GeneralOptimizationDialog.goal.minimize = Minimize value
|
||||
|
@ -190,12 +190,13 @@ public class GeneralOptimizationDialog extends JDialog {
|
||||
* @param document the document
|
||||
* @param parent the parent window
|
||||
*/
|
||||
public GeneralOptimizationDialog(OpenRocketDocument document, Window parent) {
|
||||
public GeneralOptimizationDialog(OpenRocketDocument document, Window parent) throws InterruptedException {
|
||||
super(parent, trans.get("title"));
|
||||
|
||||
this.baseDocument = document;
|
||||
this.documentCopy = document.copy();
|
||||
|
||||
|
||||
checkExistingSimulations();
|
||||
loadOptimizationParameters();
|
||||
loadSimulationModifiers();
|
||||
|
||||
@ -904,6 +905,19 @@ public class GeneralOptimizationDialog extends JDialog {
|
||||
populateParameters();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether there are simulations present in the document. If not, a pop-up information
|
||||
* dialog launches stating that the optimizer cannot be launched.
|
||||
* @throws InterruptedException when no simulations present
|
||||
*/
|
||||
private void checkExistingSimulations() throws InterruptedException {
|
||||
if (documentCopy.getSimulations().size() == 0) {
|
||||
JOptionPane.showMessageDialog(null, trans.get("GeneralOptimizationDialog.info.noSims.message"),
|
||||
trans.get("GeneralOptimizationDialog.info.noSims.title"), JOptionPane.INFORMATION_MESSAGE);
|
||||
throw new InterruptedException("No simulations to optimize");
|
||||
}
|
||||
}
|
||||
|
||||
private void populateSimulations() {
|
||||
String current = null;
|
||||
|
@ -716,7 +716,11 @@ public class BasicFrame extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "Rocket optimization selected");
|
||||
new GeneralOptimizationDialog(document, BasicFrame.this).setVisible(true);
|
||||
try {
|
||||
new GeneralOptimizationDialog(document, BasicFrame.this).setVisible(true);
|
||||
} catch (InterruptedException ex) {
|
||||
log.warn(ex.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user