package no.tornado.tornadofx.idea.configurations

import com.intellij.execution.lineMarker.ExecutorAction
import com.intellij.execution.lineMarker.RunLineMarkerContributor
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElement
import com.intellij.util.Function
import no.tornado.tornadofx.idea.FXTools
import no.tornado.tornadofx.idea.PluginIcons
import org.jetbrains.kotlin.idea.search.allScope
import org.jetbrains.kotlin.psi.KtClass

class TornadoFXRunLineMarkerContributor : RunLineMarkerContributor() {
    override fun getInfo(element: PsiElement?): Info? {
        if (element is KtClass) {
            val psiFacade = JavaPsiFacade.getInstance(element.project)
            val psiClass = psiFacade?.findClass(element.fqName.toString(), element.project.allScope()) ?: return null

            val isApp = FXTools.isApp(psiClass)
            val isView = FXTools.isView(psiClass)

            if (isApp || isView) {
                return Info(
                        PluginIcons.ACTION,
                        Function<PsiElement, String> { "Run TornadoFX ${if (isApp) "Application" else "View"}" },
                        *ExecutorAction.getActions(0)
                )
            }
        }
        return null
    }
}
package no.tornado.tornadofx.idea.configurations

import com.intellij.execution.lineMarker.ExecutorAction
import com.intellij.execution.lineMarker.RunLineMarkerContributor
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElement
import com.intellij.util.Function
import no.tornado.tornadofx.idea.FXTools
import no.tornado.tornadofx.idea.PluginIcons
import org.jetbrains.kotlin.idea.search.allScope
import org.jetbrains.kotlin.psi.KtClass

class TornadoFXRunLineMarkerContributor : RunLineMarkerContributor() {
    override fun getInfo(element: PsiElement?): Info? {
        if (element is KtClass) {
            val psiFacade = JavaPsiFacade.getInstance(element.project)
            val psiClass = psiFacade?.findClass(element.fqName.toString(), element.project.allScope()) ?: return null

            val isApp = FXTools.isApp(psiClass)
            val isView = FXTools.isUIComponent(psiClass)

            if (isApp || isView) {
                return Info(
                        PluginIcons.ACTION,
                        Function<PsiElement, String> { "Run TornadoFX ${if (isApp) "Application" else "View"}" },
                        *ExecutorAction.getActions(0)
                )
            }
        }
        return null
    }
}
Support for running Fragment directly
Support for running Fragment directly

edvin/tornadofx-idea-plugin,edvin/tornadofx-idea-plugin,edvin/tornadofx-idea-plugin,edvin/tornadofx-idea-plugin