Skip to content

Commit

Permalink
Merge pull request #115 from wuseal/3.0.1-update-ui
Browse files Browse the repository at this point in the history
3.0.1 update ui
  • Loading branch information
wuseal authored Mar 3, 2019
2 parents 9edea8a + 240958d commit da8d596
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/extensions/wu/seal/PropertySuffixSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/wu/seal/jsontokotlin/ui/ExtensionsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/wu/seal/jsontokotlin/ui/JsonInputDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit da8d596

Please sign in to comment.