File tree Expand file tree Collapse file tree 7 files changed +53
-0
lines changed
223/main/resources/META-INF
233/main/resources/META-INF Expand file tree Collapse file tree 7 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 371
371
<action id =" AutoDev.ToolWindow.Snippet.RunDevIns"
372
372
icon =" cc.unitmesh.devti.AutoDevIcons.Run"
373
373
class =" cc.unitmesh.devti.gui.snippet.AutoDevRunAction" />
374
+ <action id =" AutoDev.ToolWindow.Snippet.SaveFile"
375
+ icon =" cc.unitmesh.devti.AutoDevIcons.SaveFile"
376
+ class =" cc.unitmesh.devti.gui.snippet.AutoDevSaveFileAction" />
374
377
</group >
375
378
376
379
<group id =" AutoDev.ToolWindow.Chat.TitleActions" >
Original file line number Diff line number Diff line change 375
375
<action id =" AutoDev.ToolWindow.Snippet.RunDevIns"
376
376
icon =" cc.unitmesh.devti.AutoDevIcons.Run"
377
377
class =" cc.unitmesh.devti.gui.snippet.AutoDevRunAction" />
378
+ <action id =" AutoDev.ToolWindow.Snippet.SaveFile"
379
+ icon =" cc.unitmesh.devti.AutoDevIcons.SaveFile"
380
+ class =" cc.unitmesh.devti.gui.snippet.AutoDevSaveFileAction" />
378
381
</group >
379
382
380
383
<group id =" AutoDev.ToolWindow.Chat.TitleActions" >
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ object AutoDevIcons {
41
41
@JvmField
42
42
val Terminal : Icon = IconLoader .getIcon(" /icons/terminal.svg" , AutoDevIcons ::class .java)
43
43
44
+ @JvmField
45
+ val SaveFile : Icon = IconLoader .getIcon(" /icons/save-file.svg" , AutoDevIcons ::class .java)
46
+
44
47
@JvmField
45
48
val Stop : Icon = IconLoader .getIcon(" /icons/stop.svg" , AutoDevIcons ::class .java)
46
49
Original file line number Diff line number Diff line change
1
+ package cc.unitmesh.devti.gui.snippet
2
+
3
+ import cc.unitmesh.devti.AutoDevBundle
4
+ import com.intellij.openapi.actionSystem.ActionUpdateThread
5
+ import com.intellij.openapi.actionSystem.AnAction
6
+ import com.intellij.openapi.actionSystem.AnActionEvent
7
+ import com.intellij.openapi.actionSystem.CommonDataKeys
8
+ import com.intellij.psi.PsiElement
9
+ import com.intellij.psi.PsiManager
10
+ import com.intellij.refactoring.copy.CopyHandler
11
+
12
+ class AutoDevSaveFileAction : AnAction (AutoDevBundle .message("autodev.save.action")) {
13
+ override fun getActionUpdateThread (): ActionUpdateThread = ActionUpdateThread .BGT
14
+
15
+ override fun update (e : AnActionEvent ) {
16
+ val project = e.project
17
+ val virtualFile = project?.let { e.getData(CommonDataKeys .VIRTUAL_FILE ) }
18
+ e.presentation.isEnabled = virtualFile != null
19
+ }
20
+
21
+ override fun actionPerformed (e : AnActionEvent ) {
22
+ val project = e.project ? : return
23
+ var virtualFile = e.getData(CommonDataKeys .VIRTUAL_FILE ) ? : return
24
+ val element: PsiElement ? = PsiManager .getInstance(project).findFile(virtualFile)
25
+ if (element == null ) return
26
+ CopyHandler .doCopy(arrayOf<PsiElement ?>(element.containingFile), null )
27
+ }
28
+ }
Original file line number Diff line number Diff line change @@ -175,3 +175,4 @@ sketch.terminal.send.chat=Send to chat
175
175
sketch.terminal.popup =Popup Terminal
176
176
autodev.insert.action =Insert to Editor
177
177
autodev.copy.action =Copy
178
+ autodev.save.action =Save File
Original file line number Diff line number Diff line change @@ -175,3 +175,4 @@ sketch.terminal.send.chat=Send to chat
175
175
sketch.terminal.popup =Popup Terminal
176
176
autodev.insert.action =Insert to Editor
177
177
autodev.copy.action =Copy
178
+ autodev.save.action =Save File
You can’t perform that action at this time.
0 commit comments