J21 Updates, depreciation, and some ATB Code path removals.#8898
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the codebase for Java 21 usage and continues the ongoing deprecation/cleanup work, including removing legacy/unused AtB-facing UI/test paths and replacing older utility APIs with standard Java 21 or upstream MegaMek equivalents.
Changes:
- Remove legacy/disabled AtB-related UI flows and deprecated dialogs/tests.
- Replace
JScrollPaneWithSpeedusages withFastJScrollPaneacross many GUI panels/tabs. - Apply Java 21 refactors/cleanup (e.g.,
Math.clamp,Stream.toList(), parameterized logging, switch patterns) and mark additional APIs as@Deprecated(forRemoval=true).
Reviewed changes
Copilot reviewed 72 out of 72 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| MekHQ/unittests/mekhq/gui/enums/PersonnelTabViewTest.java | Removes deprecated test method. |
| MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/UnableToAffordJumpNagLogicTest.java | Deletes disabled/deprecated test. |
| MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/NoCommanderNagLogicTest.java | Deletes deprecated test. |
| MekHQ/unittests/mekhq/campaign/universe/TestSystems.java | Removes helper mutator method. |
| MekHQ/unittests/mekhq/campaign/unit/cleanup/MovedEquipmentStepTest.java | Simplifies Mockito answers/imports. |
| MekHQ/unittests/mekhq/campaign/unit/cleanup/MovedAmmoBinTest.java | Simplifies Mockito answers. |
| MekHQ/unittests/mekhq/campaign/unit/UnitPersonTest.java | Javadoc formatting/import cleanup. |
| MekHQ/unittests/mekhq/campaign/unit/UnitIOTest.java | Import/javadoc formatting and minor signature tweak. |
| MekHQ/unittests/mekhq/campaign/personnel/medical/advancedMedical/InjuryTypesTest.java | Uses method reference for assertDoesNotThrow. |
| MekHQ/unittests/mekhq/campaign/personnel/familyTree/FormerSpouseTest.java | Removes redundant self-equality assertion. |
| MekHQ/unittests/mekhq/campaign/personnel/InjuryTypeTest.java | Improves assertions and formatting (assertNull, lambda simplification). |
| MekHQ/unittests/mekhq/campaign/mission/MHQMoraleTest.java | Removes unused imports. |
| MekHQ/unittests/mekhq/campaign/market/TestPartsStore.java | Formatting + removes heavy “reallyStock” helper. |
| MekHQ/unittests/mekhq/campaign/market/ContractMarketAtBGenerationTests.java | Deletes large disabled/deprecated AtB generation test suite. |
| MekHQ/unittests/mekhq/campaign/camOpsReputation/FieldManualMercRevDragoonsRatingTest.java | Deletes disabled/deprecated test. |
| MekHQ/unittests/mekhq/campaign/WarehouseTest.java | Removes stray statement. |
| MekHQ/unittests/mekhq/campaign/CampaignTest.java | Assertion/javadoc formatting improvements in temp-crew tests. |
| MekHQ/unittests/asserts/BigDecimalAssert.java | Deletes custom assertion helper. |
| MekHQ/src/mekhq/utilities/spaUtilities/SpaUtilities.java | Deprecates isSpaCategory. |
| MekHQ/src/mekhq/utilities/ValidationResult.java | Deprecates getPlanetsValidated. |
| MekHQ/src/mekhq/utilities/ReportingUtilities.java | Deprecates surroundIf. |
| MekHQ/src/mekhq/service/mrms/MRMSService.java | Adds/removes deprecations on MRMS action/status accessors. |
| MekHQ/src/mekhq/service/mrms/MRMSOption.java | Uses parameterized logging for invalid type IDs. |
| MekHQ/src/mekhq/service/PartsAcquisitionService.java | Deprecates various static setters. |
| MekHQ/src/mekhq/module/atb/PersonnelMarketAtB.java | Deprecates legacy AtB personnel market implementation. |
| MekHQ/src/mekhq/module/atb/AtBEventProcessor.java | Deprecates record + avoids regex replace where not needed. |
| MekHQ/src/mekhq/module/AbstractServiceManager.java | Deprecates getAllServices() + uses Stream.toList(). |
| MekHQ/src/mekhq/gui/view/PersonViewPanel.java | Replaces MathUtility.clamp with Math.clamp. |
| MekHQ/src/mekhq/gui/view/PaperDoll.java | Deprecates legacy setters/getters. |
| MekHQ/src/mekhq/gui/view/MissionViewPanel.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/view/ForceViewPanel.java | Removes AtB tooltip wiring. |
| MekHQ/src/mekhq/gui/utilities/StaticChecks.java | Deprecates several “areAll…” helpers. |
| MekHQ/src/mekhq/gui/utilities/MultiLineTooltip.java | Javadoc formatting cleanup. |
| MekHQ/src/mekhq/gui/utilities/MarkdownEditorPanel.java | Swaps to FastJScrollPane and refactors header insertion. |
| MekHQ/src/mekhq/gui/utilities/JSuggestField.java | Swaps to FastJScrollPane + deprecates legacy API surface. |
| MekHQ/src/mekhq/gui/stratCon/TrackForceAssignmentUI.java | Swaps to FastJScrollPane + formats deploy call. |
| MekHQ/src/mekhq/gui/panes/UnitMarketPane.java | Swaps to FastJScrollPane + formatting. |
| MekHQ/src/mekhq/gui/panes/RankSystemsPane.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/panels/CampaignPresetPanel.java | Deprecates panel. |
| MekHQ/src/mekhq/gui/model/UnitTableModel.java | Minor formatting + uses StringBuilder.isEmpty(). |
| MekHQ/src/mekhq/gui/model/TaskTableModel.java | Deprecates getTasksAt. |
| MekHQ/src/mekhq/gui/model/PartsInUseTableModel.java | Deprecates row update and focus border accessors. |
| MekHQ/src/mekhq/gui/model/ObjectiveTableModel.java | Deprecates addObjective. |
| MekHQ/src/mekhq/gui/model/FilterableListModel.java | Deprecates no-arg constructor. |
| MekHQ/src/mekhq/gui/model/BotForceTableModel.java | Deprecates getAllBotForces. |
| MekHQ/src/mekhq/gui/menus/AssignPersonToUnitMenu.java | Switch pattern refactor for entity type checks. |
| MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java | Deprecates legacy column-type helpers + StringBuilder.isEmpty(). |
| MekHQ/src/mekhq/gui/enums/PersonnelTabView.java | Deprecates isMedicalSkills. |
| MekHQ/src/mekhq/gui/enums/PersonnelFilter.java | Deprecates isCampFollower. |
| MekHQ/src/mekhq/gui/dialog/nagDialogs/UnableToAffordJumpNagDialog.java | Deletes nag dialog implementation. |
| MekHQ/src/mekhq/gui/dialog/nagDialogs/NoCommanderNagDialog.java | Deletes deprecated nag dialog implementation. |
| MekHQ/src/mekhq/gui/WarehouseTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/TOETab.java | Swaps to FastJScrollPane + stream formatting. |
| MekHQ/src/mekhq/gui/StratConTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/StratConPanel.java | Deprecates isCommitForces. |
| MekHQ/src/mekhq/gui/RepairTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/PlanetarySystemMapPanel.java | Deprecates removeActionListener. |
| MekHQ/src/mekhq/gui/PersonnelTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/MekLabTab.java | Swaps to FastJScrollPane for tab contents. |
| MekHQ/src/mekhq/gui/MapTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/InterstellarMapPanel.java | Uses Math.clamp + deprecates removeActionListener. |
| MekHQ/src/mekhq/gui/InfirmaryTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/HangarTab.java | Swaps to FastJScrollPane. |
| MekHQ/src/mekhq/gui/FinancesTab.java | Swaps to FastJScrollPane + refactors asset-name padding. |
| MekHQ/src/mekhq/gui/FileDialogs.java | Deprecates openPlanetsTsv. |
| MekHQ/src/mekhq/gui/CommandCenterTab.java | Swaps to FastJScrollPane + lambda simplification. |
| MekHQ/src/mekhq/gui/CampaignGUI.java | Removes contract-market menu + removes AtB toggle/init path + simplifies new contract dialog selection. |
| MekHQ/src/mekhq/gui/BriefingTab.java | Removes AtB-specific UI plumbing and AtB-only scenario view handling. |
| MekHQ/src/mekhq/Utilities.java | Switch pattern refactor + Math.clamp usage + deprecates file/XML helpers. |
| MekHQ/src/mekhq/MekHQ.java | Deprecates setCampaignGUI + removes AtB-specific game thread selection. |
| MekHQ/src/mekhq/IconPackage.java | Deprecates auto-resolve image accessor. |
| MekHQ/src/mekhq/AtBGameThread.java | Deprecates class and removes unused exception from signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| JPanel pnlTutorial = new TutorialHyperlinkPanel("missionTab"); | ||
|
|
||
| setLayout(new BorderLayout()); |
There was a problem hiding this comment.
initTab() builds panScenario (and likely panMission earlier) but the tab never adds the main content panel to the layout—only the tutorial panel is added. This will render the Briefing/Mission UI blank. Add an appropriate container (e.g., a split pane or panel) to BorderLayout.CENTER that includes the mission + scenario components.
| JPanel pnlTutorial = new TutorialHyperlinkPanel("missionTab"); | |
| setLayout(new BorderLayout()); | |
| JPanel pnlTutorial = new TutorialHyperlinkPanel("missionTab"); | |
| JPanel pnlMainContent = new JPanel(new GridLayout(2, 1)); | |
| pnlMainContent.add(panMission); | |
| pnlMainContent.add(panScenario); | |
| setLayout(new BorderLayout()); | |
| add(pnlMainContent, BorderLayout.CENTER); |
| private void insertHeader(int level) { | ||
| StringBuilder toInsert = new StringBuilder(); | ||
| toInsert.append("#".repeat(Math.max(0, level))); | ||
| toInsert.repeat("#", Math.max(0, level)); | ||
| toInsert.append(" "); |
There was a problem hiding this comment.
StringBuilder does not provide a repeat(String, int) API in the Java 21 standard library. These calls will not compile (and if you intended repeat(int) semantics, repeating an empty builder would be a no-op). Use append("#".repeat(...))/append(".".repeat(...)) or a small loop instead.
| } else { | ||
| int numPeriods = 18 - assetName.length(); | ||
| assetName.append(".".repeat(Math.max(0, numPeriods))); | ||
| assetName.repeat(".", Math.max(0, numPeriods)); |
There was a problem hiding this comment.
StringBuilder does not provide a repeat(String, int) API in the Java 21 standard library, so this will not compile as written. Prefer assetName.append(".".repeat(...)) or a small loop to add the padding characters.
| assetName.repeat(".", Math.max(0, numPeriods)); | |
| assetName.append(".".repeat(Math.max(0, numPeriods))); |
| } else if (entity1 instanceof Tank) { | ||
| if (entity1.getMovementMode() != entity2.getMovementMode()) { | ||
| return false; | ||
| case Tank ignored -> { |
| valid = false; | ||
| } | ||
| final boolean valid = switch (entity) { | ||
| case Mek ignored -> areAllBattleMekPilots; |
| } | ||
| final boolean valid = switch (entity) { | ||
| case Mek ignored -> areAllBattleMekPilots; | ||
| case ProtoMek ignored -> areAllProtoMekPilots; |
| final boolean valid = switch (entity) { | ||
| case Mek ignored -> areAllBattleMekPilots; | ||
| case ProtoMek ignored -> areAllProtoMekPilots; | ||
| case ConvFighter ignored -> areAllConventionalAircraftPilots; |
| case Mek ignored -> areAllBattleMekPilots; | ||
| case ProtoMek ignored -> areAllProtoMekPilots; | ||
| case ConvFighter ignored -> areAllConventionalAircraftPilots; | ||
| case Aero ignored -> areAllAerospacePilots; |
| case ProtoMek ignored -> areAllProtoMekPilots; | ||
| case ConvFighter ignored -> areAllConventionalAircraftPilots; | ||
| case Aero ignored -> areAllAerospacePilots; | ||
| case VTOL ignored -> areAllVTOLCrew; |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8898 +/- ##
============================================
+ Coverage 13.79% 13.81% +0.02%
+ Complexity 8179 8177 -2
============================================
Files 1285 1283 -2
Lines 167606 167433 -173
Branches 25279 25237 -42
============================================
+ Hits 23126 23136 +10
+ Misses 142152 141967 -185
- Partials 2328 2330 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.