1
1
package com.varabyte.kobweb.intellij.startup
2
2
3
3
import com.intellij.notification.NotificationType
4
- import com.intellij.openapi.actionSystem.ActionManager
5
- import com.intellij.openapi.actionSystem.ActionPlaces
6
- import com.intellij.openapi.actionSystem.PlatformDataKeys
7
- import com.intellij.openapi.actionSystem.ex.ActionUtil
8
4
import com.intellij.openapi.components.service
9
- import com.intellij.openapi.externalSystem.action.RefreshAllExternalProjectsAction
5
+ import com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTracker
10
6
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataImportListener
11
7
import com.intellij.openapi.project.Project
12
8
import com.intellij.openapi.project.modules
@@ -50,7 +46,7 @@ private fun Project.hasAnyKobwebDependency(): Boolean {
50
46
class KobwebPostStartupProjectActivity : ProjectActivity {
51
47
private class ImportListener (
52
48
private val project : Project ,
53
- private val syncRequestedNotification : KobwebNotificationHandle ?
49
+ private val syncRequestedNotification : KobwebNotificationHandle ? ,
54
50
) : ProjectDataImportListener {
55
51
override fun onImportStarted (projectPath : String? ) {
56
52
// If an import is kicked off in an indirect way, we should still dismiss the sync popup.
@@ -74,17 +70,13 @@ class KobwebPostStartupProjectActivity : ProjectActivity {
74
70
project.kobwebPluginState = KobwebPluginState .UNINITIALIZED
75
71
}
76
72
77
- val refreshProjectAction = ActionManager .getInstance().getAction(" ExternalSystem.RefreshAllProjects" ) as ? RefreshAllExternalProjectsAction
78
- val syncRequestedNotification = if (refreshProjectAction != null && project.kobwebPluginState == KobwebPluginState .UNINITIALIZED ) {
73
+ val syncRequestedNotification = if (project.kobwebPluginState == KobwebPluginState .UNINITIALIZED ) {
79
74
KobwebNotifier .Builder (" The Kobweb plugin requires a one-time sync to enable functionality." )
80
75
.type(NotificationType .WARNING )
81
76
.addAction(" Sync Project" ) {
82
- ActionUtil .invokeAction(refreshProjectAction, { dataId ->
83
- when {
84
- PlatformDataKeys .PROJECT .`is `(dataId) -> project
85
- else -> null
86
- }
87
- }, ActionPlaces .NOTIFICATION , null , null )
77
+ val tracker = ExternalSystemProjectTracker .getInstance(project)
78
+ tracker.markDirtyAllProjects()
79
+ tracker.scheduleProjectRefresh()
88
80
}
89
81
.notify(project)
90
82
} else null
0 commit comments