|
| 1 | +/* |
| 2 | + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. |
| 3 | + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. |
| 4 | + */ |
| 5 | + |
| 6 | +package org.jetbrains.kotlin.idea.configuration.ui.notifications |
| 7 | + |
| 8 | +import com.intellij.ide.util.PropertiesComponent |
| 9 | +import com.intellij.notification.* |
| 10 | +import com.intellij.openapi.project.Project |
| 11 | +import org.jetbrains.kotlin.idea.KotlinBundle |
| 12 | +import org.jetbrains.kotlin.idea.KotlinPluginVersion |
| 13 | + |
| 14 | + |
| 15 | +private const val NEW_JVM_BACKEND_NOTIFICATION_ID = "New JVM Backend" |
| 16 | +private const val NEW_JVM_BACKEND_WAS_PROMOTED = "new.jvm.backend.notification" |
| 17 | +private const val NEW_JVM_BACKEND_BLOG_POST = "https://blog.jetbrains.com/kotlin/2021/01/jvm-backend-is-in-beta/" |
| 18 | + |
| 19 | +fun notifyNewJVMBackendIfNeeded(project: Project) { |
| 20 | + val propertiesComponent = PropertiesComponent.getInstance() |
| 21 | + if (propertiesComponent.getBoolean(NEW_JVM_BACKEND_WAS_PROMOTED)) return |
| 22 | + val kotlinVersion = KotlinPluginVersion.getCurrent()?.kotlinVersion ?: return |
| 23 | + if (kotlinVersion < "1.4.30" || kotlinVersion >= "1.5.0") return |
| 24 | + |
| 25 | + val notification = Notification( |
| 26 | + NEW_JVM_BACKEND_NOTIFICATION_ID, |
| 27 | + KotlinBundle.message("notification.title.new.jvm.ir.backend"), |
| 28 | + KotlinBundle.message("notification.message.new.jvm.ir.backend"), |
| 29 | + NotificationType.INFORMATION, |
| 30 | + ).apply { |
| 31 | + addAction(BrowseNotificationAction(KotlinBundle.message("notification.action.new.jvm.ir.backend"), NEW_JVM_BACKEND_BLOG_POST)) |
| 32 | + |
| 33 | + isImportant = true |
| 34 | + } |
| 35 | + |
| 36 | + NotificationsConfiguration.getNotificationsConfiguration().register( |
| 37 | + NEW_JVM_BACKEND_NOTIFICATION_ID, |
| 38 | + NotificationDisplayType.STICKY_BALLOON, |
| 39 | + ) |
| 40 | + |
| 41 | + notification.notify(project) |
| 42 | + propertiesComponent.setValue(NEW_JVM_BACKEND_WAS_PROMOTED, true) |
| 43 | +} |
| 44 | + |
0 commit comments