diff --git a/src/main/java/org/jetbrains/plugins/template/TemplateBundle.java b/src/main/java/org/jetbrains/plugins/template/TemplateBundle.java deleted file mode 100644 index 20ba1fd..0000000 --- a/src/main/java/org/jetbrains/plugins/template/TemplateBundle.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018 hsz Jakub Chrzanowski - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.jetbrains.plugins.template; - -import com.intellij.DynamicBundle; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.PropertyKey; - -public class TemplateBundle extends DynamicBundle { - @NonNls - public static final String BUNDLE = "messages.TemplateBundle"; - - private static final TemplateBundle INSTANCE = new TemplateBundle(); - - private TemplateBundle() { - super(BUNDLE); - } - - @NotNull - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { - return INSTANCE.getMessage(key, params); - } -} diff --git a/src/main/java/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.java b/src/main/java/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.java deleted file mode 100644 index 1ea1dc9..0000000 --- a/src/main/java/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.jetbrains.plugins.template.listeners; - -import com.intellij.ide.plugins.CannotUnloadPluginException; -import com.intellij.ide.plugins.DynamicPluginListener; -import com.intellij.ide.plugins.IdeaPluginDescriptor; -import com.intellij.openapi.components.ServiceManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.template.services.MyApplicationService; - -class MyDynamicPluginListener implements DynamicPluginListener { - @Override - public void beforePluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) { - ServiceManager.getService(MyApplicationService.class); - } - - @Override - public void pluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) { - System.out.println("xx"); - } - - @Override - public void beforePluginUnload(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { - - } - - @Override - public void checkUnloadPlugin(@NotNull IdeaPluginDescriptor pluginDescriptor) throws CannotUnloadPluginException { - - } - - @Override - public void pluginUnloaded(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { - - } -} diff --git a/src/main/java/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.java b/src/main/java/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.java deleted file mode 100644 index 07cd73e..0000000 --- a/src/main/java/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.plugins.template.listeners; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManagerListener; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.template.services.MyProjectService; - -class MyProjectManagerListener implements ProjectManagerListener { - @Override - public void projectOpened(@NotNull Project project) { - project.getService(MyProjectService.class); - } -} diff --git a/src/main/java/org/jetbrains/plugins/template/services/MyApplicationService.java b/src/main/java/org/jetbrains/plugins/template/services/MyApplicationService.java deleted file mode 100644 index 9c6bc08..0000000 --- a/src/main/java/org/jetbrains/plugins/template/services/MyApplicationService.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.jetbrains.plugins.template.services; - -public class MyApplicationService { - public MyApplicationService() { - System.out.println("MyApplicationService"); - } -} diff --git a/src/main/java/org/jetbrains/plugins/template/services/MyProjectService.java b/src/main/java/org/jetbrains/plugins/template/services/MyProjectService.java deleted file mode 100644 index 4068d22..0000000 --- a/src/main/java/org/jetbrains/plugins/template/services/MyProjectService.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.plugins.template.services; - -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.template.TemplateBundle; - -public class MyProjectService { - public MyProjectService(@NotNull Project project) { - System.out.println(TemplateBundle.message("projectService", project.getName())); - } -} diff --git a/src/main/kotlin/org/jetbrains/plugins/template/TemplateBundle.kt b/src/main/kotlin/org/jetbrains/plugins/template/TemplateBundle.kt new file mode 100644 index 0000000..6470a74 --- /dev/null +++ b/src/main/kotlin/org/jetbrains/plugins/template/TemplateBundle.kt @@ -0,0 +1,16 @@ +package org.jetbrains.plugins.template + +import com.intellij.DynamicBundle +import org.jetbrains.annotations.NonNls +import org.jetbrains.annotations.PropertyKey + +@NonNls +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) } +} diff --git a/src/main/kotlin/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.kt b/src/main/kotlin/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.kt new file mode 100644 index 0000000..cf0a150 --- /dev/null +++ b/src/main/kotlin/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.kt @@ -0,0 +1,23 @@ +package org.jetbrains.plugins.template.listeners + +import com.intellij.ide.plugins.DynamicPluginListener +import com.intellij.ide.plugins.IdeaPluginDescriptor +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 beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {} + + override fun checkUnloadPlugin(pluginDescriptor: IdeaPluginDescriptor) { + } + + override fun pluginUnloaded(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {} +} diff --git a/src/main/kotlin/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.kt b/src/main/kotlin/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.kt new file mode 100644 index 0000000..b15bd14 --- /dev/null +++ b/src/main/kotlin/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.kt @@ -0,0 +1,11 @@ +package org.jetbrains.plugins.template.listeners + +import com.intellij.openapi.project.Project +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) + } +} diff --git a/src/main/kotlin/org/jetbrains/plugins/template/services/MyApplicationService.kt b/src/main/kotlin/org/jetbrains/plugins/template/services/MyApplicationService.kt new file mode 100644 index 0000000..89a62e9 --- /dev/null +++ b/src/main/kotlin/org/jetbrains/plugins/template/services/MyApplicationService.kt @@ -0,0 +1,7 @@ +package org.jetbrains.plugins.template.services + +class MyApplicationService { + init { + println("MyApplicationService") + } +} diff --git a/src/main/kotlin/org/jetbrains/plugins/template/services/MyProjectService.kt b/src/main/kotlin/org/jetbrains/plugins/template/services/MyProjectService.kt new file mode 100644 index 0000000..f0289ad --- /dev/null +++ b/src/main/kotlin/org/jetbrains/plugins/template/services/MyProjectService.kt @@ -0,0 +1,10 @@ +package org.jetbrains.plugins.template.services + +import com.intellij.openapi.project.Project +import org.jetbrains.plugins.template.TemplateBundle + +class MyProjectService(project: Project) { + init { + println(TemplateBundle.message("projectService", project.name)) + } +}