diff --git a/megameklab/src/megameklab/ui/MenuBar.java b/megameklab/src/megameklab/ui/MenuBar.java index 3190251be..1a615bb58 100644 --- a/megameklab/src/megameklab/ui/MenuBar.java +++ b/megameklab/src/megameklab/ui/MenuBar.java @@ -808,19 +808,22 @@ private void jMenuGetUnitValidationFromCache_actionPerformed() { UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(owner.getFrame()); unitLoadingDialog.setVisible(true); MegaMekLabUnitSelectorDialog viewer = new MegaMekLabUnitSelectorDialog(owner.getFrame(), unitLoadingDialog); - - Entity tempEntity = viewer.getChosenEntity(); - if (null == tempEntity) { - return; + Entity chosenEntity = viewer.getChosenEntity(); + if (chosenEntity != null) { + UnitUtil.showValidation(chosenEntity, owner.getFrame()); } - UnitUtil.showValidation(tempEntity, owner.getFrame()); + viewer.dispose(); } private void jMenuGetUnitBreakdownFromCache_actionPerformed() { UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(owner.getFrame()); unitLoadingDialog.setVisible(true); MegaMekLabUnitSelectorDialog viewer = new MegaMekLabUnitSelectorDialog(owner.getFrame(), unitLoadingDialog); - new CostDisplayDialog(owner.getFrame(), viewer.getChosenEntity()).setVisible(true); + Entity chosenEntity = viewer.getChosenEntity(); + if (chosenEntity != null) { + new CostDisplayDialog(owner.getFrame(), chosenEntity).setVisible(true); + } + viewer.dispose(); } private void jMenuGetUnitWeightBreakdownFromCache_actionPerformed() { @@ -828,11 +831,11 @@ private void jMenuGetUnitWeightBreakdownFromCache_actionPerformed() { unitLoadingDialog.setVisible(true); MegaMekLabUnitSelectorDialog viewer = new MegaMekLabUnitSelectorDialog(owner.getFrame(), unitLoadingDialog); - Entity tempEntity = viewer.getChosenEntity(); - if (null == tempEntity) { - return; + Entity chosenEntity = viewer.getChosenEntity(); + if (chosenEntity != null) { + UnitUtil.showUnitWeightBreakDown(chosenEntity, owner.getFrame()); } - UnitUtil.showUnitWeightBreakDown(tempEntity, owner.getFrame()); + viewer.dispose(); } private void jMenuGetUnitBVFromFile_actionPerformed() { diff --git a/megameklab/src/megameklab/ui/StartupGUI.java b/megameklab/src/megameklab/ui/StartupGUI.java index 0d3f5637b..5088a5ebf 100644 --- a/megameklab/src/megameklab/ui/StartupGUI.java +++ b/megameklab/src/megameklab/ui/StartupGUI.java @@ -23,6 +23,7 @@ import megamek.client.ui.swing.widget.SkinnedJPanel; import megamek.common.Configuration; import megamek.common.Entity; +import megamek.common.MechSummary; import megameklab.MMLConstants; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; import megameklab.ui.dialog.UiLoader; @@ -251,16 +252,20 @@ public static void selectAndLoadUnitFromCache(MenuBarOwner previousFrame) { unitLoadingDialog.setVisible(true); MegaMekLabUnitSelectorDialog viewer = new MegaMekLabUnitSelectorDialog(previousFrame.getFrame(), unitLoadingDialog); Entity newUnit = viewer.getChosenEntity(); + MechSummary mechSummary = viewer.getChosenMechSummary(); + viewer.dispose(); + if ((mechSummary == null) || (newUnit == null)) { + return; + } + String fileName = viewer.getChosenMechSummary().getSourceFile().toString(); if (fileName.toLowerCase().endsWith(".zip")) { fileName = viewer.getChosenMechSummary().getSourceFile().getAbsolutePath(); fileName = fileName.substring(0, fileName.lastIndexOf(File.separatorChar) + 1); fileName = fileName + MenuBar.createUnitFilename(newUnit); } - viewer.setVisible(false); - viewer.dispose(); - if ((newUnit == null) || !previousFrame.safetyPrompt()) { + if (!previousFrame.safetyPrompt()) { return; } diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index bb4bc7ed5..c80558e71 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -144,9 +144,8 @@ private void selectFromCache() { UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parent); unitLoadingDialog.setVisible(true); MegaMekLabUnitSelectorDialog viewer = new MegaMekLabUnitSelectorDialog(parent, unitLoadingDialog, this::entitySelected); - - viewer.setVisible(false); Entity entity = viewer.getChosenEntity(); + viewer.dispose(); if (entity != null) { units.add(entity);