1
1
package cc.unitmesh.devti.gui.toolbar
2
2
3
3
import cc.unitmesh.devti.AutoDevBundle
4
+ import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
5
+ import cc.unitmesh.devti.gui.chat.ChatCodingPanel
4
6
import com.intellij.openapi.actionSystem.AnActionEvent
5
7
import com.intellij.openapi.actionSystem.Presentation
6
8
import com.intellij.openapi.actionSystem.ex.CustomComponentAction
7
9
import com.intellij.openapi.project.DumbAwareAction
10
+ import com.intellij.openapi.project.ProjectManager
11
+ import com.intellij.openapi.wm.ToolWindowManager
8
12
import com.intellij.ui.components.panels.Wrapper
9
13
import com.intellij.util.ui.JBInsets
10
14
import com.intellij.util.ui.JBUI
15
+ import java.awt.event.ActionEvent
11
16
import javax.swing.JButton
12
17
import javax.swing.JComponent
13
18
@@ -23,6 +28,15 @@ class NewChatAction : DumbAwareAction(), CustomComponentAction {
23
28
putClientProperty(" ActionToolbar.smallVariant" , true )
24
29
putClientProperty(" customButtonInsets" , JBInsets (1 ).asUIResource())
25
30
setOpaque(false )
31
+ addActionListener { event: ActionEvent ? ->
32
+ val project = ProjectManager .getInstance().openProjects.firstOrNull() ? : return @addActionListener
33
+ val toolWindowManager = ToolWindowManager .getInstance(project).getToolWindow(
34
+ AutoDevToolWindowFactory .Util .id)
35
+ val contentManager = toolWindowManager?.contentManager
36
+ contentManager?.component?.components?.filterIsInstance<ChatCodingPanel >()?.firstOrNull()?.let {
37
+ it.clearChat()
38
+ }
39
+ }
26
40
}
27
41
}
28
42
return Wrapper (button).also {
0 commit comments