Skip to content

Commit e670f28

Browse files
committed
feat(ui): extract ResponseDetailPanel to separate file #371
Move ResponseDetailPanel from McpMessageLogPanel to its own file and improve content display with JsonLanguageField.
1 parent 21722af commit e670f28

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

core/src/main/kotlin/cc/unitmesh/devti/mcp/ui/McpMessageLogPanel.kt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -304,40 +304,7 @@ class McpMessageLogPanel : JPanel(BorderLayout()) {
304304
}
305305

306306
private fun formatJsonValue(element: JsonElement): String {
307-
// Convert JsonElement to a nicely formatted string
308307
return element.toString()
309308
}
310309
}
311-
312-
private class ResponseDetailPanel : JPanel(BorderLayout()) {
313-
private val headerPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
314-
border = JBUI.Borders.empty(10)
315-
background = JBColor(0xF8F9FA, 0x2B2D30)
316-
}
317-
318-
private val durationLabel = JBLabel().apply {
319-
font = font.deriveFont(Font.BOLD)
320-
}
321-
322-
private val contentTextArea = JTextArea().apply {
323-
isEditable = false
324-
wrapStyleWord = true
325-
lineWrap = true
326-
border = JBUI.Borders.empty(10)
327-
}
328-
329-
init {
330-
headerPanel.add(JBLabel("Response Duration:"))
331-
headerPanel.add(durationLabel)
332-
333-
add(headerPanel, BorderLayout.NORTH)
334-
add(JBScrollPane(contentTextArea), BorderLayout.CENTER)
335-
}
336-
337-
fun displayMessage(message: McpMessage) {
338-
durationLabel.text = message.duration?.toString()?.plus(" ms") ?: "N/A"
339-
contentTextArea.text = message.content
340-
contentTextArea.caretPosition = 0
341-
}
342-
}
343310
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package cc.unitmesh.devti.mcp.ui
2+
3+
import cc.unitmesh.devti.mcp.ui.model.McpMessage
4+
import cc.unitmesh.devti.provider.local.JsonLanguageField
5+
import com.intellij.ui.JBColor
6+
import com.intellij.ui.components.JBLabel
7+
import com.intellij.ui.components.JBScrollPane
8+
import com.intellij.util.ui.JBUI
9+
import java.awt.BorderLayout
10+
import java.awt.FlowLayout
11+
import java.awt.Font
12+
import javax.swing.JPanel
13+
14+
class ResponseDetailPanel : JPanel(BorderLayout()) {
15+
private val headerPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
16+
border = JBUI.Borders.empty(10)
17+
background = JBColor(0xF8F9FA, 0x2B2D30)
18+
}
19+
20+
private val durationLabel = JBLabel().apply {
21+
font = font.deriveFont(Font.BOLD)
22+
}
23+
24+
private val contentTextArea = JsonLanguageField(
25+
null,
26+
"",
27+
"Response content",
28+
"response.json"
29+
).apply {
30+
border = JBUI.Borders.empty(10)
31+
}
32+
33+
init {
34+
headerPanel.add(JBLabel("Response Duration:"))
35+
headerPanel.add(durationLabel)
36+
37+
add(headerPanel, BorderLayout.NORTH)
38+
add(JBScrollPane(contentTextArea), BorderLayout.CENTER)
39+
}
40+
41+
fun displayMessage(message: McpMessage) {
42+
durationLabel.text = message.duration?.toString()?.plus(" ms") ?: "N/A"
43+
contentTextArea.text = message.content
44+
}
45+
}

0 commit comments

Comments
 (0)