mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 15:26:27 -04:00
Fix #547
This commit is contained in:
parent
9ed14b227b
commit
7e8cc5fe6c
@ -85,4 +85,11 @@ public final class UpdateInstallerWizardProvider implements WizardProvider {
|
||||
public boolean cancel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancelIfCannotGoBack() {
|
||||
// VersionsPage will call wizardController.onPrev(cleanUp = true) when list is empty.
|
||||
// So we cancel this wizard when VersionPage calls the method.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,12 @@ public class WizardController implements Navigation {
|
||||
@Override
|
||||
public void onPrev(boolean cleanUp) {
|
||||
if (!canPrev()) {
|
||||
throw new IllegalStateException("Cannot go backward since this is the back page. Pages: " + pages);
|
||||
if (provider.cancelIfCannotGoBack()) {
|
||||
onCancel();
|
||||
return;
|
||||
} else {
|
||||
throw new IllegalStateException("Cannot go backward since this is the back page. Pages: " + pages);
|
||||
}
|
||||
}
|
||||
|
||||
Node page = pages.pop();
|
||||
|
@ -26,6 +26,9 @@ public interface WizardProvider {
|
||||
Object finish(Map<String, Object> settings);
|
||||
Node createPage(WizardController controller, int step, Map<String, Object> settings);
|
||||
boolean cancel();
|
||||
default boolean cancelIfCannotGoBack() {
|
||||
return false;
|
||||
}
|
||||
|
||||
interface FailureCallback {
|
||||
void onFail(Map<String, Object> settings, Exception exception, Runnable next);
|
||||
|
Loading…
x
Reference in New Issue
Block a user