Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}
}
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
<docTagParserExtension tagName="type" implementationClass="com.vk.kphpstorm.exphptype.psi.PhpDocVarTagParserEx" order="first" />
</extensions>

<extensions defaultExtensionNs="com.intellij">
<notificationGroup id="kphpstorm.plugin.setup.notification" displayType="BALLOON" toolWindowId="kphp configuration notification"/>
</extensions>

<actions>
<group id="com.vk.kphpstorm" text="KPHPStorm" popup="true" icon="/icons/kphp_logo.svg">
<add-to-group group-id="ToolsMenu" anchor="last"/>
Expand Down