Skip to content

Commit 69d0642

Browse files
committed
feat(ui): add scroll pane to elementsList in AutoDevInputSection
Wrap elementsList in a JBScrollPane to enable vertical and horizontal scrolling as needed. This improves usability for long lists.
1 parent 797e6f7 commit 69d0642

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import com.intellij.ui.MutableCollectionComboBoxModel
4343
import com.intellij.ui.SimpleListCellRenderer
4444
import com.intellij.ui.components.JBLabel
4545
import com.intellij.ui.components.JBList
46+
import com.intellij.ui.components.JBScrollPane
4647
import com.intellij.util.EventDispatcher
4748
import com.intellij.util.ui.JBEmptyBorder
4849
import com.intellij.util.ui.JBUI
@@ -166,7 +167,12 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
166167
inputPanel.add(input, BorderLayout.CENTER)
167168
inputPanel.addToBottom(layoutPanel)
168169

169-
this.add(elementsList, BorderLayout.NORTH)
170+
// 将 elementsList 放入 JScrollPane 中
171+
val scrollPane = JBScrollPane(elementsList)
172+
scrollPane.verticalScrollBarPolicy = JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
173+
scrollPane.horizontalScrollBarPolicy = JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
174+
this.add(scrollPane, BorderLayout.NORTH)
175+
170176
this.add(inputPanel, BorderLayout.CENTER)
171177

172178
ComponentValidator(disposable!!).withValidator(Supplier<ValidationInfo?> {
@@ -222,6 +228,9 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
222228
elementsList.cellRenderer = RelatedFileListCellRenderer()
223229
elementsList.setEmptyText("")
224230

231+
// 假设 elementsList 是某个容器的子组件,你需要将 scrollPane 添加到该容器中
232+
// 例如:parentContainer.add(scrollPane)
233+
225234
elementsList.addMouseListener(object : MouseAdapter() {
226235
override fun mouseClicked(e: MouseEvent) {
227236
val list = e.source as JBList<*>

0 commit comments

Comments
 (0)