From 9df2a8ef6944e612fa2d57d5d82258ecab52c736 Mon Sep 17 00:00:00 2001 From: Richardas Kuchinskas Date: Thu, 9 Nov 2023 20:07:11 +0300 Subject: [PATCH 1/4] created notification prototype --- .../configuration/KphpStormStartupActivity.kt | 43 ++++++++++++++++++- src/main/resources/META-INF/plugin.xml | 4 ++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt index f1721547..478e5a11 100644 --- a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt +++ b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt @@ -1,5 +1,8 @@ package com.vk.kphpstorm.configuration +import com.intellij.ide.util.PropertiesComponent +import com.intellij.notification.* +import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.openapi.startup.ProjectActivity @@ -20,7 +23,45 @@ class KphpStormStartupActivity : ProjectActivity { } private fun showSetupDialog(project: Project) { - if (!KphpStormConfiguration.wasSetupForProject(project) && KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)) + if (!KphpStormConfiguration.wasSetupForProject(project) && KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)){ SetupPluginForProjectDialog(project).show() + }else{ + showNotification(project) + } + } + + private fun showNotification(project: Project) { + val notification = NotificationGroupManager.getInstance() + .getNotificationGroup("kphpstorm.plugin.setup.notification") + .createNotification("Prototype notification", NotificationType.INFORMATION) + + val propertiesComponent = PropertiesComponent.getInstance(project) + if (propertiesComponent.getBoolean("DoNotShowAgain", false)) { + return + } + + if (propertiesComponent.getBoolean("isKphpProject", false)) { + return + } + + notification.setSuggestionType(true) + + notification.addAction(object : NotificationAction("Setup project as kPHP") { + override fun actionPerformed(e: AnActionEvent, notification: Notification) { + propertiesComponent.setValue("isKphpProject", true) + SetupPluginForProjectDialog(project).show() + notification.expire() + } + }) + + // Turn-off notifications + notification.addAction(object : NotificationAction("Don`t show it again") { + override fun actionPerformed(e: AnActionEvent, notification: Notification) { + propertiesComponent.setValue("DoNotShowAgain", true) + notification.expire() + } + }) + + Notifications.Bus.notify(notification, project) } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 92c9087a..942dee2a 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -106,6 +106,10 @@ + + + + From e1c784536b4a9018b03a61793366dd222fab0ffa Mon Sep 17 00:00:00 2001 From: Richardas Kuchinskas Date: Fri, 10 Nov 2023 15:46:02 +0300 Subject: [PATCH 2/4] refactoring --- .../configuration/KphpStormStartupActivity.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt index 478e5a11..14accb21 100644 --- a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt +++ b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt @@ -33,14 +33,17 @@ class KphpStormStartupActivity : ProjectActivity { private fun showNotification(project: Project) { val notification = NotificationGroupManager.getInstance() .getNotificationGroup("kphpstorm.plugin.setup.notification") - .createNotification("Prototype notification", NotificationType.INFORMATION) + .createNotification("Transforming to kPHP", NotificationType.INFORMATION) + + val dntShow = "DoNotShowAgain" + val isKphp = "isKphpProject" val propertiesComponent = PropertiesComponent.getInstance(project) - if (propertiesComponent.getBoolean("DoNotShowAgain", false)) { + if (propertiesComponent.getBoolean(dntShow, false)) { return } - if (propertiesComponent.getBoolean("isKphpProject", false)) { + if (propertiesComponent.getBoolean(isKphp, false)) { return } @@ -48,7 +51,7 @@ class KphpStormStartupActivity : ProjectActivity { notification.addAction(object : NotificationAction("Setup project as kPHP") { override fun actionPerformed(e: AnActionEvent, notification: Notification) { - propertiesComponent.setValue("isKphpProject", true) + propertiesComponent.setValue(isKphp, true) SetupPluginForProjectDialog(project).show() notification.expire() } @@ -57,7 +60,7 @@ class KphpStormStartupActivity : ProjectActivity { // Turn-off notifications notification.addAction(object : NotificationAction("Don`t show it again") { override fun actionPerformed(e: AnActionEvent, notification: Notification) { - propertiesComponent.setValue("DoNotShowAgain", true) + propertiesComponent.setValue(dntShow, true) notification.expire() } }) From 68cd4b8e913a7c30c4aac72ed6f2fa0a6705d1a2 Mon Sep 17 00:00:00 2001 From: Richardas Kuchinskas Date: Thu, 25 Jan 2024 18:49:18 +0300 Subject: [PATCH 3/4] condition fix --- .../vk/kphpstorm/configuration/KphpStormStartupActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt index 14accb21..a52d0779 100644 --- a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt +++ b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt @@ -26,14 +26,16 @@ class KphpStormStartupActivity : ProjectActivity { if (!KphpStormConfiguration.wasSetupForProject(project) && KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)){ SetupPluginForProjectDialog(project).show() }else{ - showNotification(project) + if(!KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)){ + showNotification(project) + } } } private fun showNotification(project: Project) { val notification = NotificationGroupManager.getInstance() .getNotificationGroup("kphpstorm.plugin.setup.notification") - .createNotification("Transforming to kPHP", NotificationType.INFORMATION) + .createNotification("Transforming to KPHP", NotificationType.INFORMATION) val dntShow = "DoNotShowAgain" val isKphp = "isKphpProject" From e38618083395bf7cbdde841173db1e9efc1d2fb1 Mon Sep 17 00:00:00 2001 From: Richardas Kuchinskas Date: Fri, 26 Jan 2024 13:54:46 +0300 Subject: [PATCH 4/4] fix formatting --- .../vk/kphpstorm/configuration/KphpStormStartupActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt index a52d0779..f99360a4 100644 --- a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt +++ b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt @@ -23,10 +23,10 @@ class KphpStormStartupActivity : ProjectActivity { } private fun showSetupDialog(project: Project) { - if (!KphpStormConfiguration.wasSetupForProject(project) && KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)){ + if (!KphpStormConfiguration.wasSetupForProject(project) && KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)) { SetupPluginForProjectDialog(project).show() - }else{ - if(!KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)){ + } else { + if (!KphpStormConfiguration.seemsLikeProjectIsKphpBased(project)) { showNotification(project) } }