mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 23:37:14 -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() {
|
public boolean cancel() {
|
||||||
return true;
|
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
|
@Override
|
||||||
public void onPrev(boolean cleanUp) {
|
public void onPrev(boolean cleanUp) {
|
||||||
if (!canPrev()) {
|
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();
|
Node page = pages.pop();
|
||||||
|
@ -26,6 +26,9 @@ public interface WizardProvider {
|
|||||||
Object finish(Map<String, Object> settings);
|
Object finish(Map<String, Object> settings);
|
||||||
Node createPage(WizardController controller, int step, Map<String, Object> settings);
|
Node createPage(WizardController controller, int step, Map<String, Object> settings);
|
||||||
boolean cancel();
|
boolean cancel();
|
||||||
|
default boolean cancelIfCannotGoBack() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
interface FailureCallback {
|
interface FailureCallback {
|
||||||
void onFail(Map<String, Object> settings, Exception exception, Runnable next);
|
void onFail(Map<String, Object> settings, Exception exception, Runnable next);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user