Skip to content

Commit 8b54522

Browse files
committed
feat(gui): add AutoDevVariableListComponent and improve popup behavior in AutoDevInputSection #51
The commit introduces a new class `AutoDevVariableListComponent` to the GUI package, which is a custom Swing component. Additionally, the commit modifies the `AutoDevInputSection` class to improve the behavior of the popup when the user inputs a specific character. The popup is now created lazily and reused if it's not disposed, ensuring better memory management and a smoother user experience.
1 parent 741dda8 commit 8b54522

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import com.intellij.util.ui.JBEmptyBorder
3636
import com.intellij.util.ui.JBUI
3737
import com.intellij.util.ui.UIUtil
3838
import com.intellij.util.ui.components.BorderLayoutPanel
39+
import com.intellij.vcsUtil.showAbove
3940
import kotlinx.serialization.decodeFromString
4041
import kotlinx.serialization.json.Json
4142
import java.awt.Color
@@ -105,16 +106,17 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
105106

106107
// check new input == $
107108
if (event.newFragment.contentEquals("$") || event.newFragment.contentEquals("¥")) {
108-
popup?.show(this@AutoDevInputSection)
109+
if (popup?.isDisposed == true) {
110+
popup = createPopup()
111+
popup?.showAbove(input)
112+
} else {
113+
popup?.showAbove(input)
114+
}
109115
}
110116
}
111117
}
112118

113-
popup = JBPopupFactory.getInstance().createComponentPopupBuilder(JTextField(""), null)
114-
.setRequestFocus(false)
115-
.setMinSize(
116-
Dimension(200, 200)
117-
).createPopup()
119+
popup = createPopup()
118120

119121
input.addDocumentListener(documentListener)
120122
input.recreateDocument()
@@ -167,6 +169,12 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
167169
tokenizer = TokenizerImpl.INSTANCE
168170
}
169171

172+
private fun createPopup() = JBPopupFactory.getInstance().createComponentPopupBuilder(AutoDevVariableListComponent(), null)
173+
.setRequestFocus(false)
174+
.setMinSize(
175+
Dimension(200, 200)
176+
).createPopup()
177+
170178

171179
private fun loadRagApps(): List<CustomAgentConfig> {
172180
val ragsJsonConfig = project.customAgentSetting.ragsJsonConfig
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cc.unitmesh.devti.gui.chat
2+
3+
import javax.swing.JPanel
4+
5+
class AutoDevVariableListComponent : JPanel() {
6+
init {
7+
// TODO
8+
isOpaque = true
9+
}
10+
}
11+

0 commit comments

Comments
 (0)