1
1
package cc.unitmesh.devti.shadow
2
2
3
+ import cc.unitmesh.devti.AutoDevNotifications
3
4
import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
4
5
import cc.unitmesh.devti.gui.chat.message.ChatActionType
5
6
import cc.unitmesh.devti.sketch.AutoSketchMode
@@ -8,7 +9,6 @@ import com.intellij.openapi.fileTypes.FileTypes
8
9
import com.intellij.openapi.project.Project
9
10
import com.intellij.ui.*
10
11
import com.intellij.util.containers.ContainerUtil
11
- import com.intellij.util.ui.JBUI
12
12
import java.awt.BorderLayout
13
13
import java.awt.FlowLayout
14
14
import javax.swing.BorderFactory
@@ -22,21 +22,19 @@ class IssueInputPanel(
22
22
private val onSubmit : (String ) -> Unit ,
23
23
private val onCancel : () -> Unit
24
24
) : JPanel(BorderLayout ()) {
25
- private val textArea: EditorTextField
26
- private var isPlaceholderVisible = true
25
+ private val textArea: EditorTextField = createEditor(project).apply {
26
+ setPlaceholder(placeholder)
27
+ setShowPlaceholderWhenFocused(true )
28
+ setBorder(BorderFactory .createEmptyBorder())
29
+ }
27
30
28
31
init {
29
- textArea = createEditor(project).apply {
30
- setPlaceholder(placeholder)
31
- setShowPlaceholderWhenFocused(true )
32
- }
33
-
34
32
val buttonsPanel = createActionButtons()
35
33
36
34
add(textArea, BorderLayout .CENTER )
37
35
add(buttonsPanel, BorderLayout .SOUTH )
38
36
39
- background = textArea.editor?.component?.background ? : JBUI . CurrentTheme . ToolWindow .background()
37
+ background = JBColor . WHITE
40
38
setBorder(BorderFactory .createEmptyBorder())
41
39
}
42
40
@@ -49,10 +47,11 @@ class IssueInputPanel(
49
47
50
48
val submitButton = JButton (" Submit" ).apply {
51
49
addActionListener {
52
- val text = if (isPlaceholderVisible) " " else textArea.text
53
50
if (text.isNotBlank()) {
54
51
handlingExecute(text)
55
52
onSubmit(text)
53
+ } else {
54
+ AutoDevNotifications .notify(project, " Input cannot be empty" )
56
55
}
57
56
}
58
57
}
@@ -76,15 +75,13 @@ class IssueInputPanel(
76
75
}
77
76
}
78
77
79
- fun getText (): String = if (isPlaceholderVisible) " " else textArea.text
78
+ fun getText (): String = textArea.text
80
79
81
80
fun setText (text : String ) {
82
81
if (text.isNotBlank()) {
83
82
textArea.text = text
84
- isPlaceholderVisible = false
85
83
} else {
86
84
textArea.text = placeholder
87
- isPlaceholderVisible = true
88
85
}
89
86
}
90
87
0 commit comments