-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBalloonNotificationService.kt
More file actions
40 lines (36 loc) · 1.34 KB
/
BalloonNotificationService.kt
File metadata and controls
40 lines (36 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.github.surpsg.diffcoverage.services.notifications
import com.github.surpsg.diffcoverage.DiffCoverageBundle
import com.github.surpsg.diffcoverage.properties.PLUGIN_NAME
import com.intellij.notification.NotificationGroup
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationListener
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
@Service
class BalloonNotificationService(private val project: Project) {
fun notify(
title: String = DiffCoverageBundle.message(PLUGIN_NAME),
notificationType: NotificationType = NotificationType.INFORMATION,
notificationListener: NotificationListener? = null,
message: String,
silent: Boolean = false
) {
if (silent) {
return
}
Notifications.Bus.notify(
getNotificationGroup().createNotification(
title,
message,
notificationType,
notificationListener
),
project
)
}
private fun getNotificationGroup(): NotificationGroup {
return NotificationGroupManager.getInstance().getNotificationGroup("diff.coverage.notification")
}
}