<commit_before>package tornadofx.testapps

import javafx.geometry.Pos
import javafx.scene.control.Alert
import tornadofx.*
import tornadofx.tests.Customer
import tornadofx.tests.CustomerModel

class WizardTestApp : App(WizardTestView::class)
class WizardWorkspaceApp : WorkspaceApp(CustomerWizard::class)

class WizardTestView : View("Wizard Test") {
    override val root = stackpane {
        paddingAll = 100
        button("Create customer").action { find<CustomerWizard>().openModal() }
    }
}

class CustomerWizard : Wizard("Create customer", "Provide customer information") {
    val customer: CustomerModel by inject()

    override val canGoNext = currentPageComplete
    override val canFinish = allPagesComplete

    init {
        add(WizardStep1::class)
        add(WizardStep2::class)
        customer.item = Customer()
        graphic = resources.imageview("/tornadofx/tests/person.png")
        showSteps = true
        stepLinksCommits = true
        showHeader = true
        numberedSteps = true
        showStepsHeader = false
        enableStepLinks = true
    }

    override fun onSave() {
        alert(Alert.AlertType.INFORMATION, "Saving customer", "Collected data: ${customer.item}")
        super.onSave()
    }
}

class WizardStep1 : View("Customer Data") {
    val customer: CustomerModel by inject()
    val wizard: CustomerWizard by inject()

    override val complete = customer.valid(customer.name)

    override val root = form {
        fieldset(title) {
            field("Type") {
                combobox(customer.type, Customer.Type.values().toList())
            }
            field("Name") {
                textfield(customer.name) {
                    required()
                    // Make sure we get focus instead of the type combo
                    whenDocked { requestFocus() }
                }
            }
            hbox {
                alignment = Pos.BASELINE_RIGHT
                hyperlink("Skip") {
                    action {
                        wizard.currentPage = wizard.pages.last()
                    }
                }
            }
        }
    }
}

class WizardStep2 : View("Address") {
    val customer: CustomerModel by inject()
    override val complete = customer.valid(customer.zip, customer.city)

    override val root = form {
        fieldset(title) {
            field("Zip/City") {
                textfield(customer.zip) {
                    prefColumnCount = 7
                    required()
                }
                textfield(customer.city) {
                    required()
                }
            }
        }
    }
}<commit_msg>Improved the Wizard sample with a Workspace/CustomerList<commit_after>package tornadofx.testapps

import javafx.collections.FXCollections
import javafx.geometry.Pos
import tornadofx.*
import tornadofx.tests.Customer
import tornadofx.tests.CustomerModel

class WizardTestApp : WorkspaceApp(WizardCustomerList::class)

class CustomerWizard : Wizard("Create customer", "Provide customer information") {
    val customer: CustomerModel by inject()

    override val canGoNext = currentPageComplete
    override val canFinish = allPagesComplete

    init {
        add(WizardStep1::class)
        add(WizardStep2::class)
        customer.item = Customer()
        graphic = resources.imageview("/tornadofx/tests/person.png")
        showSteps = true
        stepLinksCommits = true
        showHeader = true
        numberedSteps = true
        showStepsHeader = false
        enableStepLinks = true
    }
}

class WizardStep1 : View("Customer Data") {
    val customer: CustomerModel by inject()
    val wizard: CustomerWizard by inject()

    override val complete = customer.valid(customer.name)

    override val root = form {
        fieldset(title) {
            field("Type") {
                combobox(customer.type, Customer.Type.values().toList())
            }
            field("Name") {
                textfield(customer.name) {
                    required()
                    // Make sure we get focus instead of the type combo
                    whenDocked { requestFocus() }
                }
            }
            hbox {
                alignment = Pos.BASELINE_RIGHT
                hyperlink("Skip") {
                    action {
                        wizard.currentPage = wizard.pages.last()
                    }
                }
            }
        }
    }
}

class WizardStep2 : View("Address") {
    val customer: CustomerModel by inject()
    override val complete = customer.valid(customer.zip, customer.city)

    override val root = form {
        fieldset(title) {
            field("Zip/City") {
                textfield(customer.zip) {
                    prefColumnCount = 7
                    required()
                }
                textfield(customer.city) {
                    required()
                }
            }
        }
    }
}

class WizardCustomerList : View() {
    val customers = FXCollections.observableArrayList<Customer>()

    override val root = tableview(customers) {
        column("Name", Customer::nameProperty)
        columnResizePolicy = SmartResize.POLICY
    }

    override fun onDock() {
        with(workspace) {
            button("_Add").action {
                find<CustomerWizard> {
                    onComplete { customers.add(customer.item) }
                    openModal()
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08864468864468865, 'fraction_numerical': 0.002380952380952381, 'mean_word_length': 1.7664640324214793, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4549909', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1365, 'n_words': 309}