From 388676a882e6e5e32766db1b27b0702bc61c9af6 Mon Sep 17 00:00:00 2001 From: Weaver Date: Wed, 6 Nov 2024 22:50:26 -0800 Subject: [PATCH] Refit - Fix a couple of CodeQL issues --- MekHQ/src/mekhq/campaign/unit/Unit.java | 1 - .../src/mekhq/gui/dialog/ChooseRefitDialog.java | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/unit/Unit.java b/MekHQ/src/mekhq/campaign/unit/Unit.java index 97f16f9ccf..60a17d22bb 100644 --- a/MekHQ/src/mekhq/campaign/unit/Unit.java +++ b/MekHQ/src/mekhq/campaign/unit/Unit.java @@ -1263,7 +1263,6 @@ public Part getHeatSinkExample() { * not work on small craft and larger because they hide their heatsinks in an available * Spacecraft Cooling System Part. * - * @param entity Either the starting or the ending unit of the refit. * @return The number of heat sinks the unit mounts that are not tracked as parts. */ public Part getUntrackedHeatSinks () { diff --git a/MekHQ/src/mekhq/gui/dialog/ChooseRefitDialog.java b/MekHQ/src/mekhq/gui/dialog/ChooseRefitDialog.java index 7fd2a9b007..08b3fda82e 100644 --- a/MekHQ/src/mekhq/gui/dialog/ChooseRefitDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/ChooseRefitDialog.java @@ -561,8 +561,8 @@ public static int getActualQuantity(Part part) { } } - public int getToOrder(Part part) { - PartInventory inventory = campaign.getPartInventory(part); + public static int getToOrder(Part part) { + PartInventory inventory = part.getCampaign().getPartInventory(part); return Math.max(0, getActualQuantity(part) - inventory.getSupply() - inventory.getTransit() @@ -689,7 +689,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole // region Needed Model - public class RefitNeededListTableModel extends AbstractTableModel { + public static class RefitNeededListTableModel extends AbstractTableModel { public final static int COL_NEEDED = 0; public final static int COL_NAME = 1; public final static int COL_TECH_BASE = 2; @@ -752,7 +752,7 @@ public Object getValueAt(int row, int col) { } else { part = (Part) data.get(row); } - + Campaign campaign = part.getCampaign(); return switch(col) { case COL_NAME -> "" + part.getName() + ReportingUtilities.surroundIf(" (", part.getDetails(), ")") @@ -800,7 +800,7 @@ public String getTooltip(int row, int col) { part = data.get(row); } return switch (col) { - case COL_TARGET -> campaign.getTargetForAcquisition(part.getAcquisitionWork()).getDesc(); + case COL_TARGET -> part.getCampaign().getTargetForAcquisition(part.getAcquisitionWork()).getDesc(); default -> null; }; } @@ -826,7 +826,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole // region Returns Model - public class RefitReturnsListTableModel extends AbstractTableModel { + public static class RefitReturnsListTableModel extends AbstractTableModel { public final static int COL_RECEIVING = 0; public final static int COL_NAME = 1; public final static int COL_TECH_BASE = 2; @@ -885,7 +885,7 @@ public Object getValueAt(int row, int col) { + part.getName() + ReportingUtilities.surroundIf(" (", part.getDetails(), ")") + ""; case COL_TECH_BASE -> part.getTechBaseName(); - case COL_STOCK -> campaign.getPartInventory(part).getSupply(); + case COL_STOCK -> part.getCampaign().getPartInventory(part).getSupply(); case COL_RECEIVING -> getActualQuantity(part); case COL_VALUE -> part.getActualValue().multipliedBy(part.getQuantity()).toAmountAndSymbolString(); default -> "?"; @@ -935,7 +935,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole // region Steps Model - public class RefitStepsListTableModel extends AbstractTableModel { + public static class RefitStepsListTableModel extends AbstractTableModel { public final static int COL_OLD_NAME = 0; public final static int COL_OLD_LOC = 1; public final static int COL_OLD_QUANTITY = 2;