use of org.jboss.hal.client.patching.wizard.PatchState.UPLOAD in project console by hal.
the class ApplyPatchWizard method show.
public void show() {
Messages messages = resources.messages();
Wizard.Builder<PatchContext, PatchState> wb = new Wizard.Builder<>(messages.addResourceTitle(Names.PATCH), new PatchContext());
checkServersState(servers -> {
if (servers != null) {
wb.addStep(CHECK_SERVERS, new CheckRunningServersStep(resources, servers, statementContext.selectedHost()));
}
wb.addStep(UPLOAD, new UploadPatchStep(resources)).addStep(CONFIGURE, new ConfigurationStep(metadata, resources)).onBack((context, currentState) -> {
PatchState previous = null;
switch(currentState) {
case CHECK_SERVERS:
break;
case UPLOAD:
previous = CHECK_SERVERS;
break;
case CONFIGURE:
previous = UPLOAD;
break;
default:
break;
}
return previous;
}).onNext((context, currentState) -> {
PatchState next = null;
switch(currentState) {
case CHECK_SERVERS:
next = UPLOAD;
break;
case UPLOAD:
next = CONFIGURE;
break;
case CONFIGURE:
break;
default:
break;
}
return next;
}).stayOpenAfterFinish().onFinish((wzd, context) -> {
String name = context.file.name;
wzd.showProgress(resources.constants().patchInProgress(), messages.patchInProgress(name));
series(new FlowContext(progress.get()), new UploadPatch(statementContext, dispatcher, serverActions, context)).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext flowContext, Throwable error) {
wzd.showError(resources.constants().patchError(), messages.patchAddError(name, error.getMessage()), error.getMessage());
}
@Override
public void onSuccess(FlowContext context) {
callback.execute();
wzd.showSuccess(resources.constants().patchSuccessful(), messages.patchSucessfullyApplied(name), messages.view(Names.PATCH), cxt -> {
/* nothing to do, content is already selected */
});
}
});
});
Wizard<PatchContext, PatchState> wizard = wb.build();
wizard.show();
});
}
Aggregations