|
|
@@ -0,0 +1,36 @@
|
|
|
+import com.intellij.notification.NotificationGroupManager
|
|
|
+import com.intellij.notification.NotificationType
|
|
|
+import com.intellij.openapi.project.Project
|
|
|
+import com.intellij.openapi.ui.Messages
|
|
|
+import javax.swing.Icon
|
|
|
+import com.intellij.notification.NotificationDisplayType
|
|
|
+
|
|
|
+import com.intellij.notification.NotificationGroup
|
|
|
+
|
|
|
+
|
|
|
+enum class NotifierType {
|
|
|
+ INFO, WARM, ERROR
|
|
|
+}
|
|
|
+
|
|
|
+object NotifierUtil {
|
|
|
+ const val title: String = "提示"
|
|
|
+ private val NOTIFICATION_GROUP =
|
|
|
+ NotificationGroup("Custom Notification Group", NotificationDisplayType.BALLOON, true)
|
|
|
+
|
|
|
+ fun showNotifier(
|
|
|
+ project: Project,
|
|
|
+ content: String,
|
|
|
+ title: String = this.title,
|
|
|
+ type: NotifierType = NotifierType.INFO
|
|
|
+ ) = NOTIFICATION_GROUP
|
|
|
+ .createNotification(title, content, getNotifierByType(type))
|
|
|
+ .notify(project);
|
|
|
+
|
|
|
+ private fun getNotifierByType(type: NotifierType): NotificationType {
|
|
|
+ return when (type) {
|
|
|
+ NotifierType.INFO -> NotificationType.INFORMATION
|
|
|
+ NotifierType.WARM -> NotificationType.WARNING
|
|
|
+ NotifierType.ERROR -> NotificationType.ERROR
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|