|
106 | 106 | * @author Illiani |
107 | 107 | * @since 0.50.06 |
108 | 108 | */ |
109 | | -public class PersonnelMarketDialog { |
| 109 | +public class PersonnelMarketDialog extends JDialog { |
110 | 110 | private static final String RESOURCE_BUNDLE = "mekhq.resources.PersonnelMarket"; |
111 | 111 |
|
112 | 112 | private static final int MAXIMUM_DAYS_IN_MONTH = 31; |
@@ -153,14 +153,11 @@ public PersonnelMarketDialog(NewPersonnelMarket market) { |
153 | 153 | * @since 0.50.06 |
154 | 154 | */ |
155 | 155 | public void initializeComponents() { |
156 | | - JDialog dialog = new JDialog(parent); |
157 | | - setDialogTitle(dialog); |
158 | | - dialog.addWindowListener(new WindowAdapter() { |
| 156 | + setDialogTitle(); |
| 157 | + addWindowListener(new WindowAdapter() { |
159 | 158 | @Override |
160 | 159 | public void windowClosing(WindowEvent e) { |
161 | | - market.setOfferingGoldenHello(goldenHelloCheckbox.isSelected()); |
162 | | - market.setCurrentApplicants(currentApplicants); |
163 | | - dialog.dispose(); |
| 160 | + closeAction(); |
164 | 161 | } |
165 | 162 | }); |
166 | 163 |
|
@@ -194,13 +191,28 @@ public void windowClosing(WindowEvent e) { |
194 | 191 |
|
195 | 192 | // This handles the initializing and display of the applicant panel |
196 | 193 | JSplitPane splitPane = initializePersonView(selectedPerson, mainPanel); |
197 | | - dialog.getContentPane().add(splitPane, BorderLayout.CENTER); |
| 194 | + getContentPane().add(splitPane, BorderLayout.CENTER); |
198 | 195 |
|
199 | 196 | // Finalize the dialog |
200 | | - dialog.setModal(true); |
201 | | - dialog.pack(); |
202 | | - dialog.setLocationRelativeTo(parent); |
203 | | - dialog.setVisible(true); |
| 197 | + setModal(true); |
| 198 | + pack(); |
| 199 | + setLocationRelativeTo(parent); |
| 200 | + setVisible(true); |
| 201 | + } |
| 202 | + |
| 203 | + /** |
| 204 | + * Applies the current UI settings to the {@link NewPersonnelMarket} object and closes the dialog. |
| 205 | + * |
| 206 | + * <p>This method updates the market's "golden hello" offering status and the list of current applicants based on |
| 207 | + * the user selections, then disposes of the dialog.</p> |
| 208 | + * |
| 209 | + * @author Illiani |
| 210 | + * @since 0.50.07 |
| 211 | + */ |
| 212 | + private void closeAction() { |
| 213 | + market.setOfferingGoldenHello(goldenHelloCheckbox.isSelected()); |
| 214 | + market.setCurrentApplicants(currentApplicants); |
| 215 | + dispose(); |
204 | 216 | } |
205 | 217 |
|
206 | 218 |
|
@@ -335,6 +347,10 @@ private JPanel initializeButtonPanel() { |
335 | 347 | boolean isGM = campaign.isGM(); |
336 | 348 |
|
337 | 349 | JPanel buttonPanel = new JPanel(); |
| 350 | + JButton closeButton = new JButton(getTextAt(RESOURCE_BUNDLE, "button.personnelMarket.close")); |
| 351 | + closeButton.addActionListener(e -> closeAction()); |
| 352 | + buttonPanel.add(closeButton); |
| 353 | + |
338 | 354 | JButton hireButton = new JButton(getTextAt(RESOURCE_BUNDLE, "button.personnelMarket.hire.normal")); |
339 | 355 | hireButton.addActionListener(e -> hireActionListener(isGM)); |
340 | 356 | buttonPanel.add(hireButton); |
@@ -480,25 +496,23 @@ private void hireActionListener(boolean isGM) { |
480 | 496 | /** |
481 | 497 | * Sets the dialog's title based on market and campaign context. |
482 | 498 | * |
483 | | - * @param dialog the dialog window to set the title on |
484 | | - * |
485 | 499 | * @author Illiani |
486 | 500 | * @since 0.50.06 |
487 | 501 | */ |
488 | | - private void setDialogTitle(JDialog dialog) { |
| 502 | + private void setDialogTitle() { |
489 | 503 | Faction campaignFaction = campaign.getFaction(); |
490 | 504 | if (campaignFaction.isClan()) { |
491 | | - dialog.setTitle(getTextAt(RESOURCE_BUNDLE, "title.personnelMarket.clan")); |
| 505 | + setTitle(getTextAt(RESOURCE_BUNDLE, "title.personnelMarket.clan")); |
492 | 506 | } else if (campaignFaction.isComStarOrWoB()) { |
493 | 507 | Person commander = campaign.getFlaggedCommander(); |
494 | 508 | String address = commander != null ? commander.getTitleAndSurname() : campaign.getCommanderAddress(false); |
495 | | - dialog.setTitle(getFormattedTextAt(RESOURCE_BUNDLE, |
| 509 | + setTitle(getFormattedTextAt(RESOURCE_BUNDLE, |
496 | 510 | "title.personnelMarket.comStarOrWoB", |
497 | 511 | address.toUpperCase())); |
498 | 512 | } else if (campaignFaction.isMercenary()) { |
499 | | - dialog.setTitle(getTextAt(RESOURCE_BUNDLE, "title.personnelMarket.mercenary")); |
| 513 | + setTitle(getTextAt(RESOURCE_BUNDLE, "title.personnelMarket.mercenary")); |
500 | 514 | } else if (campaignFaction.isMercenary()) { |
501 | | - dialog.setTitle(getTextAt(RESOURCE_BUNDLE, "title.personnelMarket.normal")); |
| 515 | + setTitle(getTextAt(RESOURCE_BUNDLE, "title.personnelMarket.normal")); |
502 | 516 | } |
503 | 517 | } |
504 | 518 |
|
|
0 commit comments