diff --git a/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt b/src/main/kotlin/com/vk/kphpstorm/configuration/KphpStormStartupActivity.kt index f1721547..f99360a4 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,50 @@ 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)) { + showNotification(project) + } + } + } + + private fun showNotification(project: Project) { + val notification = NotificationGroupManager.getInstance() + .getNotificationGroup("kphpstorm.plugin.setup.notification") + .createNotification("Transforming to KPHP", NotificationType.INFORMATION) + + val dntShow = "DoNotShowAgain" + val isKphp = "isKphpProject" + + val propertiesComponent = PropertiesComponent.getInstance(project) + if (propertiesComponent.getBoolean(dntShow, false)) { + return + } + + if (propertiesComponent.getBoolean(isKphp, false)) { + return + } + + notification.setSuggestionType(true) + + notification.addAction(object : NotificationAction("Setup project as kPHP") { + override fun actionPerformed(e: AnActionEvent, notification: Notification) { + propertiesComponent.setValue(isKphp, 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(dntShow, 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 @@ + + + +