mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 15:57:18 -04:00
fix: not closing launching progress pane when java downloading was cancelled. Closes #1134.
This commit is contained in:
parent
8d559dba02
commit
f893eeea1f
@ -65,6 +65,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
|
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
|
||||||
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
||||||
|
import static org.jackhuang.hmcl.util.Lang.resolveException;
|
||||||
import static org.jackhuang.hmcl.util.Logging.LOG;
|
import static org.jackhuang.hmcl.util.Logging.LOG;
|
||||||
import static org.jackhuang.hmcl.util.Pair.pair;
|
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
@ -415,6 +416,7 @@ public final class LauncherHelper {
|
|||||||
})
|
})
|
||||||
.exceptionally(throwable -> {
|
.exceptionally(throwable -> {
|
||||||
LOG.log(Level.WARNING, "Failed to download java", throwable);
|
LOG.log(Level.WARNING, "Failed to download java", throwable);
|
||||||
|
breakAction.run();
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
return Task.fromCompletableFuture(future);
|
return Task.fromCompletableFuture(future);
|
||||||
@ -528,7 +530,10 @@ public final class LauncherHelper {
|
|||||||
CompletableFuture<JavaVersion> future = new CompletableFuture<>();
|
CompletableFuture<JavaVersion> future = new CompletableFuture<>();
|
||||||
|
|
||||||
JFXHyperlink link = new JFXHyperlink(i18n("download.external_link"));
|
JFXHyperlink link = new JFXHyperlink(i18n("download.external_link"));
|
||||||
link.setOnAction(e -> FXUtils.openLink("https://adoptium.net/?variant=openjdk17"));
|
link.setOnAction(e -> {
|
||||||
|
FXUtils.openLink("https://docs.microsoft.com/zh-cn/java/openjdk/download");
|
||||||
|
future.completeExceptionally(new CancellationException());
|
||||||
|
});
|
||||||
|
|
||||||
Controllers.dialog(new MessageDialogPane.Builder(
|
Controllers.dialog(new MessageDialogPane.Builder(
|
||||||
i18n("launch.advice.require_newer_java_version",
|
i18n("launch.advice.require_newer_java_version",
|
||||||
@ -543,8 +548,11 @@ public final class LauncherHelper {
|
|||||||
future.complete(downloadedJava);
|
future.complete(downloadedJava);
|
||||||
})
|
})
|
||||||
.exceptionally(throwable -> {
|
.exceptionally(throwable -> {
|
||||||
|
Throwable resolvedException = resolveException(throwable);
|
||||||
LOG.log(Level.WARNING, "Failed to download java", throwable);
|
LOG.log(Level.WARNING, "Failed to download java", throwable);
|
||||||
Controllers.dialog(DownloadProviders.localizeErrorMessage(throwable), i18n("download.failed"));
|
if (!(resolvedException instanceof CancellationException)) {
|
||||||
|
Controllers.dialog(DownloadProviders.localizeErrorMessage(resolvedException), i18n("install.failed"));
|
||||||
|
}
|
||||||
future.completeExceptionally(new CancellationException());
|
future.completeExceptionally(new CancellationException());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,7 @@ import java.nio.file.AccessDeniedException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -160,6 +161,8 @@ public final class DownloadProviders {
|
|||||||
}
|
}
|
||||||
} else if (exception instanceof ArtifactMalformedException) {
|
} else if (exception instanceof ArtifactMalformedException) {
|
||||||
return i18n("exception.artifact_malformed");
|
return i18n("exception.artifact_malformed");
|
||||||
|
} else if (exception instanceof CancellationException) {
|
||||||
|
return i18n("message.cancelled");
|
||||||
}
|
}
|
||||||
return StringUtils.getStackTrace(exception);
|
return StringUtils.getStackTrace(exception);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user