Skip to content

Commit 5738d3d

Browse files
committed
refactor(gui): refactor auto dev input section to use mutable collection combo box model
1 parent 00706be commit 5738d3d

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import com.intellij.openapi.ui.ValidationInfo
2323
import com.intellij.openapi.wm.IdeFocusManager
2424
import com.intellij.openapi.wm.impl.InternalDecorator
2525
import com.intellij.temporary.gui.block.AutoDevCoolBorder
26-
import com.intellij.ui.CollectionComboBoxModel
2726
import com.intellij.ui.JBColor
2827
import com.intellij.ui.MutableCollectionComboBoxModel
2928
import com.intellij.ui.SimpleListCellRenderer
@@ -55,7 +54,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
5554
private val documentListener: DocumentListener
5655
private val buttonPresentation: Presentation
5756
private val button: ActionButton
58-
private val customRag: ComboBox<CustomRagApp>
57+
private var customRag: ComboBox<CustomRagApp> = ComboBox(MutableCollectionComboBoxModel(listOf()))
5958
private val logger = logger<AutoDevInputSection>()
6059

6160
val editorListeners: EventDispatcher<AutoDevInputListener> =
@@ -116,14 +115,18 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
116115
JBColor(3684930, 3750720)
117116
)
118117
layoutPanel.setOpaque(false)
119-
customRag = ComboBox(MutableCollectionComboBoxModel(loadRagApps()))
120-
customRag.setRenderer(SimpleListCellRenderer.create { label: JBLabel, value: CustomRagApp?, _: Int ->
121-
if (value != null) {
122-
label.text = value.name
123-
}
124-
})
125118

126-
layoutPanel.addToLeft(customRag)
119+
if (project.customRagSettings.enableCustomRag) {
120+
customRag = ComboBox(MutableCollectionComboBoxModel(loadRagApps()))
121+
customRag.setRenderer(SimpleListCellRenderer.create { label: JBLabel, value: CustomRagApp?, _: Int ->
122+
if (value != null) {
123+
label.text = value.name
124+
}
125+
})
126+
127+
layoutPanel.addToLeft(customRag)
128+
}
129+
127130
layoutPanel.addToCenter(horizontalGlue)
128131
layoutPanel.addToRight(button)
129132
addToBottom(layoutPanel)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
206206

207207
var text = ""
208208
content.onCompletion {
209-
// println("onCompletion ${it?.message}")
210209
logger.info("onCompletion ${it?.message}")
211210
}.catch {
212211
it.printStackTrace()

src/main/kotlin/cc/unitmesh/devti/gui/toolbar/NewChatAction.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,8 @@ class NewChatAction : DumbAwareAction(), CustomComponentAction {
3939
val toolWindowManager = ToolWindowManager.getInstance(project).getToolWindow(
4040
AutoDevToolWindowFactory.Util.id
4141
)
42-
val contentManager = toolWindowManager?.contentManager
43-
val codingPanel =
44-
contentManager?.component?.components?.filterIsInstance<ChatCodingPanel>()?.firstOrNull()
4542

46-
if (codingPanel == null) {
47-
AutoDevToolWindowFactory().createToolWindowContent(project, toolWindowManager!!)
48-
return@addActionListener
49-
}
50-
51-
codingPanel.clearChat()
43+
AutoDevToolWindowFactory().createToolWindowContent(project, toolWindowManager!!)
5244
}
5345
}
5446
}

0 commit comments

Comments
 (0)