Skip to content

Commit 1ba8287

Browse files
committed
fixed: 处理兼容性问题
1 parent e4306e7 commit 1ba8287

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = "dev.huyaro.gen"
12-
version = "0.1.4"
12+
version = "0.1.5"
1313

1414

1515
repositories {

src/main/kotlin/dev/huyaro/gen/ui/GeneratorDialog.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.huyaro.gen.ui
22

33
import com.intellij.database.psi.DbTable
4-
import com.intellij.database.util.or
54
import com.intellij.database.view.actions.font
65
import com.intellij.icons.AllIcons
76
import 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
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</ul>
2323
]]></description>
2424
<change-notes><![CDATA[
25-
<h4>0.1.4</h4>
25+
<h4>0.1.5</h4>
2626
<ul>
2727
<li>Support to automatically get excluded columns from superclass</li>
2828
</ul>

0 commit comments

Comments
 (0)