diff --git a/src/main/kotlin/extensions/wu/seal/PropertyPrefixSupport.kt b/src/main/kotlin/extensions/wu/seal/PropertyPrefixSupport.kt index 1a41fa53..8286b81a 100644 --- a/src/main/kotlin/extensions/wu/seal/PropertyPrefixSupport.kt +++ b/src/main/kotlin/extensions/wu/seal/PropertyPrefixSupport.kt @@ -57,7 +57,7 @@ object PropertyPrefixSupport : Extension() { override fun intercept(kotlinDataClass: KotlinDataClass): KotlinDataClass { - return if (getConfig(prefixKeyEnable).toBoolean()) { + return if (getConfig(prefixKeyEnable).toBoolean() && getConfig(prefixKey).isNotEmpty()) { val originProperties = kotlinDataClass.properties val newProperties = originProperties.map { val prefix = getConfig(prefixKey) diff --git a/src/main/kotlin/extensions/wu/seal/PropertySuffixSupport.kt b/src/main/kotlin/extensions/wu/seal/PropertySuffixSupport.kt index a3b0c0f0..87c76d30 100644 --- a/src/main/kotlin/extensions/wu/seal/PropertySuffixSupport.kt +++ b/src/main/kotlin/extensions/wu/seal/PropertySuffixSupport.kt @@ -22,6 +22,7 @@ object PropertySuffixSupport : Extension() { addFocusListener(object : FocusListener { override fun focusGained(e: FocusEvent?) { } + override fun focusLost(e: FocusEvent?) { if (getConfig(suffixKeyEnable).toBoolean()) { setConfig(suffixKey, text) @@ -46,17 +47,17 @@ object PropertySuffixSupport : Extension() { suffixJField() } }.apply { - border = JBEmptyBorder(6,0,0,0) + border = JBEmptyBorder(6, 0, 0, 0) } } override fun intercept(kotlinDataClass: KotlinDataClass): KotlinDataClass { - return if (getConfig(suffixKeyEnable).toBoolean()) { + return if (getConfig(suffixKeyEnable).toBoolean() && getConfig(suffixKey).isNotEmpty()) { val originProperties = kotlinDataClass.properties val newProperties = originProperties.map { val suffix = getConfig(suffixKey) - val newName = it.name + suffix.first().toUpperCase() +suffix.substring(1) + val newName = it.name + suffix.first().toUpperCase() + suffix.substring(1) it.copy(name = newName) } kotlinDataClass.copy(properties = newProperties) diff --git a/src/main/kotlin/wu/seal/jsontokotlin/ui/ExtensionsTab.kt b/src/main/kotlin/wu/seal/jsontokotlin/ui/ExtensionsTab.kt index fec1b04a..8b07532b 100644 --- a/src/main/kotlin/wu/seal/jsontokotlin/ui/ExtensionsTab.kt +++ b/src/main/kotlin/wu/seal/jsontokotlin/ui/ExtensionsTab.kt @@ -18,7 +18,6 @@ class ExtensionsTab(layout: LayoutManager?, isDoubleBuffered: Boolean) : JPanel( ExtensionsCollector.extensions.forEach { row(separated = false) { it.createUI().apply { - background = Color(225,225,225) preferredSize = JBDimension(500, 0) }.invoke() } diff --git a/src/main/kotlin/wu/seal/jsontokotlin/ui/JsonInputDialog.kt b/src/main/kotlin/wu/seal/jsontokotlin/ui/JsonInputDialog.kt index d78baff8..f2445eb5 100644 --- a/src/main/kotlin/wu/seal/jsontokotlin/ui/JsonInputDialog.kt +++ b/src/main/kotlin/wu/seal/jsontokotlin/ui/JsonInputDialog.kt @@ -128,7 +128,7 @@ class JsonInputDialog(classsName: String, private val project: Project) : Messag private fun createJsonContentEditor(): Editor { val editorFactory = EditorFactory.getInstance() - val document = editorFactory.createDocument("").apply { } + val document = editorFactory.createDocument("").apply { } document.setReadOnly(false) document.addDocumentListener(object : com.intellij.openapi.editor.event.DocumentListener { override fun documentChanged(event: com.intellij.openapi.editor.event.DocumentEvent?) = revalidate() @@ -142,7 +142,9 @@ class JsonInputDialog(classsName: String, private val project: Project) : Messag component.preferredSize = Dimension(640, 480) component.autoscrolls = true - editor.contentComponent.componentPopupMenu = JPopupMenu().apply { + val contentComponent = editor.contentComponent + contentComponent.isFocusable = true + contentComponent.componentPopupMenu = JPopupMenu().apply { add(createPasteFromClipboardMenuItem()) add(createRetrieveContentFromHttpURLMenuItem()) add(createLoadFromLocalFileMenu()) @@ -210,7 +212,7 @@ class JsonInputDialog(classsName: String, private val project: Project) : Messag override fun getInputString(): String = if (exitCode == 0) jsonContentEditor.document.text.trim() else "" override fun getPreferredFocusedComponent(): JComponent? { - return if (this.myField.text?.isEmpty() != false) { + return if (this.myField.text.isNullOrEmpty()) { this.myField } else { jsonContentEditor.contentComponent