rewrite Java classes to Kotlin

pull/5/head
Jakub Chrzanowski 4 years ago
parent 3885874e7b
commit 3f83267e99

@ -1,46 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 hsz Jakub Chrzanowski <jakub@hsz.mobi>
*
* 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);
}
}

@ -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) {
}
}

@ -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);
}
}

@ -1,7 +0,0 @@
package org.jetbrains.plugins.template.services;
public class MyApplicationService {
public MyApplicationService() {
System.out.println("MyApplicationService");
}
}

@ -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()));
}
}

@ -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) }
}

@ -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) {}
}

@ -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)
}
}

@ -0,0 +1,7 @@
package org.jetbrains.plugins.template.services
class MyApplicationService {
init {
println("MyApplicationService")
}
}

@ -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))
}
}
Loading…
Cancel
Save