Skip to content

Commit 46d6c84

Browse files
committed
refactor(devti): rename and restructure planner components
- Rename EditPlanViewPanel to PlanEditViewPanel- Rename IssueInputViewPanel to PlanIssueInputViewPanel - Rename LoadingPanel to PlanLoadingPanel - Update related imports and usages in AutoDevPlannerToolWindow - Remove shadow package for IssueInputViewPanel
1 parent 45937f6 commit 46d6c84

File tree

5 files changed

+32
-35
lines changed

5 files changed

+32
-35
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cc.unitmesh.devti.inline.fullWidth
55
import cc.unitmesh.devti.observer.plan.AgentTaskEntry
66
import cc.unitmesh.devti.observer.plan.MarkdownPlanParser
77
import cc.unitmesh.devti.observer.plan.PlanUpdateListener
8-
import cc.unitmesh.devti.shadow.IssueInputViewPanel
8+
import cc.unitmesh.devti.gui.planner.PlanIssueInputViewPanel
99
import cc.unitmesh.devti.sketch.ui.plan.PlanLangSketch
1010
import com.intellij.openapi.Disposable
1111
import com.intellij.openapi.actionSystem.ActionGroup
@@ -51,7 +51,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
5151
add(contentPanel, BorderLayout.CENTER)
5252

5353
if (content.isBlank()) {
54-
switchToView(IssueInputView())
54+
switchToView(PlanIssueInputView())
5555
} else {
5656
switchToView(PlanSketchView())
5757
}
@@ -62,7 +62,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
6262

