apply steps at the end, add ability to cancel wizard

pull/53/head
Zlatin Balevsky 2020-05-29 01:15:56 +01:00
parent c041f6baaa
commit cb54b30967
No known key found for this signature in database
GPG Key ID: A72832072D525E41
4 changed files with 33 additions and 4 deletions

View File

@ -36,7 +36,17 @@ class WizardController {
@ControllerAction @ControllerAction
void finish() { 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() { private void recalcButtons() {

View File

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

View File

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

View File

@ -35,9 +35,15 @@ class WizardView {
} }
} }
panel (constraints : BorderLayout.SOUTH) { panel (constraints : BorderLayout.SOUTH) {
button(text : "Previous", enabled : bind {model.previousButtonEnabled}, previousAction) gridLayout(rows:1, cols:2)
button(text : "Next", enabled : bind {model.nextButtonEnabled}, nextAction) panel {
button(text : "Finish", enabled : bind {model.finishButtonEnabled}, finishAction) 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() dialog.show()
} }
void hide() {
dialog.setVisible(false)
mvcGroup.destroy()
}
} }