<commit_before>package cn.yiiguxing.plugin.translate.activity

import cn.yiiguxing.plugin.translate.UPDATE_NOTIFICATION_GROUP_ID
import cn.yiiguxing.plugin.translate.message
import cn.yiiguxing.plugin.translate.util.IdeVersion
import cn.yiiguxing.plugin.translate.util.show
import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project

@Suppress("unused")
class IdeaVersionUpgradeNoticeActivity : BaseStartupActivity(true), DumbAware {

    override fun onBeforeRunActivity(project: Project): Boolean {
        return !(IdeVersion.isIde2019_3OrNewer || PropertiesComponent.getInstance()
            .getBoolean(DO_NOT_NOTIFY_AGAIN_PROPERTY, false))
    }

    override fun onRunActivity(project: Project) = showNotification(project)

    private class DoNotShowAgainAction : NotificationAction(message("notification.idea.version.do.not.show.again")) {
        override fun actionPerformed(e: AnActionEvent, notification: Notification) {
            notification.expire()
            PropertiesComponent.getInstance().setValue(DO_NOT_NOTIFY_AGAIN_PROPERTY, true)
        }
    }

    companion object {
        private const val DISPLAY_ID = "Outdated IDE Version"

        private val DO_NOT_NOTIFY_AGAIN_PROPERTY =
            "yii.guxing.translate.IdeaVersionUpgradeNotice.${IdeVersion.buildNumber}.disable"

        private fun showNotification(project: Project) {
            NotificationGroupManager.getInstance()
                .getNotificationGroup(UPDATE_NOTIFICATION_GROUP_ID)
                .createNotification(
                    message("notification.idea.version.title"),
                    message("notification.idea.version"),
                    NotificationType.WARNING
                )
                .addAction(DoNotShowAgainAction())
                .setImportant(true)
                .show(project)<commit_msg>replace deprecated apis<commit_after>package cn.yiiguxing.plugin.translate.activity

import cn.yiiguxing.plugin.translate.UPDATE_NOTIFICATION_GROUP_ID
import cn.yiiguxing.plugin.translate.message
import cn.yiiguxing.plugin.translate.util.IdeVersion
import cn.yiiguxing.plugin.translate.util.show
import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project

@Suppress("unused")
class IdeaVersionUpgradeNoticeActivity : BaseStartupActivity(true), DumbAware {

    override fun onBeforeRunActivity(project: Project): Boolean {
        return !(IdeVersion.isIde2019_3OrNewer || PropertiesComponent.getInstance()
            .getBoolean(DO_NOT_NOTIFY_AGAIN_PROPERTY, false))
    }

    override fun onRunActivity(project: Project) = showNotification(project)

    private class DoNotShowAgainAction : NotificationAction(message("notification.idea.version.do.not.show.again")) {
        override fun actionPerformed(e: AnActionEvent, notification: Notification) {
            notification.expire()
            PropertiesComponent.getInstance().setValue(DO_NOT_NOTIFY_AGAIN_PROPERTY, true)
        }
    }

    companion object {
        private const val DISPLAY_ID = "Outdated IDE Version"

        private val DO_NOT_NOTIFY_AGAIN_PROPERTY =
            "yii.guxing.translate.IdeaVersionUpgradeNotice.${IdeVersion.buildNumber}.disable"

        private fun showNotification(project: Project) {
            NotificationGroupManager.getInstance()
                .getNotificationGroup(UPDATE_NOTIFICATION_GROUP_ID)
                .createNotification(
                    message("notification.idea.version"), NotificationType.WARNING
                )
                .setTitle(message("notification.idea.version.title"))
                .addAction(DoNotShowAgainAction())
                .setImportant(true)
                .show(project)
{'fraction_non_alphanumeric': 0.08137931034482758, 'fraction_numerical': 0.0022988505747126436, 'mean_word_length': 3.6684549356223175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6444714', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1148, 'n_words': 171}