6363
runInEdt {
6464
planLangSketch.updatePlan(items)
65-
contentPanel.components.find { it is LoadingPanel }?.let {
65+
contentPanel.components.find { it is PlanLoadingPanel }?.let {
6666
contentPanel.remove(it)
6767
contentPanel.revalidate()
6868
contentPanel.repaint()
@@ -112,7 +112,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
112112
val parsedItems = MarkdownPlanParser.parse(issueText).toMutableList()
113113
planLangSketch.updatePlan(parsedItems)
114114

115-
switchToView(LoadingView())
115+
switchToView(PlanLoadingView())
116116
}
117117

118118
override fun dispose() {
@@ -135,15 +135,15 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
135135
}
136136
}
137137

138-
inner class EditPlanView : PlannerView {
138+
inner class PlanEditView : PlannerView {
139139
override val viewType = PlannerViewType.EDITOR
140140
override fun initialize(window: AutoDevPlannerToolWindow) {
141-
val editPlanViewPanel = EditPlanViewPanel(
141+
val planEditViewPanel = PlanEditViewPanel(
142142
project = project,
143143
content = content,
144144
onSave = { newContent ->
145145
if (newContent == content) {
146-
return@EditPlanViewPanel
146+
return@PlanEditViewPanel
147147
}
148148
switchToPlanView(newContent)
149149
currentCallback?.invoke(newContent)
@@ -153,16 +153,16 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
153153
}
154154
)
155155

156-
contentPanel.add(editPlanViewPanel, BorderLayout.CENTER)
156+
contentPanel.add(planEditViewPanel, BorderLayout.CENTER)
157157
}
158158
}
159159

160-
inner class IssueInputView : PlannerView {
160+
inner class PlanIssueInputView : PlannerView {
161161
override val viewType = PlannerViewType.ISSUE_INPUT
162-
private lateinit var viewPanel: IssueInputViewPanel
162+
private lateinit var viewPanel: PlanIssueInputViewPanel
163163

164164
override fun initialize(window: AutoDevPlannerToolWindow) {
165-
viewPanel = IssueInputViewPanel(
165+
viewPanel = PlanIssueInputViewPanel(
166166
project,
167167
onSubmit = { issueText ->
168168
if (issueText.isNotBlank()) {
@@ -180,7 +180,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
180180
}
181181
}
182182

183-
inner class LoadingView : PlannerView {
183+
inner class PlanLoadingView : PlannerView {
184184
override val viewType = PlannerViewType.LOADING
185185
override fun initialize(window: AutoDevPlannerToolWindow) {
186186
val planPanel = panel {
@@ -192,7 +192,7 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
192192
}
193193

194194
contentPanel.add(planPanel, BorderLayout.CENTER)
195-
contentPanel.add(LoadingPanel(project), BorderLayout.NORTH)
195+
contentPanel.add(PlanLoadingPanel(project), BorderLayout.NORTH)
196196
}
197197
}
198198

@@ -217,13 +217,13 @@ class AutoDevPlannerToolWindow(val project: Project) : SimpleToolWindowPanel(tru
217217
if (planText.isNotEmpty() && planText != plannerWindow.content) {
218218
plannerWindow.content = planText
219219
}
220-
plannerWindow.switchToView(plannerWindow.EditPlanView())
220+
plannerWindow.switchToView(plannerWindow.PlanEditView())
221221
}
222222
}
223223

224224
fun showIssueInput(project: Project) {
225225
withPlannerWindow(project) { plannerWindow ->
226-
plannerWindow.switchToView(plannerWindow.IssueInputView())
226+
plannerWindow.switchToView(plannerWindow.PlanIssueInputView())
227227
}
228228
}
229229
}

core/src/main/kotlin/cc/unitmesh/devti/gui/planner/EditPlanViewPanel.kt renamed to core/src/main/kotlin/cc/unitmesh/devti/gui/planner/PlanEditViewPanel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import javax.swing.Box
1818
import javax.swing.JButton
1919
import javax.swing.JPanel
2020

21-
class EditPlanViewPanel(
21+
class PlanEditViewPanel(
2222
private val project: Project,
2323
private val content: String,
2424
private val onSave: (String) -> Unit,

core/src/main/kotlin/cc/unitmesh/devti/shadow/IssueInputViewPanel.kt renamed to core/src/main/kotlin/cc/unitmesh/devti/gui/planner/PlanIssueInputViewPanel.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
package cc.unitmesh.devti.shadow
1+
package cc.unitmesh.devti.gui.planner
22

33
import cc.unitmesh.devti.AutoDevBundle
44
import cc.unitmesh.devti.AutoDevNotifications
55
import cc.unitmesh.devti.gui.AutoDevToolWindowFactory
66
import cc.unitmesh.devti.gui.chat.message.ChatActionType
7-
import cc.unitmesh.devti.gui.planner.MarkdownLanguageField
87
import cc.unitmesh.devti.sketch.AutoSketchMode
98
import com.intellij.openapi.project.Project
109
import com.intellij.ui.components.JBScrollPane
@@ -15,7 +14,7 @@ import javax.swing.Box
1514
import javax.swing.JButton
1615
import javax.swing.JPanel
1716

18-
class IssueInputViewPanel(
17+
class PlanIssueInputViewPanel(
1918
private val project: Project,
2019
private val onSubmit: (String) -> Unit,
2120
private val onCancel: () -> Unit
@@ -58,7 +57,7 @@ class IssueInputViewPanel(
5857

5958
fun handlingExecute(newPlan: String) {
6059
AutoDevToolWindowFactory.Companion.sendToSketchToolWindow(project, ChatActionType.SKETCH) { ui, _ ->
61-
AutoSketchMode.getInstance(project).enableComposerMode()
60+
AutoSketchMode.Companion.getInstance(project).enableComposerMode()
6261
ui.sendInput(newPlan)
6362
}
6463
}
@@ -76,4 +75,4 @@ class IssueInputViewPanel(
7675
fun dispose() {
7776
textArea = null
7877
}
79-
}
78+
}

core/src/main/kotlin/cc/unitmesh/devti/gui/planner/LoadingPanel.kt renamed to core/src/main/kotlin/cc/unitmesh/devti/gui/planner/PlanLoadingPanel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import javax.swing.plaf.basic.BasicProgressBarUI
1414
import javax.swing.text.BadLocationException
1515
import javax.swing.text.StyleConstants
1616

17-
class LoadingPanel(val project: Project) : JPanel() {
17+
class PlanLoadingPanel(val project: Project) : JPanel() {
1818
private val loadingMessages: MutableList<String> = mutableListOf<String>(
1919
"🤔 Analyzing your request...",
2020
"💡 Generating a plan...",

core/src/main/kotlin/cc/unitmesh/devti/gui/snippet/AutoDevSaveFileAction.kt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,18 @@ class AutoDevSaveFileAction : AnAction(AutoDevBundle.message("autodev.save.actio
3737

3838
val dialog: FileSaverDialog = FileChooserFactory.getInstance().createSaveFileDialog(descriptor, project)
3939
val dir = project.baseDir
40-
val virtualFileWrapper: VirtualFileWrapper? = dialog.save(dir, virtualFile.name)
41-
42-
if (virtualFileWrapper != null) {
43-
try {
44-
ApplicationManager.getApplication().runWriteAction {
45-
val file = virtualFileWrapper.file
46-
file.writeText(content)
47-
48-
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)
49-
AutoDevNotifications.notify(project, "File saved successfully to: ${file.absolutePath}")
50-
}
51-
} catch (ex: IOException) {
52-
AutoDevNotifications.error(project, "Failed to save file: ${ex.message}")
40+
val virtualFileWrapper: VirtualFileWrapper = dialog.save(dir, virtualFile.name) ?: return
41+
42+
try {
43+
ApplicationManager.getApplication().runWriteAction {
44+
val file = virtualFileWrapper.file
45+
file.writeText(content)
46+
47+
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)
48+
AutoDevNotifications.notify(project, "File saved successfully to: ${file.absolutePath}")
5349
}
50+
} catch (ex: IOException) {
51+
AutoDevNotifications.error(project, "Failed to save file: ${ex.message}")
5452
}
5553
}
5654
}

0 commit comments

Comments
 (0)