From cc1f3b20ba17b0a5665bfa8a9ad93f4f6ef75478 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 25 Sep 2024 11:33:31 -0500 Subject: [PATCH] Refactored GM Person Editing to Handle Multiple Selections. Revised the `PersonnelTableMouseAdapter` to iterate through all selected people rather than processing a single person. Updated the `edit.text` resource to `editPerson.text` for improved clarity and consistency. --- .../resources/mekhq/resources/GUI.properties | 2 +- .../adapter/PersonnelTableMouseAdapter.java | 73 +++++++------------ 2 files changed, 28 insertions(+), 47 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index 0ed21da257..4f5200a4a7 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -246,7 +246,7 @@ add1XP.text=Add 1 XP addXP.text=Add XP setXP.text=Set XP setEdge.text=Set Edge -edit.text=Edit +editPerson.text=Edit Person loadGMTools.text=Load GM Tools removeAllInjuries.text=Remove All Injuries removeInjury.format=Remove Injury: %s diff --git a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java index fbcee127ca..ca4e49d78b 100644 --- a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java @@ -18,27 +18,6 @@ */ package mekhq.gui.adapter; -import static megamek.client.ui.WrapLayout.wordWrap; -import static mekhq.campaign.personnel.education.Academy.skillParser; -import static mekhq.campaign.personnel.education.EducationController.getAcademy; -import static mekhq.campaign.personnel.education.EducationController.makeEnrollmentCheck; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; -import java.time.LocalDate; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JSplitPane; -import javax.swing.JTable; - import megamek.client.generator.RandomCallsignGenerator; import megamek.client.generator.RandomNameGenerator; import megamek.client.ui.dialogs.PortraitChooserDialog; @@ -62,26 +41,12 @@ import mekhq.campaign.finances.enums.TransactionType; import mekhq.campaign.log.LogEntry; import mekhq.campaign.log.PersonalLogger; -import mekhq.campaign.personnel.Award; -import mekhq.campaign.personnel.AwardsFactory; -import mekhq.campaign.personnel.Injury; -import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; -import mekhq.campaign.personnel.SpecialAbility; +import mekhq.campaign.personnel.*; import mekhq.campaign.personnel.autoAwards.AutoAwardsController; import mekhq.campaign.personnel.education.Academy; import mekhq.campaign.personnel.education.AcademyFactory; import mekhq.campaign.personnel.education.EducationController; -import mekhq.campaign.personnel.enums.ManeiDominiClass; -import mekhq.campaign.personnel.enums.ManeiDominiRank; -import mekhq.campaign.personnel.enums.MergingSurnameStyle; -import mekhq.campaign.personnel.enums.PersonnelRole; -import mekhq.campaign.personnel.enums.PersonnelStatus; -import mekhq.campaign.personnel.enums.PrisonerStatus; -import mekhq.campaign.personnel.enums.Profession; -import mekhq.campaign.personnel.enums.ROMDesignation; -import mekhq.campaign.personnel.enums.SplittingSurnameStyle; +import mekhq.campaign.personnel.enums.*; import mekhq.campaign.personnel.enums.education.EducationLevel; import mekhq.campaign.personnel.enums.education.EducationStage; import mekhq.campaign.personnel.generator.SingleSpecialAbilityGenerator; @@ -104,6 +69,21 @@ import mekhq.gui.utilities.MultiLineTooltip; import mekhq.gui.utilities.StaticChecks; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.time.LocalDate; +import java.util.List; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static megamek.client.ui.WrapLayout.wordWrap; +import static mekhq.campaign.personnel.education.Academy.skillParser; +import static mekhq.campaign.personnel.education.EducationController.getAcademy; +import static mekhq.campaign.personnel.education.EducationController.makeEnrollmentCheck; + public class PersonnelTableMouseAdapter extends JPopupMenuAdapter { private static final MMLogger logger = MMLogger.create(PersonnelTableMouseAdapter.class); @@ -845,10 +825,12 @@ public void actionPerformed(ActionEvent action) { break; } case CMD_EDIT: { - CustomizePersonDialog npd = new CustomizePersonDialog( - gui.getFrame(), true, selectedPerson, gui.getCampaign()); - npd.setVisible(true); - gui.getCampaign().personUpdated(selectedPerson); + for (Person person : people) { + CustomizePersonDialog npd = new CustomizePersonDialog(gui.getFrame(), true, + person, gui.getCampaign()); + npd.setVisible(true); + gui.getCampaign().personUpdated(selectedPerson); + } break; } case CMD_EDIT_HITS: { @@ -2916,13 +2898,12 @@ protected Optional createPopupMenu() { menuItem.addActionListener(this); menu.add(menuItem); } + menuItem = new JMenuItem(resources.getString("editPerson.text")); + menuItem.setActionCommand(CMD_EDIT); + menuItem.addActionListener(this); + menu.add(menuItem); if (oneSelected) { - menuItem = new JMenuItem(resources.getString("edit.text")); - menuItem.setActionCommand(CMD_EDIT); - menuItem.addActionListener(this); - menu.add(menuItem); - menuItem = new JMenuItem(resources.getString("loadGMTools.text")); menuItem.addActionListener(evt -> loadGMToolsForPerson(person)); menu.add(menuItem);