Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception guards for report search fields #4047

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions megamek/src/megamek/client/ui/swing/MiniReportDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,14 @@ private void updateEntityChoice() {
for (Iterator<Entity> ents = currentClient.getGame().getEntities(); ents.hasNext();) {
Entity entity = ents.next();
if (entity.getOwner().equals(currentClient.getLocalPlayer())) {
displayNane =addEntity(comboEntity, entity.getShortName());
displayNane = addEntity(comboEntity, entity.getShortName());
}
}
lastChoice = (lastChoice != null ? lastChoice : displayNane);
if (comboEntity.getItemCount() == 1) {
comboEntity.setEnabled(false);
}
comboEntity.setSelectedItem(lastChoice);
if (comboEntity.getSelectedIndex() < 0) {
if (comboEntity.getItemCount() <= 1) {
comboEntity.setEnabled(false);
} else if (comboEntity.getSelectedIndex() < 0) {
comboEntity.setSelectedIndex(0);
}
}
Expand All @@ -252,11 +251,10 @@ private void updateQuickChoice() {
for (String keyword : keywords) {
comboQuick.addItem(keyword);
}
if (comboQuick.getItemCount() == 1) {
comboQuick.setEnabled(false);
}
comboQuick.setSelectedItem(lastChoice);
if (comboQuick.getSelectedIndex() < 0) {
if (comboQuick.getItemCount() <= 1) {
comboQuick.setEnabled(false);
} else if (comboQuick.getSelectedIndex() < 0) {
comboQuick.setSelectedIndex(0);
}
}
Expand Down