Skip to content

Commit e70f265

Browse files
committed
feat(gui): add toolbar to AutoDevPlannerToolWindow and update IssueInputPanel #352
- Add toolbar to AutoDevPlannerToolWindow for better navigation- Remove title actions from AutoDevPlannerToolWindowFactory - Update IssueInputPanel to handle empty input and improve styling
1 parent 129fb29 commit e70f265

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

core/src/main/kotlin/cc/unitmesh/devti/gui/AutoDevPlannerToolWindowFactory.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cc.unitmesh.devti.gui
22

33
import cc.unitmesh.devti.gui.planner.AutoDevPlannerToolWindow
4-
import com.intellij.openapi.actionSystem.ex.ActionUtil
54
import com.intellij.openapi.project.DumbAware
65
import com.intellij.openapi.project.Project
76
import com.intellij.openapi.ui.Splittable
@@ -22,7 +21,6 @@ class AutoDevPlannerToolWindowFactory : ToolWindowFactory, ToolWindowManagerList
2221
val manager = toolWindow.contentManager
2322
manager.addContent(manager.factory.createContent(panel, null, false).apply { isCloseable = false })
2423
project.messageBus.connect(manager).subscribe(ToolWindowManagerListener.TOPIC, this)
25-
toolWindow.setTitleActions(listOfNotNull(ActionUtil.getAction("AutoDevPlanner.ToolWindow.TitleActions")))
2624
}
2725

2826
override fun stateChanged(manager: ToolWindowManager) {

core/src/main/kotlin/cc/unitmesh/devti/gui/planner/AutoDevPlannerToolWindow.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import cc.unitmesh.devti.observer.plan.PlanUpdateListener
88
import cc.unitmesh.devti.shadow.IssueInputPanel
99
import cc.unitmesh.devti.sketch.ui.plan.PlanLangSketch
1010
import com.intellij.openapi.Disposable
11+
import com.intellij.openapi.actionSystem.ActionGroup
12+
import com.intellij.openapi.actionSystem.ActionManager
13+
import com.intellij.openapi.actionSystem.ex.ActionUtil
1114
import com.intellij.openapi.application.ApplicationManager
1215
import com.intellij.openapi.application.runInEdt
1316
import com.intellij.openapi.project.Project
@@ -37,6 +40,18 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
3740
private val plannerResultSummary = PlannerResultSummary(project, mutableListOf())
3841

3942
init {
43+
val toolbar = ActionManager.getInstance()
44+
.createActionToolbar(
45+
AutoDevPlannerToolWindowFactory.Companion.PlANNER_ID,
46+
ActionUtil.getAction("AutoDevPlanner.ToolWindow.TitleActions") as ActionGroup,
47+
true
48+
)
49+
50+
val toolbarPanel = JPanel(FlowLayout(FlowLayout.RIGHT))
51+
toolbarPanel.add(toolbar.component)
52+
53+
contentPanel.add(toolbarPanel, BorderLayout.NORTH)
54+
4055
if (content.isBlank()) {
4156
isIssueInputMode = true
4257
contentPanel.add(createIssueInputPanel(), BorderLayout.CENTER)

core/src/main/kotlin/cc/unitmesh/devti/shadow/IssueInputPanel.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devti.shadow
22

3+
import cc.unitmesh.devti.AutoDevNotifications
34
import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
45
import cc.unitmesh.devti.gui.chat.message.ChatActionType
56
import cc.unitmesh.devti.sketch.AutoSketchMode
@@ -8,7 +9,6 @@ import com.intellij.openapi.fileTypes.FileTypes
89
import com.intellij.openapi.project.Project
910
import com.intellij.ui.*
1011
import com.intellij.util.containers.ContainerUtil
11-
import com.intellij.util.ui.JBUI
1212
import java.awt.BorderLayout
1313
import java.awt.FlowLayout
1414
import javax.swing.BorderFactory
@@ -22,21 +22,19 @@ class IssueInputPanel(
2222
private val onSubmit: (String) -> Unit,
2323
private val onCancel: () -> Unit
2424
) : JPanel(BorderLayout()) {
25-
private val textArea: EditorTextField
26-
private var isPlaceholderVisible = true
25+
private val textArea: EditorTextField = createEditor(project).apply {
26+
setPlaceholder(placeholder)
27+
setShowPlaceholderWhenFocused(true)
28+
setBorder(BorderFactory.createEmptyBorder())
29+
}
2730

2831
init {
29-
textArea = createEditor(project).apply {
30-
setPlaceholder(placeholder)
31-
setShowPlaceholderWhenFocused(true)
32-
}
33-
3432
val buttonsPanel = createActionButtons()
3533

3634
add(textArea, BorderLayout.CENTER)
3735
add(buttonsPanel, BorderLayout.SOUTH)
3836

39-
background = textArea.editor?.component?.background ?: JBUI.CurrentTheme.ToolWindow.background()
37+
background = JBColor.WHITE
4038
setBorder(BorderFactory.createEmptyBorder())
4139
}
4240

@@ -49,10 +47,11 @@ class IssueInputPanel(
4947

5048
val submitButton = JButton("Submit").apply {
5149
addActionListener {
52-
val text = if (isPlaceholderVisible) "" else textArea.text
5350
if (text.isNotBlank()) {
5451
handlingExecute(text)
5552
onSubmit(text)
53+
} else {
54+
AutoDevNotifications.notify(project, "Input cannot be empty")
5655
}
5756
}
5857
}
@@ -76,15 +75,13 @@ class IssueInputPanel(
7675
}
7776
}
7877

79-
fun getText(): String = if (isPlaceholderVisible) "" else textArea.text
78+
fun getText(): String = textArea.text
8079

8180
fun setText(text: String) {
8281
if (text.isNotBlank()) {
8382
textArea.text = text
84-
isPlaceholderVisible = false
8583
} else {
8684
textArea.text = placeholder
87-
isPlaceholderVisible = true
8885
}
8986
}
9087

0 commit comments

Comments
 (0)