@@ -13,6 +13,7 @@ import cc.unitmesh.devti.gui.chat.ui.AutoDevInputListener
13
13
import cc.unitmesh.devti.gui.chat.ui.AutoDevInputSection
14
14
import cc.unitmesh.devti.gui.chat.ui.AutoDevInputTrigger
15
15
import cc.unitmesh.devti.gui.chat.view.MessageView
16
+ import cc.unitmesh.devti.gui.component.LoadingSpinner
16
17
import cc.unitmesh.devti.gui.toolbar.CopyAllMessagesAction
17
18
import cc.unitmesh.devti.gui.toolbar.NewChatAction
18
19
import cc.unitmesh.devti.provider.TextContextPrompter
@@ -32,7 +33,6 @@ import com.intellij.openapi.ui.DialogPanel
32
33
import com.intellij.openapi.ui.NullableComponent
33
34
import com.intellij.openapi.ui.SimpleToolWindowPanel
34
35
import com.intellij.openapi.wm.IdeFocusManager
35
- import com.intellij.ui.JBColor
36
36
import com.intellij.ui.JBColor.PanelBackground
37
37
import com.intellij.ui.components.JBScrollPane
38
38
import com.intellij.ui.components.panels.VerticalLayout
@@ -50,30 +50,6 @@ import java.awt.event.MouseAdapter
50
50
import java.awt.event.MouseEvent
51
51
import javax.swing.*
52
52
53
- interface AutoDevChatPanel {
54
- val progressBar: JProgressBar get() = JProgressBar ()
55
- fun resetChatSession ()
56
-
57
- /* *
58
- * Custom Agent Event
59
- */
60
- fun resetAgent ()
61
- fun hasSelectedCustomAgent (): Boolean
62
- fun getSelectedCustomAgent (): CustomAgentConfig
63
- fun selectAgent (config : CustomAgentConfig )
64
-
65
- /* *
66
- * Progress Bar
67
- */
68
- fun hiddenProgressBar ()
69
- fun showProgressBar ()
70
-
71
- /* *
72
- * append custom view
73
- */
74
- fun appendWebView (content : String , project : Project )
75
- }
76
-
77
53
class NormalChatCodingPanel (private val chatCodingService : ChatCodingService , val disposable : Disposable ? ) :
78
54
SimpleToolWindowPanel (true , true ), NullableComponent , AutoDevChatPanel {
79
55
private val myList = JPanel (VerticalLayout (JBUI .scale(4 )))
@@ -203,7 +179,7 @@ class NormalChatCodingPanel(private val chatCodingService: ChatCodingService, va
203
179
return messageView
204
180
}
205
181
206
- fun showInitLoading () {
182
+ fun showInitLoading (string : String ) {
207
183
clearLoadingView()
208
184
loadingPanel = JPanel (BorderLayout ())
209
185
loadingPanel!! .background = UIUtil .getListBackground()
@@ -212,51 +188,10 @@ class NormalChatCodingPanel(private val chatCodingService: ChatCodingService, va
212
188
val spinnerPanel = JPanel ()
213
189
spinnerPanel.isOpaque = false
214
190
215
- val spinner = object : JPanel () {
216
- override fun paintComponent (g : Graphics ) {
217
- super .paintComponent(g)
218
-
219
- val g2d = g as Graphics2D
220
- g2d.setRenderingHint(RenderingHints .KEY_ANTIALIASING , RenderingHints .VALUE_ANTIALIAS_ON )
221
-
222
- val width = width.toFloat()
223
- val height = height.toFloat()
224
- val centerX = width / 2
225
- val centerY = height / 2
226
- val radius = minOf(width, height) / 2 - 5
227
-
228
- val oldStroke = g2d.stroke
229
- g2d.stroke = BasicStroke (3f )
230
-
231
- val step = if (loadingStep >= 12 ) 0 else loadingStep
232
- for (i in 0 until 12 ) {
233
- g2d.color = JBColor (
234
- Color (47 , 99 , 162 , 255 - ((i + 12 - step) % 12 ) * 20 ),
235
- Color (88 , 157 , 246 , 255 - ((i + 12 - step) % 12 ) * 20 )
236
- )
237
-
238
- val startAngle = i * 30
239
- g2d.drawArc(
240
- (centerX - radius).toInt(),
241
- (centerY - radius).toInt(),
242
- (radius * 2 ).toInt(),
243
- (radius * 2 ).toInt(),
244
- startAngle,
245
- 15
246
- )
247
- }
248
-
249
- g2d.stroke = oldStroke
250
- }
251
-
252
- override fun getPreferredSize (): Dimension {
253
- return Dimension (40 , 40 )
254
- }
255
- }
256
-
191
+ val spinner = LoadingSpinner ()
257
192
spinnerPanel.add(spinner)
258
193
259
- val loadingLabel = JLabel (" Loading " , SwingConstants .CENTER )
194
+ val loadingLabel = JLabel (string , SwingConstants .CENTER )
260
195
loadingPanel!! .add(spinnerPanel, BorderLayout .CENTER )
261
196
loadingPanel!! .add(loadingLabel, BorderLayout .SOUTH )
262
197
@@ -278,15 +213,12 @@ class NormalChatCodingPanel(private val chatCodingService: ChatCodingService, va
278
213
}
279
214
280
215
private fun clearLoadingView () {
281
- // Stop the timer first
282
216
loadingTimer?.stop()
283
217
loadingTimer = null
284
218
285
- // Safely remove the loading panel if it exists
286
219
if (loadingPanel != null ) {
287
220
val panelToRemove = loadingPanel
288
221
runInEdt {
289
- // Check if the panel is still in the component hierarchy
290
222
if (panelToRemove != null && panelToRemove.parent == = myList) {
291
223
try {
292
224
myList.remove(panelToRemove)
@@ -453,4 +385,3 @@ class NormalChatCodingPanel(private val chatCodingService: ChatCodingService, va
453
385
inputSection.moveCursorToStart()
454
386
}
455
387
}
456
-
0 commit comments