override fun actionPerformed()

in exposed-intellij/src/main/kotlin/com/jetbrains/exposed/intellij/actions/GenerateExposedCodeAction.kt [54:82]


    override fun actionPerformed(e: AnActionEvent) {
        val currentProject: Project = e.project ?: return

        // TODO replace
        // put the path to your actual build.gradle.kts file for this very exposed-intellij module,
        // or any other module here that has the Kotlin plugin applied.
        // this is Very Bad and will be fixed later
        val directory = File("")

        val connection: ProjectConnection = GradleConnector.newConnector()
                .forProjectDirectory(directory)
                .connect()

        if (ExposedCodeGeneratorConfigDialog(currentProject).showAndGet()) {
            connection.use {
                it.newBuild()
                        .forTasks("generateExposedCode")
                        .setEnvironmentVariables(mapOf(
                                "databaseDriver" to UISettings.databaseDriver,
                                "databaseName" to UISettings.databaseName,
                                "user" to UISettings.user,
                                "password" to UISettings.password,
                                "configFilename" to UISettings.configFilename
                        ))
                        .setStandardOutput(System.out)
                        .run()
            }
        }
    }