Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.github.oldmegit.goframehelper.listener

import com.github.oldmegit.goframehelper.data.Bundle
import com.github.oldmegit.goframehelper.gf.Gf
import com.github.oldmegit.goframehelper.gf.GfGoMod
import com.goide.GoFileType
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import java.io.File

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

val runtime = Runtime.getRuntime()
if (Gf.isApiFile(project, file) && Gf.enableApiWatch(project)) {
runtime.exec(Gf.gfGenCtrl, null, File(project.basePath.toString()))
} else if (Gf.isLogicFile(project, file) && Gf.enableLogicWatch(project)) {
runtime.exec(Gf.gfGenService, null, File(project.basePath.toString()))
try {
if (Gf.isApiFile(project, file) && Gf.enableApiWatch(project)) {
runtime.exec(Gf.gfGenCtrl, null, File(project.basePath.toString()))
} else if (Gf.isLogicFile(project, file) && Gf.enableLogicWatch(project)) {
runtime.exec(Gf.gfGenService, null, File(project.basePath.toString()))
}
} catch (_: Exception) {
val message = Bundle.getMessage("gfExecErrNotify")
NotificationGroupManager.getInstance()
.getNotificationGroup("GoFrame Help Notify")
.createNotification(message, NotificationType.INFORMATION)
.notify(project)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<projectConfigurable parentId="tools"
instance="com.github.oldmegit.goframehelper.ui.AppSettingsConfigurable"
key="name"/>

<notificationGroup displayType="BALLOON" id="GoFrame Help Notify" />
</extensions>

<projectListeners>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/message/GoFrameHelperBundle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name=GoFrame Helper
init=Init GoFrame Helper
init=Init GoFrame Helper
gfExecErrNotify=Please check if gf-cli is available.