Skip to content

Commit 12ee328

Browse files
committed
refactor(run-configuration): improve console view configuration #101
1 parent 30ea1c2 commit 12ee328

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInsRunConfigurationProfileState.kt

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devti.language.run
22

3+
// DONT REMOVE THIS IMPORT
34
import cc.unitmesh.devti.language.compiler.DevInsCompiler
45
import cc.unitmesh.devti.language.psi.DevInFile
56
import cc.unitmesh.devti.llms.LLMProvider
@@ -18,15 +19,19 @@ import com.intellij.execution.process.ProcessTerminatedListener
1819
import com.intellij.execution.runners.ProgramRunner
1920
import com.intellij.execution.ui.ConsoleView
2021
import com.intellij.execution.ui.ConsoleViewContentType
22+
import com.intellij.openapi.actionSystem.ActionManager
23+
import com.intellij.openapi.actionSystem.DefaultActionGroup
2124
import com.intellij.openapi.application.ApplicationManager
2225
import com.intellij.openapi.project.Project
2326
import com.intellij.openapi.vfs.VirtualFileManager
2427
import com.intellij.psi.PsiManager
28+
import com.intellij.ui.components.panels.NonOpaquePanel
2529
import kotlinx.coroutines.launch
2630
import kotlinx.coroutines.runBlocking
27-
// DONT REMOVE THIS IMPORT
28-
import kotlinx.coroutines.flow.collect
31+
import java.awt.BorderLayout
2932
import java.io.OutputStream
33+
import javax.swing.JComponent
34+
import javax.swing.JPanel
3035

3136
open class DevInsRunConfigurationProfileState(
3237
private val myProject: Project,
@@ -38,7 +43,23 @@ open class DevInsRunConfigurationProfileState(
3843
val processHandler: ProcessHandler = createProcessHandler(configuration.name)
3944
ProcessTerminatedListener.attach(processHandler)
4045

41-
val console: ConsoleView = ConsoleViewWrapperBase(ConsoleViewImpl(myProject, true))
46+
val executionConsole = ConsoleViewImpl(myProject, true)
47+
val console = object : ConsoleViewWrapperBase(executionConsole) {
48+
private var myPanel: NonOpaquePanel = NonOpaquePanel(BorderLayout())
49+
50+
init {
51+
val baseComponent = delegate.component
52+
myPanel.add(baseComponent, BorderLayout.CENTER)
53+
54+
val actionGroup = DefaultActionGroup(*executionConsole.createConsoleActions())
55+
val toolbar = ActionManager.getInstance().createActionToolbar("BuildConsole", actionGroup, false)
56+
toolbar.targetComponent = baseComponent
57+
myPanel.add(toolbar.component, BorderLayout.EAST)
58+
}
59+
60+
override fun getComponent(): JComponent = myPanel
61+
}
62+
4263
console.attachToProcess(processHandler)
4364

4465
val file: DevInFile? = lookupDevInsFile(myProject, configuration.getScriptPath())
@@ -96,10 +117,6 @@ open class DevInsRunConfigurationProfileState(
96117

97118
override fun getProcessInput(): OutputStream? = null
98119
override fun getExecutionName(): String = myExecutionName
99-
100-
protected fun closeInput() {
101-
102-
}
103120
}
104121
}
105122
}

0 commit comments

Comments
 (0)