Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.1 update ui #115

Merged
merged 3 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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