Skip to content

Commit

Permalink
Improve error handling of mod components info in details window
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Oct 26, 2023
1 parent 4f8e4fd commit 7dd26b6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/io/infinitytools/wit/gui/DetailsWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ private void onLanguageItemSelected(int newLanguageIndex) {
controller.groupComboBox.getSelectionModel().select(curGroupIndex);
} catch (IndexOutOfBoundsException e) {
Logger.error(e, "Language item selected at index {}", newLanguageIndex);
} catch (Exception e) {
Logger.error(e, "Mod components information unavailable");
setComponentsTreeDisabled();
return;
}

onComponentsTreeChanged(newLanguageIndex, controller.groupComboBox.getSelectionModel().getSelectedItem());
Expand Down Expand Up @@ -339,6 +343,21 @@ private void onHyperlinkClick(Hyperlink node) {
}
}

/**
* Disables the controls associated with the mod components tree.
*/
private void setComponentsTreeDisabled() {
controller.languageComboBox.setDisable(true);
controller.groupComboBox.setDisable(true);
final String msg = String.format("*** %s ***", R.get("ui.details.modInfo.message.unavailable"));
final ComponentInfo ci = new ComponentInfo(null, -1, -1, msg, false);
final TreeItem<ComponentBase> root = new TreeItem<>(ci);
controller.componentsTree.setRoot(root);

controller.componentsTree.setShowRoot(true);
controller.componentsTree.setFocusTraversable(false);
}

/**
* Stores the current window size, position and state.
*/
Expand Down

0 comments on commit 7dd26b6

Please sign in to comment.