前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >javafx框架tornadofx批量生成桌面版CRUB程序

javafx框架tornadofx批量生成桌面版CRUB程序

原创
作者头像
用户6167008
修改2019-09-03 18:35:52
7520
修改2019-09-03 18:35:52
举报
文章被收录于专栏:javafx框架tornadofx

演示地址

javafx框架tornadofx批量生成桌面版CRUB程序,采用tornadofx制作界面,jfinal active record操作数据库,jfinal enjoy模板引擎生成相关代码,只演示了简单桌面版CRUB程序,更完善的程序需要对模板代码进行设计。

代码语言:txt
复制
import java.sql.Connection
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.transactions.TransactionManager
import tornadofx.*

class CRUD_GUI : App(MainTap::class){
var n=0
override fun init() {
if(n==0){
run{
newDb()
}
n+=1
}
        super.init()
    }
}

class MainTap() : View("CRUD_GUI") {

    override val root = tabpane {

        #for(v:views)
        tab("#(v)") {
            isClosable=false
            add(#(v)Editor())
        }
        #end
    }
}

// create db and table
fun newDb() {
    // "connect" a database file called data.sqlite in the current working directory
    // (creates the file if id does not exist)
    Database.connect("jdbc:sqlite:file:data.sqlite", driver = "org.sqlite.JDBC")
    // this isolation level is required for sqlite, may not be applicable to other DBMS
    TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE

    transaction {
    addLogger(StdOutSqlLogger)
    // create the table
	#for(c:claLowName)
    SchemaUtils.create(#(c ??)zz)
	#end

    // add some entries
    ###(claUpName ??).new {
    ###for(col : cols)
    ###if(for.first)
    ###continue
    ###end
    ###(col.attrName ??) ="#(col.attrName ??)+#(for.index)"
    ###end
    ###}
    }

    // new transaction to check the results
    transaction {
        #(claUpName ??).all().forEach { println(it) }
    }
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档