Skip to content

Commit 41a9429

Browse files
committed
refactor(chat): reorganize layout components in AutoDevInputSection #257
- Introduced `inputPanel` to centralize input and layout components. - Removed redundant scroll pane setup for `elementsList`. - Adjusted border application to `inputPanel` instead of the main container.
1 parent 0e92133 commit 41a9429

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
6969
private val sendButton: ActionButton
7070
private val stopButton: ActionButton
7171
private val buttonPanel = JPanel(CardLayout())
72+
private val inputPanel = BorderLayoutPanel()
7273

7374
private val listModel = DefaultListModel<ModelWrapper>()
7475
private val elementsList = JBList(listModel)
@@ -142,9 +143,6 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
142143
input.recreateDocument()
143144
input.border = JBEmptyBorder(10)
144145

145-
this.add(input, BorderLayout.CENTER)
146-
this.add(elementsList, BorderLayout.NORTH)
147-
148146
val layoutPanel = BorderLayoutPanel()
149147
val horizontalGlue = Box.createHorizontalGlue()
150148
horizontalGlue.addMouseListener(object : MouseAdapter() {
@@ -174,7 +172,12 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
174172

175173
layoutPanel.addToCenter(horizontalGlue)
176174
layoutPanel.addToRight(buttonPanel)
177-
addToBottom(layoutPanel)
175+
176+
inputPanel.add(input, BorderLayout.CENTER)
177+
inputPanel.addToBottom(layoutPanel)
178+
179+
this.add(elementsList, BorderLayout.NORTH)
180+
this.add(inputPanel, BorderLayout.CENTER)
178181

179182
ComponentValidator(disposable!!).withValidator(Supplier<ValidationInfo?> {
180183
val validationInfo: ValidationInfo? = this.getInputValidationInfo()
@@ -224,11 +227,6 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
224227
elementsList.cellRenderer = RelatedFileListCellRenderer()
225228
elementsList.setEmptyText("")
226229

227-
val scrollPane = JBScrollPane(elementsList)
228-
scrollPane.preferredSize = Dimension(-1, 80)
229-
scrollPane.horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
230-
scrollPane.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
231-
232230
elementsList.addMouseListener(object : MouseAdapter() {
233231
override fun mouseClicked(e: MouseEvent) {
234232
val list = e.source as JBList<*>
@@ -255,8 +253,6 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
255253
} ?: list.clearSelection()
256254
}
257255
})
258-
259-
add(scrollPane, BorderLayout.NORTH)
260256
}
261257

262258
private fun updateElements(elements: List<PsiElement>?) {
@@ -296,7 +292,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
296292

297293
fun initEditor() {
298294
val editorEx = this.input.editor as? EditorEx ?: return
299-
setBorder(AutoDevCoolBorder(editorEx, this))
295+
inputPanel.setBorder(AutoDevCoolBorder(editorEx, this))
300296
UIUtil.setOpaqueRecursively(this, false)
301297
this.revalidate()
302298
}

0 commit comments

Comments
 (0)