Pass Selected Player through to add unit and random force dialogs #5727
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update makes the selected Player update the following dialogs (either for the first time, or now correctly):
The above dialogs will now correctly reflect which Player has been selected when they open, and new units will be added to the appropriate players' lists. Filenames likewise will correctly reflect the current player for loading and saving (previously they would stick with whatever player was selected when the dialog was first opened).
It also adds a utility
GetFocusListenerclass that can be added as an AncestorListener to components: when that component or its ancestor (containing component, such as JPanel or JDialog) is set to visible, it will be notified and made the focus. This is slightly cleaner than the current ".grabFocus()" approach we use in a lot of places.Note: Unfortunately the wonkiness of Java JDialog modals means that it is not possible to focus on more than one component prior to turning the Dialog visible, and this new functionality requires taking focus initially to ensure that the Player combo box gets updated appropriately, so I have removed the auto-focus on the text filter box from the MegaMek unit picker only (this will not affect other derived dialogs or projects).
Testing: