11package dev.huyaro.gen.ui
22
33import com.intellij.database.psi.DbTable
4- import com.intellij.database.util.or
54import com.intellij.database.view.actions.font
65import com.intellij.icons.AllIcons
76import com.intellij.ide.util.PackageChooserDialog
@@ -43,14 +42,14 @@ import javax.swing.ListSelectionModel
4342 * @author huyaro
4443 * @date 2022-11-06
4544 */
46- class GeneratorDialog constructor (
45+ class GeneratorDialog (
4746 private val project : Project ? ,
4847 private val options : GeneratorOptions ,
4948 private val data : DataModel
5049) {
5150
5251 private lateinit var outDir: Cell <TextFieldWithBrowseButton >
53- private lateinit var textPkg : Cell <JBTextField >
52+ private lateinit var txtPkg : Cell <JBTextField >
5453 private lateinit var txtLog: Cell <JBTextArea >
5554 private lateinit var chkEntity: Cell <JBCheckBox >
5655 private lateinit var chkRepository: Cell <JBCheckBox >
@@ -98,10 +97,10 @@ class GeneratorDialog constructor(
9897 val selectedIndex = (it.source as ComboBox <* >).selectedIndex
9998 val curOpts = buildOptions(data.modules[selectedIndex])
10099 outDir.text(curOpts.outputDir)
101- textPkg .text(curOpts.rootPackage)
100+ txtPkg .text(curOpts.rootPackage)
102101 }
103102
104- textPkg = textField().label(" Package: " )
103+ txtPkg = textField().label(" Package: " )
105104 .bindText(options::rootPackage)
106105 .horizontalAlign(HorizontalAlign .FILL )
107106 .resizableColumn()
@@ -111,7 +110,7 @@ class GeneratorDialog constructor(
111110 chooserDialog.show()
112111 val psiPackage = chooserDialog.selectedPackage
113112 if (psiPackage != null ) {
114- textPkg .text(psiPackage.qualifiedName)
113+ txtPkg .text(psiPackage.qualifiedName)
115114 }
116115 }
117116 }.layout(RowLayout .PARENT_GRID )
@@ -131,21 +130,21 @@ class GeneratorDialog constructor(
131130 button(" Choose..." ) {
132131 val classChooserDialog = TreeJavaClassChooserDialog (" Choose SuperClass..." , project)
133132 classChooserDialog.show()
134- val selected = classChooserDialog.selected
135- if (selected != null ) {
136- selected .qualifiedName?.let { superCls.text(it) }
133+ val selectedCls = classChooserDialog.selected
134+ if (selectedCls != null ) {
135+ selectedCls .qualifiedName?.let { superCls.text(it) }
137136 txtExcludeCols.text(" " )
138137 options.excludeCols = " "
139138 // 反射获取superclass的已定义字段放入到excludeColumns中
140- if (selected .isInterface) {
141- val joinCols = selected .methods.joinToString(" , " ) { method ->
142- method.getAnnotation( " org.babyfish.jimmer.sql.Column " )?. let { an ->
143- an.findAttributeValue( " name " )
144- ?.text?.replace(" \" " , " " )
145- }. or ( toUnderline(method.name) )
139+ if (selectedCls .isInterface) {
140+ val joinColumns = selectedCls .methods.joinToString(" , " ) { method ->
141+ method.annotations
142+ .firstOrNull { it.qualifiedName == " org.babyfish.jimmer.sql.Column " }
143+ ?. let { it.findAttributeValue( " name " ) ?.text?.replace(" \" " , " " ) }
144+ ? : toUnderline(method.name)
146145 }
147- txtExcludeCols.text(joinCols )
148- options.excludeCols = joinCols
146+ txtExcludeCols.text(joinColumns )
147+ options.excludeCols = joinColumns
149148 }
150149 }
151150 }
0 commit comments