Skip to content

Commit a29bed5

Browse files
authored
Merge pull request #115 from wuseal/3.0.1-update-ui
3.0.1 update ui
2 parents 5d415d1 + 846ec26 commit a29bed5

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/main/kotlin/extensions/wu/seal/PropertyPrefixSupport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object PropertyPrefixSupport : Extension() {
5757

5858

5959
override fun intercept(kotlinDataClass: KotlinDataClass): KotlinDataClass {
60-
return if (getConfig(prefixKeyEnable).toBoolean()) {
60+
return if (getConfig(prefixKeyEnable).toBoolean() && getConfig(prefixKey).isNotEmpty()) {
6161
val originProperties = kotlinDataClass.properties
6262
val newProperties = originProperties.map {
6363
val prefix = getConfig(prefixKey)

src/main/kotlin/extensions/wu/seal/PropertySuffixSupport.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ object PropertySuffixSupport : Extension() {
2222
addFocusListener(object : FocusListener {
2323
override fun focusGained(e: FocusEvent?) {
2424
}
25+
2526
override fun focusLost(e: FocusEvent?) {
2627
if (getConfig(suffixKeyEnable).toBoolean()) {
2728
setConfig(suffixKey, text)
@@ -46,17 +47,17 @@ object PropertySuffixSupport : Extension() {
4647
suffixJField()
4748
}
4849
}.apply {
49-
border = JBEmptyBorder(6,0,0,0)
50+
border = JBEmptyBorder(6, 0, 0, 0)
5051
}
5152
}
5253

5354

5455
override fun intercept(kotlinDataClass: KotlinDataClass): KotlinDataClass {
55-
return if (getConfig(suffixKeyEnable).toBoolean()) {
56+
return if (getConfig(suffixKeyEnable).toBoolean() && getConfig(suffixKey).isNotEmpty()) {
5657
val originProperties = kotlinDataClass.properties
5758
val newProperties = originProperties.map {
5859
val suffix = getConfig(suffixKey)
59-
val newName = it.name + suffix.first().toUpperCase() +suffix.substring(1)
60+
val newName = it.name + suffix.first().toUpperCase() + suffix.substring(1)
6061
it.copy(name = newName)
6162
}
6263
kotlinDataClass.copy(properties = newProperties)

src/main/kotlin/wu/seal/jsontokotlin/ui/ExtensionsTab.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class ExtensionsTab(layout: LayoutManager?, isDoubleBuffered: Boolean) : JPanel(
1818
ExtensionsCollector.extensions.forEach {
1919
row(separated = false) {
2020
it.createUI().apply {
21-
background = Color(225,225,225)
2221
preferredSize = JBDimension(500, 0)
2322
}.invoke()
2423
}

src/main/kotlin/wu/seal/jsontokotlin/ui/JsonInputDialog.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class JsonInputDialog(classsName: String, private val project: Project) : Messag
128128

129129
private fun createJsonContentEditor(): Editor {
130130
val editorFactory = EditorFactory.getInstance()
131-
val document = editorFactory.createDocument("").apply { }
131+
val document = editorFactory.createDocument("").apply { }
132132
document.setReadOnly(false)
133133
document.addDocumentListener(object : com.intellij.openapi.editor.event.DocumentListener {
134134
override fun documentChanged(event: com.intellij.openapi.editor.event.DocumentEvent?) = revalidate()
@@ -142,7 +142,9 @@ class JsonInputDialog(classsName: String, private val project: Project) : Messag
142142
component.preferredSize = Dimension(640, 480)
143143
component.autoscrolls = true
144144

145-
editor.contentComponent.componentPopupMenu = JPopupMenu().apply {
145+
val contentComponent = editor.contentComponent
146+
contentComponent.isFocusable = true
147+
contentComponent.componentPopupMenu = JPopupMenu().apply {
146148
add(createPasteFromClipboardMenuItem())
147149
add(createRetrieveContentFromHttpURLMenuItem())
148150
add(createLoadFromLocalFileMenu())
@@ -210,7 +212,7 @@ class JsonInputDialog(classsName: String, private val project: Project) : Messag
210212
override fun getInputString(): String = if (exitCode == 0) jsonContentEditor.document.text.trim() else ""
211213

212214
override fun getPreferredFocusedComponent(): JComponent? {
213-
return if (this.myField.text?.isEmpty() != false) {
215+
return if (this.myField.text.isNullOrEmpty()) {
214216
this.myField
215217
} else {
216218
jsonContentEditor.contentComponent

0 commit comments

Comments
 (0)