Skip to content

Commit be8de8c

Browse files
committed
completion create file tree action
1 parent d2cd989 commit be8de8c

4 files changed

Lines changed: 41 additions & 24 deletions

File tree

resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<actions>
3030
<!-- Add your actions here -->
31-
<action id="com.dengzii.plugin.auc.gen" class="com.dengzii.plugin.auc.AucFrameGen" text="AucFrameGenerator"
31+
<action id="com.dengzii.plugin.auc.gen" class="com.dengzii.plugin.auc.AucFrameGenAction" text="AucFrameGenerator"
3232
description="AucFrameGenerator">
3333
<add-to-group group-id="ProjectViewPopupMenu" anchor="first"/>
3434
</action>

src/com/dengzii/plugin/auc/AucFrameGen.kt renamed to src/com/dengzii/plugin/auc/AucFrameGenAction.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@ package com.dengzii.plugin.auc
22

33
import com.intellij.openapi.actionSystem.AnAction
44
import com.intellij.openapi.actionSystem.AnActionEvent
5-
import com.intellij.openapi.command.WriteCommandAction
65

76
/**
87
* <pre>
98
* author : dengzi
109
* e-mail : denua@foxmail.com
11-
* github : https://github.com/MrDenua
10+
* github : https://github.com/dengzii
1211
* time : 2019/12/31
1312
* desc :
1413
</pre> *
1514
*/
16-
class AucFrameGen : AnAction() {
15+
class AucFrameGenAction : AnAction() {
1716
override fun actionPerformed(e: AnActionEvent) {
1817
val kit = PluginKit.get(e)
1918
if (!kit.isProjectValid()) {
2019
return
2120
}
22-
WriteCommandAction.writeCommandAction(kit.project).run(FileWriteAction(kit))
21+
FileWriteCommand.startAction(kit)
2322
}
2423

2524
}

src/com/dengzii/plugin/auc/FileWriteAction.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.dengzii.plugin.auc
2+
3+
import com.intellij.openapi.command.WriteCommandAction
4+
import com.intellij.util.ThrowableRunnable
5+
6+
/**
7+
* <pre>
8+
* author : dengzi
9+
* e-mail : denua@foxmail.com
10+
* github : https://github.com/dengzii
11+
* time : 2019/12/31
12+
* desc :
13+
* </pre>
14+
*/
15+
class FileWriteCommand(private var kit: PluginKit) : ThrowableRunnable<RuntimeException> {
16+
17+
companion object {
18+
fun startAction(kit: PluginKit) {
19+
WriteCommandAction.writeCommandAction(kit.project).run(FileWriteCommand(kit))
20+
}
21+
}
22+
23+
override fun run() {
24+
25+
val current = kit.getVirtualFile() ?: return
26+
if (!current.isDirectory) {
27+
return
28+
}
29+
AucTemplate.APP.forEach {
30+
if (it.isDir) {
31+
kit.createDir(it.getPath())
32+
} else {
33+
kit.createFile(it.getPath())
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)