apply steps at the end, add ability to cancel wizard

This commit is contained in:
Zlatin Balevsky
2020-05-29 01:15:56 +01:00
parent c041f6baaa
commit cb54b30967
4 changed files with 33 additions and 4 deletions

View File

@ -36,7 +36,17 @@ class WizardController {
@ControllerAction
void finish() {
model.steps.each {
it.apply(model.muSettings, model.i2pProps)
}
model.finished['applied'] = true
view.hide()
}
@ControllerAction
void cancel() {
model.finished['applied'] = false
view.hide()
}
private void recalcButtons() {

View File

@ -64,8 +64,15 @@ class Ready extends AbstractLifecycleHandler {
params['embeddedRouterAvailable'] = embeddedRouterAvailable
params['muSettings'] = props
params['i2pProps'] = i2pProps
def finished = [:]
params['finished'] = finished
application.mvcGroupManager.createMVCGroup("wizard", params)
if (!finished['applied']) {
JOptionPane.showMessageDialog(parent, "MuWire will now exit")
System.exit(0)
}
// props.incompleteLocation = new File(home, "incompletes")

View File

@ -14,6 +14,7 @@ class WizardModel {
boolean embeddedRouterAvailable
MuWireSettings muSettings
Properties i2pProps
def finished
final List<WizardStep> steps = [new NicknameStep(),
new DirectoriesStep()]

View File

@ -35,9 +35,15 @@ class WizardView {
}
}
panel (constraints : BorderLayout.SOUTH) {
button(text : "Previous", enabled : bind {model.previousButtonEnabled}, previousAction)
button(text : "Next", enabled : bind {model.nextButtonEnabled}, nextAction)
button(text : "Finish", enabled : bind {model.finishButtonEnabled}, finishAction)
gridLayout(rows:1, cols:2)
panel {
button(text : "Cancel", cancelAction)
}
panel {
button(text : "Previous", enabled : bind {model.previousButtonEnabled}, previousAction)
button(text : "Next", enabled : bind {model.nextButtonEnabled}, nextAction)
button(text : "Finish", enabled : bind {model.finishButtonEnabled}, finishAction)
}
}
}
}
@ -60,4 +66,9 @@ class WizardView {
})
dialog.show()
}
void hide() {
dialog.setVisible(false)
mvcGroup.destroy()
}
}