Skip to content

Commit a9467b7

Browse files
authored
Merge pull request #2 from oldme-git/fix/issue#1
fix issue#1
2 parents 5a82b22 + 898cc04 commit a9467b7

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/main/kotlin/com/github/oldmegit/goframehelper/listener/Listener.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.github.oldmegit.goframehelper.listener
22

3+
import com.github.oldmegit.goframehelper.data.Bundle
34
import com.github.oldmegit.goframehelper.gf.Gf
45
import com.github.oldmegit.goframehelper.gf.GfGoMod
56
import com.goide.GoFileType
67
import com.intellij.openapi.project.Project
78
import com.intellij.openapi.vfs.newvfs.BulkFileListener
89
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
10+
import com.intellij.notification.NotificationGroupManager
11+
import com.intellij.notification.NotificationType
912
import java.io.File
1013

1114
class Listener(private val project: Project): BulkFileListener {
@@ -26,10 +29,18 @@ class Listener(private val project: Project): BulkFileListener {
2629
}
2730

2831
val runtime = Runtime.getRuntime()
29-
if (Gf.isApiFile(project, file) && Gf.enableApiWatch(project)) {
30-
runtime.exec(Gf.gfGenCtrl, null, File(project.basePath.toString()))
31-
} else if (Gf.isLogicFile(project, file) && Gf.enableLogicWatch(project)) {
32-
runtime.exec(Gf.gfGenService, null, File(project.basePath.toString()))
32+
try {
33+
if (Gf.isApiFile(project, file) && Gf.enableApiWatch(project)) {
34+
runtime.exec(Gf.gfGenCtrl, null, File(project.basePath.toString()))
35+
} else if (Gf.isLogicFile(project, file) && Gf.enableLogicWatch(project)) {
36+
runtime.exec(Gf.gfGenService, null, File(project.basePath.toString()))
37+
}
38+
} catch (_: Exception) {
39+
val message = Bundle.getMessage("gfExecErrNotify")
40+
NotificationGroupManager.getInstance()
41+
.getNotificationGroup("GoFrame Help Notify")
42+
.createNotification(message, NotificationType.INFORMATION)
43+
.notify(project)
3344
}
3445
}
3546
}

src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<projectConfigurable parentId="tools"
2222
instance="com.github.oldmegit.goframehelper.ui.AppSettingsConfigurable"
2323
key="name"/>
24+
25+
<notificationGroup displayType="BALLOON" id="GoFrame Help Notify" />
2426
</extensions>
2527

2628
<projectListeners>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
name=GoFrame Helper
2-
init=Init GoFrame Helper
2+
init=Init GoFrame Helper
3+
gfExecErrNotify=Please check if gf-cli is available.

0 commit comments

Comments
 (0)