[Feature] 让Java下载页面可以同时下载多个Java#5394
Conversation
|
cc @3gf8jv4dv |
|
我在 #2988 (review) 建议过搞一个复选框,但 Glavo 最后没做。不知道现在 Glavo 怎么想。 |
There was a problem hiding this comment.
Pull request overview
This PR updates the Mojang Java download dialog to support selecting and downloading multiple Java major versions in one operation.
Changes:
- Replace single-choice radio buttons with multi-select checkboxes and update dialog validation accordingly.
- Update accept handler to gather multiple selected versions and download them sequentially (including optional override flow).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else chain = chain.thenComposeAsync(Schedulers.javafx(), ignore -> task); | ||
| } | ||
|
|
||
| for (GameJavaVersion v : notInstalled) { | ||
| Task<?> task = downloadTask(v); | ||
| if (chain == null) chain = task; | ||
| else chain = chain.thenComposeAsync(Schedulers.javafx(), ignore -> task); |
There was a problem hiding this comment.
The download chain is built with thenComposeAsync(...), which stops executing subsequent tasks if any earlier download fails (because thenComposeAsync relies on dependents succeeding). With multi-select, a single failed Java download will prevent the remaining selected versions from downloading. Consider chaining with withComposeAsync(...) (doesn’t break the chain on dependent failure) or wrapping each per-version task so failures are handled and the chain continues, while still reporting errors to the user.
| else chain = chain.thenComposeAsync(Schedulers.javafx(), ignore -> task); | |
| } | |
| for (GameJavaVersion v : notInstalled) { | |
| Task<?> task = downloadTask(v); | |
| if (chain == null) chain = task; | |
| else chain = chain.thenComposeAsync(Schedulers.javafx(), ignore -> task); | |
| else chain = chain.withComposeAsync(Schedulers.javafx(), ignore -> task); | |
| } | |
| for (GameJavaVersion v : notInstalled) { | |
| Task<?> task = downloadTask(v); | |
| if (chain == null) chain = task; | |
| else chain = chain.withComposeAsync(Schedulers.javafx(), ignore -> task); |
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (exceptions.size() == 1) { | ||
| exceptionToDisplay = exceptions.get(0); | ||
| } else { | ||
| exceptionToDisplay = new IOException("Failed to download Java"); |
There was a problem hiding this comment.
The error message "Failed to download Java" is hardcoded in English, which is inconsistent with the internationalization (i18n) pattern used throughout the codebase. This message should use the i18n() function to support multiple languages, similar to how other error messages in this file use i18n("install.failed") on line 199. Consider using an i18n key like i18n("download.java.failed") or a similar localized message.
| exceptionToDisplay = new IOException("Failed to download Java"); | |
| exceptionToDisplay = new IOException(i18n("download.java.failed")); |
No description provided.