GradleScriptNotifications: suggest to import and link gradle project
This commit is contained in:
+25
-5
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType
|
|||||||
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsLocator.NotificationKind.*
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsLocator.NotificationKind.*
|
||||||
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager
|
||||||
|
import org.jetbrains.kotlin.idea.scripting.gradle.roots.Imported
|
||||||
|
|
||||||
class MissingGradleScriptConfigurationNotificationProvider(private val project: Project) :
|
class MissingGradleScriptConfigurationNotificationProvider(private val project: Project) :
|
||||||
EditorNotifications.Provider<EditorNotificationPanel>() {
|
EditorNotifications.Provider<EditorNotificationPanel>() {
|
||||||
@@ -32,25 +33,40 @@ class MissingGradleScriptConfigurationNotificationProvider(private val project:
|
|||||||
outsideAnything -> EditorNotificationPanel().apply {
|
outsideAnything -> EditorNotificationPanel().apply {
|
||||||
text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text"))
|
text(KotlinIdeaGradleBundle.message("notification.outsideAnything.text"))
|
||||||
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
|
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
|
||||||
runPartialGradleImport(project)
|
linkProject(project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wasNotImportedAfterCreation -> EditorNotificationPanel().apply {
|
wasNotImportedAfterCreation -> EditorNotificationPanel().apply {
|
||||||
text(KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.text"))
|
text(KotlinIdeaGradleBundle.message("notification.wasNotImportedAfterCreation.text"))
|
||||||
createActionLabel(getMissingConfigurationActionText()) {
|
createActionLabel(getMissingConfigurationActionText()) {
|
||||||
runPartialGradleImport(project)
|
linkProject(project)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notEvaluatedInLastImport -> EditorNotificationPanel().apply {
|
notEvaluatedInLastImport -> EditorNotificationPanel().apply {
|
||||||
text(KotlinIdeaGradleBundle.message(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.text")))
|
text(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.text"))
|
||||||
|
|
||||||
createActionLabel(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.info")) {
|
// suggest to reimport project if something changed after import
|
||||||
|
val importTs = (scriptUnderRoot.nearest as? Imported)?.data?.importTs
|
||||||
|
if (importTs != null && !scriptUnderRoot.nearest.areRelatedFilesChangedBefore(file, importTs)) {
|
||||||
|
createActionLabel(getMissingConfigurationActionText()) {
|
||||||
|
rootsManager.updateStandaloneScripts {
|
||||||
|
runPartialGradleImport(project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// suggest to choose new gradle project
|
||||||
|
createActionLabel(KotlinIdeaGradleBundle.message("notification.outsideAnything.linkAction")) {
|
||||||
|
linkProject(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
createActionLabel(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.addAsStandaloneAction")) {
|
||||||
rootsManager.updateStandaloneScripts {
|
rootsManager.updateStandaloneScripts {
|
||||||
addStandaloneScript(file.path)
|
addStandaloneScript(file.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contextHelp(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.addAsStandaloneAction"))
|
contextHelp(KotlinIdeaGradleBundle.message("notification.notEvaluatedInLastImport.info"))
|
||||||
}
|
}
|
||||||
standalone -> EditorNotificationPanel().apply {
|
standalone -> EditorNotificationPanel().apply {
|
||||||
text(KotlinIdeaGradleBundle.message("notification.standalone.text"))
|
text(KotlinIdeaGradleBundle.message("notification.standalone.text"))
|
||||||
@@ -64,6 +80,10 @@ class MissingGradleScriptConfigurationNotificationProvider(private val project:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun linkProject(project: Project) {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
private fun EditorNotificationPanel.contextHelp(text: String) {
|
private fun EditorNotificationPanel.contextHelp(text: String) {
|
||||||
val helpIcon = createActionLabel("") {}
|
val helpIcon = createActionLabel("") {}
|
||||||
helpIcon.setIcon(AllIcons.General.ContextHelp)
|
helpIcon.setIcon(AllIcons.General.ContextHelp)
|
||||||
|
|||||||
Reference in New Issue
Block a user