Skip to content

Commit 7a466db

Browse files
author
seal
committed
beautify config settings dialog layout
optimize some code logic
1 parent 7c1cf85 commit 7a466db

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

src/wu/seal/jsontokotlin/ConfigSettingDialog.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ interface IConfigSettingDialog {
2020

2121
}
2222

23-
//todo : change the tab of TargetJson Lib postion to make it more pre
2423
class ConfigSettingDialog(canBeParent: Boolean) : DialogWrapper(canBeParent), IConfigSettingDialog {
2524

2625
init {

src/wu/seal/jsontokotlin/JsonToKotlinApplication.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package wu.seal.jsontokotlin
22

33
import com.intellij.openapi.components.ApplicationComponent
4-
import com.intellij.openapi.ui.Messages
5-
import wu.seal.jsontokotlin.statistics.handlerException
64
import wu.seal.jsontokotlin.statistics.sendHistoryExceptionInfo
75
import wu.seal.jsontokotlin.statistics.sendHistoryActionInfo
86

src/wu/seal/jsontokotlin/MakeKotlinClassAction.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.intellij.openapi.project.Project
1010
import com.intellij.openapi.ui.Messages
1111
import wu.seal.jsontokotlin.statistics.StartAction
1212
import wu.seal.jsontokotlin.statistics.SuccessCompleteAction
13-
import wu.seal.jsontokotlin.statistics.handlerException
13+
import wu.seal.jsontokotlin.statistics.getUncaughtExceptionHandler
1414
import wu.seal.jsontokotlin.statistics.sendActionInfo
1515

1616
import java.util.IllegalFormatFlagsException
@@ -60,7 +60,7 @@ class MakeKotlinClassAction : AnAction("MakeKotlinClass") {
6060
}
6161

6262
executeCouldRollBackAction(project) {
63-
var offset = 0
63+
var offset: Int
6464

6565
if (caret != null) {
6666

@@ -77,7 +77,7 @@ class MakeKotlinClassAction : AnAction("MakeKotlinClass") {
7777
Messages.showMessageDialog(project, "Kotlin Code insert successfully!", "Information", Messages.getInformationIcon())
7878
sendActionInfo(gson.toJson(SuccessCompleteAction()))
7979
} catch(e: Exception) {
80-
handlerException(jsonString) {
80+
getUncaughtExceptionHandler(jsonString) {
8181
Messages.showErrorDialog("I am sorry,JsonToKotlin may occur a RuntimeException,You could try again later or recover to the old version", "Occur a fatal error")
8282
}.uncaughtException(Thread.currentThread(), e)
8383
}

src/wu/seal/jsontokotlin/Panel.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package wu.seal.jsontokotlin
22

3+
import com.intellij.util.ui.JBDimension
4+
import com.intellij.util.ui.JBUI
5+
import com.intellij.util.xml.ui.TextPanel
36
import java.awt.*
47
import javax.swing.*
58
import javax.swing.border.EmptyBorder
@@ -21,7 +24,8 @@ class PropertyPanel(layout: LayoutManager?, isDoubleBuffered: Boolean) : JPanel(
2124

2225
val boxLayout = BoxLayout(this, BoxLayout.PAGE_AXIS)
2326
setLayout(boxLayout)
24-
border = EmptyBorder(10, 10, 10, 10)
27+
val bordWidth = JBUI.scale(10)
28+
border = EmptyBorder(bordWidth, bordWidth, bordWidth, bordWidth)
2529

2630
val keywordLable = JLabel("Keyword")
2731

@@ -56,11 +60,10 @@ class PropertyPanel(layout: LayoutManager?, isDoubleBuffered: Boolean) : JPanel(
5660
add(Box.createVerticalStrut(20))
5761

5862

59-
val line = JPanel()
60-
line.maximumSize = Dimension(1000, 1)
61-
line.minimumSize = Dimension(500, 1)
62-
line.preferredSize = Dimension(800, 1)
63-
line.background = Color.BLACK
63+
val line = TextPanel()
64+
line.maximumSize = JBDimension(480, 1)
65+
line.minimumSize = JBDimension(480, 1)
66+
line.background = Color.GRAY
6467

6568
add(line)
6669

@@ -103,9 +106,9 @@ class CommentConfigPanel(layout: LayoutManager?, isDoubleBuffered: Boolean) : JP
103106

104107
init {
105108

106-
border = EmptyBorder(10, 10, 10, 10)
107-
108-
setLayout(GridLayout(5, 1, 10, 10))
109+
val bordWidth = JBUI.scale(10)
110+
border = EmptyBorder(bordWidth, bordWidth, bordWidth, bordWidth)
111+
setLayout(GridLayout(6, 1, 10, 10))
109112

110113
val radioButtonOpen = JRadioButton("On")
111114

@@ -145,9 +148,10 @@ class TargetJsonLibConfigPanel(layout: LayoutManager?, isDoubleBuffered: Boolean
145148

146149
init {
147150

148-
border = EmptyBorder(10, 10, 10, 10)
151+
val bordWidth = JBUI.scale(10)
152+
border = EmptyBorder(bordWidth, bordWidth, bordWidth, bordWidth)
149153

150-
setLayout(GridLayout(5, 1, 10, 10))
154+
setLayout(GridLayout(6, 1, 10, 10))
151155

152156
val radioButtonNone = JRadioButton("None")
153157

src/wu/seal/jsontokotlin/statistics/Actions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.util.*
1010
*/
1111

1212
const val ACTION_START = "action_start"
13-
const val ACTION_SUCCESS_COMPLETE = "action_sucess_complete"
13+
const val ACTION_SUCCESS_COMPLETE = "action_success_complete"
1414

1515
data class StartAction(
1616
val uuid: String = UUID,

src/wu/seal/jsontokotlin/statistics/ExceptionHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java.util.*
1515
/**
1616
* handler the exception
1717
*/
18-
fun handlerException(jsonString: String, callBack: () -> Unit): Thread.UncaughtExceptionHandler = Thread.UncaughtExceptionHandler { t, e ->
18+
fun getUncaughtExceptionHandler(jsonString: String, callBack: () -> Unit): Thread.UncaughtExceptionHandler = Thread.UncaughtExceptionHandler { _, e ->
1919
val logBuilder = StringBuilder()
2020
logBuilder.append("PluginVersion:$PLUGIN_VERSION\n")
2121
logBuilder.append("user: $UUID").append("\n")

src/wu/seal/jsontokotlin/statistics/NetWork.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fun sendHistoryExceptionInfo() {
5757
PersistCache.readAllCachedExceptionInfo().split("#").filter { it.isNotBlank() }.forEach {
5858
sendExceptionLog(it)
5959
}
60-
}
60+
}.start()
6161
PersistCache.deleteAllExceptionInfoCache()
6262
}
6363

src/wu/seal/jsontokotlin/statistics/PersistCache.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ object PersistCache : IPersistCache {
5757
override fun readAllCachedExceptionInfo(): String {
5858
val builder = StringBuilder()
5959
exceptionDir.listFiles().forEach {
60-
builder.append(it.readText()).append("#")
60+
if (it.exists()) {
61+
builder.append(it.readText()).append("#")
62+
}
6163
}
6264
return builder.toString()
6365
}
@@ -73,12 +75,15 @@ object PersistCache : IPersistCache {
7375
override fun readAllCachedActionInfo(): String {
7476
val builder = StringBuilder()
7577
actionDir.listFiles().forEach {
76-
builder.append(it.readText()).append("#")
78+
if (it.exists()) {
79+
builder.append(it.readText()).append("#")
80+
}
7781
}
7882
return builder.toString()
7983
}
8084

8185
override fun deleteAllActionInfo() {
86+
actionDir.listFiles().forEach { it.delete() }
8287
}
8388

8489
}

0 commit comments

Comments
 (0)