mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2026-03-02 03:39:24 +00:00
Rewrite Gradle script to us Kotlin DSL, code cleanup
This commit is contained in:
@@ -8,9 +8,11 @@ import org.jetbrains.annotations.PropertyKey
|
||||
private const val BUNDLE = "messages.TemplateBundle"
|
||||
|
||||
object TemplateBundle : DynamicBundle(BUNDLE) {
|
||||
|
||||
@JvmStatic
|
||||
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params)
|
||||
|
||||
@JvmStatic
|
||||
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): () -> String = { message(key, *params) }
|
||||
|
||||
}
|
||||
|
||||
@@ -6,18 +6,17 @@ import com.intellij.openapi.components.ServiceManager
|
||||
import org.jetbrains.plugins.template.services.MyApplicationService
|
||||
|
||||
internal class MyDynamicPluginListener : DynamicPluginListener {
|
||||
|
||||
override fun beforePluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
|
||||
ServiceManager.getService(MyApplicationService::class.java)
|
||||
}
|
||||
|
||||
override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
|
||||
println("xx")
|
||||
}
|
||||
override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {}
|
||||
|
||||
override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {}
|
||||
|
||||
override fun checkUnloadPlugin(pluginDescriptor: IdeaPluginDescriptor) {
|
||||
}
|
||||
override fun checkUnloadPlugin(pluginDescriptor: IdeaPluginDescriptor) {}
|
||||
|
||||
override fun pluginUnloaded(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.intellij.openapi.project.ProjectManagerListener
|
||||
import org.jetbrains.plugins.template.services.MyProjectService
|
||||
|
||||
internal class MyProjectManagerListener : ProjectManagerListener {
|
||||
|
||||
override fun projectOpened(project: Project) {
|
||||
project.getService(MyProjectService::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package org.jetbrains.plugins.template.services
|
||||
|
||||
import org.jetbrains.plugins.template.TemplateBundle
|
||||
|
||||
class MyApplicationService {
|
||||
|
||||
init {
|
||||
println("MyApplicationService")
|
||||
println(TemplateBundle.message("applicationService"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.plugins.template.TemplateBundle
|
||||
|
||||
class MyProjectService(project: Project) {
|
||||
|
||||
init {
|
||||
println(TemplateBundle.message("projectService", project.name))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user