1+ package shop.itbug.fluttercheckversionx.actions.components
2+
3+ import com.intellij.execution.configurations.GeneralCommandLine
4+ import com.intellij.icons.AllIcons
5+ import com.intellij.openapi.actionSystem.AnAction
6+ import com.intellij.openapi.actionSystem.AnActionEvent
7+ import com.intellij.openapi.actionSystem.DefaultActionGroup
8+ import com.intellij.openapi.project.DumbAware
9+ import com.intellij.openapi.project.DumbAwareAction
10+ import shop.itbug.fluttercheckversionx.config.FlutterConfigQuickOpenInCommandDialog
11+ import shop.itbug.fluttercheckversionx.config.FlutterXGlobalConfigService
12+ import shop.itbug.fluttercheckversionx.util.RunUtil
13+
14+ class QuickOpenInActions : DefaultActionGroup (), DumbAware {
15+
16+ override fun getChildren (e : AnActionEvent ? ): Array <out AnAction ?> {
17+ if (e!= null ){
18+ val list = mutableListOf<AnAction >()
19+ val setting = FlutterXGlobalConfigService .getInstance().state
20+ val customOpenIn = setting.quickOpenInCommand
21+ if (customOpenIn.isNotEmpty()) {
22+ customOpenIn.forEach { item ->
23+ val title = item.title
24+ val command = item.command
25+ if (title != null && command != null ) {
26+ list.add(object : DumbAwareAction (title) {
27+ override fun actionPerformed (p0 : AnActionEvent ) {
28+ RunUtil .runOpenInBackground(p0, title) {
29+ GeneralCommandLine (command.split(" " ))
30+ }
31+ }
32+ })
33+ }
34+ }
35+ }
36+ list.add(object : DumbAwareAction (" Add Custom Quick Open In" ," " , AllIcons .General .Add ) {
37+ override fun actionPerformed (e : AnActionEvent ) {
38+ val project = e.project
39+ if (project != null ) {
40+ FlutterConfigQuickOpenInCommandDialog (project).show()
41+ }
42+ }
43+ })
44+ return list.toTypedArray()
45+ }
46+ return super .getChildren(e)
47+ }
48+
49+ }
0 commit comments