Skip to content

Commit e33c82b

Browse files
committed
feat(toolWindow): add AutoDevPlaner tool window
#223 Add a new tool window `AutoDevPlaner` with left anchor, positioned after the Structure window. Includes a factory class `AutoDevPlanerToolWindowFactory` to manage the window's content and state.
1 parent 4bf75d3 commit e33c82b

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

core/src/223/main/resources/META-INF/autodev-core.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
6565
factoryClass="cc.unitmesh.devti.gui.AutoDevToolWindowFactory"/>
6666

67+
<toolWindow id="AutoDevPlaner"
68+
anchor="left"
69+
order="after Structure"
70+
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
71+
secondary="true"
72+
factoryClass="cc.unitmesh.devti.gui.AutoDevPlanerToolWindowFactory"/>
73+
6774
<notificationGroup id="AutoDev.notify" displayType="STICKY_BALLOON" bundle="messages.AutoDevBundle"
6875
key="name"/>
6976

core/src/233/main/resources/META-INF/autodev-core.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@
6363
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
6464
factoryClass="cc.unitmesh.devti.gui.AutoDevToolWindowFactory"/>
6565

66+
<toolWindow id="AutoDevPlaner"
67+
anchor="left"
68+
order="after Structure"
69+
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT"
70+
secondary="true"
71+
factoryClass="cc.unitmesh.devti.gui.AutoDevPlanerToolWindowFactory"/>
72+
6673
<notificationGroup id="AutoDev.notify" displayType="STICKY_BALLOON" bundle="messages.AutoDevBundle"
6774
key="name"/>
6875

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package cc.unitmesh.devti.gui
2+
3+
import cc.unitmesh.devti.observer.plan.PlanBoard
4+
import com.intellij.openapi.Disposable
5+
import com.intellij.openapi.project.DumbAware
6+
import com.intellij.openapi.project.Project
7+
import com.intellij.openapi.ui.SimpleToolWindowPanel
8+
import com.intellij.openapi.ui.Splittable
9+
import com.intellij.openapi.util.NlsActions
10+
import com.intellij.openapi.wm.ToolWindow
11+
import com.intellij.openapi.wm.ToolWindowFactory
12+
import com.intellij.openapi.wm.ToolWindowManager
13+
import com.intellij.openapi.wm.ex.ToolWindowManagerListener
14+
import java.util.concurrent.atomic.AtomicBoolean
15+
16+
class AutoDevPlanerToolWindowFactory : ToolWindowFactory, ToolWindowManagerListener, DumbAware {
17+
private val orientation = AtomicBoolean(true)
18+
19+
override fun createToolWindowContent(
20+
project: Project,
21+
toolWindow: ToolWindow
22+
) {
23+
val panel = AutoDevPlanerTooWindow(project)
24+
val manager = toolWindow.contentManager
25+
manager.addContent(manager.factory.createContent(panel, null, false).apply { isCloseable = false })
26+
project.messageBus.connect(manager).subscribe(ToolWindowManagerListener.TOPIC, this)
27+
}
28+
29+
override fun stateChanged(manager: ToolWindowManager) {
30+
val window = manager.getToolWindow(PlANNER_ID) ?: return
31+
if (window.isDisposed) return
32+
val vertical = !window.anchor.isHorizontal
33+
if (vertical != orientation.getAndSet(vertical)) {
34+
for (content in window.contentManager.contents) {
35+
val splittable = content?.component as? Splittable
36+
splittable?.orientation = vertical
37+
}
38+
}
39+
}
40+
41+
companion object {
42+
private val PlANNER_ID = "AutoDevPlaner"
43+
}
44+
}
45+
46+
class AutoDevPlanerTooWindow(val project: Project) : SimpleToolWindowPanel(true, true), Disposable {
47+
override fun getName(): @NlsActions.ActionText String? = "AutoDev Planer"
48+
val planBoard: PlanBoard = project.getService(PlanBoard::class.java)
49+
50+
init {
51+
add(planBoard.planSketch)
52+
}
53+
54+
override fun dispose() {
55+
56+
}
57+
}

0 commit comments

Comments
 (0)