Skip to content

Commit

Permalink
Merge pull request #112 from SchweinchenFuntik/kotlin_1.4
Browse files Browse the repository at this point in the history
added support Kotlin 1.4
  • Loading branch information
SchweinchenFuntik authored Aug 26, 2020
2 parents 73fddd0 + 54a4aa4 commit e2258fb
Show file tree
Hide file tree
Showing 21 changed files with 274 additions and 158 deletions.
34 changes: 0 additions & 34 deletions build.gradle

This file was deleted.

46 changes: 46 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import org.jetbrains.intellij.tasks.RunIdeTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.tasks.PatchPluginXmlTask
import org.jetbrains.intellij.tasks.PublishTask

plugins {
idea apply true
java
kotlin("jvm") version "1.4.0"
id("org.jetbrains.intellij") version "0.4.21"
}

group = "no.tornado"
version = "1.7.20"

val publishUsername: String by rootProject.extra
val publishPassword: String by rootProject.extra

repositories {
mavenCentral()
}

intellij {
version = "2020.2"
//updateSinceUntilBuild = false
setPlugins("java", "properties", "org.jetbrains.kotlin:1.4.0-release-IJ2020.2-1")
}

tasks {
// withType<PatchPluginXmlTask> { }

withType<PublishTask> {
username(publishUsername)
password(publishPassword)
}

withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}

withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
publishUsername="REPLACE_WITH_USERNAME"
publishPassword="REPLACE_WITH_PASSWORD"

gradleVersion=4.10.2
gradleVersion=6.5
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
109 changes: 0 additions & 109 deletions src/main/java/no/tornado/tornadofx/idea/TornadoFXConfigurable.java

This file was deleted.

72 changes: 72 additions & 0 deletions src/main/kotlin/no/tornado/tornadofx/idea/TornadoFXConfigurable.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package no.tornado.tornadofx.idea

import com.intellij.openapi.options.SearchableConfigurable
import com.intellij.ui.HyperlinkAdapter
import com.intellij.ui.HyperlinkLabel
import java.awt.Desktop
import java.io.IOException
import java.net.URI
import javax.swing.JCheckBox
import javax.swing.JComponent
import javax.swing.JPanel
import javax.swing.event.HyperlinkEvent

class TornadoFXConfigurable : SearchableConfigurable {
private val id = "preferences.TornadoFX"
private val displayName = "TornadoFX"
private val settings by lazy { TornadoFXSettings.getInstance() }
private var ui: ConfigUI? = null

override fun createComponent(): JComponent? = ui?.mainPanel ?: ConfigUI().also { ui = it }.mainPanel

override fun isModified(): Boolean = ui?.isModified(settings) ?: false

override fun apply() {
ui?.apply(settings)
}

override fun getDisplayName(): String = displayName

override fun getId(): String = id

override fun getHelpTopic(): String? = id

override fun disposeUIResources() {
ui = null
}

override fun reset() {
ui?.reset(settings)
}

class ConfigUI {
internal var mainPanel: JPanel? = null
private var alternativePropertySyntaxCheckbox: JCheckBox? = null
private var propertySyntaxLink: HyperlinkLabel? = null

fun reset(settings: TornadoFXSettings) {
alternativePropertySyntaxCheckbox!!.isSelected = settings.alternativePropertySyntax
}

fun apply(settings: TornadoFXSettings) {
settings.alternativePropertySyntax = alternativePropertySyntaxCheckbox!!.isSelected
}

fun isModified(settings: TornadoFXSettings): Boolean {
return settings.alternativePropertySyntax != alternativePropertySyntaxCheckbox!!.isSelected
}

init {
propertySyntaxLink!!.setHyperlinkText("More")
propertySyntaxLink!!.addHyperlinkListener(object : HyperlinkAdapter() {
override fun hyperlinkActivated(e: HyperlinkEvent) {
try {
Desktop.getDesktop().browse(URI.create("https://edvin.gitbooks.io/tornadofx-guide/content/part2/Property%20Delegates.html#alternative-property-syntax"))
} catch (e1: IOException) {
e1.printStackTrace()
}
}
})
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package no.tornado.tornadofx.idea.configurations

import com.intellij.execution.actions.ConfigurationContext
import com.intellij.execution.actions.LazyRunConfigurationProducer
import com.intellij.execution.actions.RunConfigurationProducer
import com.intellij.execution.configurations.ConfigurationFactory
import com.intellij.execution.configurations.runConfigurationType
import com.intellij.openapi.util.Ref
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElement
Expand All @@ -13,7 +16,14 @@ import org.jetbrains.kotlin.idea.refactoring.memberInfo.qualifiedClassNameForRen
import org.jetbrains.kotlin.idea.search.allScope
import org.jetbrains.kotlin.psi.KtClass

class TornadoFXRunConfigurationProducer : RunConfigurationProducer<TornadoFXConfiguration>(TornadoFXConfigurationType()){
class TornadoFXRunConfigurationProducer : LazyRunConfigurationProducer<TornadoFXConfiguration>() {
private val tornadoFXConfigurationType by lazy { runConfigurationType<TornadoFXConfigurationType>() }


override fun getConfigurationFactory(): ConfigurationFactory {
return tornadoFXConfigurationType.configurationFactories[0]
}

override fun setupConfigurationFromContext(configuration: TornadoFXConfiguration, context: ConfigurationContext, sourceElement: Ref<PsiElement>): Boolean {
val ktClass = sourceElement.get() as? KtClass ?: return false
val psiFacade = JavaPsiFacade.getInstance(ktClass.project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.psi.codeStyle.PackageEntry
import com.jetbrains.rd.util.string.print
import org.jetbrains.kotlin.daemon.common.experimental.log
import org.jetbrains.kotlin.idea.core.formatter.KotlinPackageEntry
import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings
import org.jetbrains.kotlin.idea.util.projectStructure.allModules

Expand Down Expand Up @@ -43,9 +46,12 @@ class TornadoFXFacet(
val codeStyleSettings = CodeStyle.getDefaultSettings()
val settings = codeStyleSettings.kotlinCustomSettings
if (!settings.PACKAGES_TO_USE_STAR_IMPORTS.contains("tornadofx")) {
settings.PACKAGES_TO_USE_STAR_IMPORTS.addEntry(PackageEntry(false, "tornadofx", false))
// PackageEntry(false, "tornadofx", false)
val entry = KotlinPackageEntry("tornadofx", false)
settings.PACKAGES_TO_USE_STAR_IMPORTS.addEntry(entry)
}
} catch (ignored: Exception) {
ignored.printStackTrace()
}
}
}
12 changes: 9 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<idea-plugin>
<id>no.tornado.tornadofx.idea</id>
<name>TornadoFX</name>
<version>1.7.18</version>
<version>1.7.20</version>
<vendor email="[email protected]" url="https://www.syse.no">SYSE</vendor>
<description>Run configurations, templates, actions and intentions for TornadoFX.</description>
<description><![CDATA[
Support for TornadoFX - the JavaFX framework for Kotlin
]]></description>

<change-notes><![CDATA[
<h4>1.7.20 2020-08-24</h4>
<ul>
<li>Support kotlin 1.4</li>
</ul>
<h4>1.7.17.1 2018-10-01</h4>
<ul>
<li>General bug fix and compatibility release</li>
Expand All @@ -23,7 +28,7 @@
<depends>org.jetbrains.kotlin</depends>
<depends>com.intellij.properties</depends>

<idea-version since-build="201" />
<idea-version since-build="202" />

<extensions defaultExtensionNs="com.intellij">

Expand Down Expand Up @@ -77,7 +82,7 @@
<internalFileTemplate name="TornadoFX FXML View"/>
<internalFileTemplate name="TornadoFX FXML ViewResource"/>

<applicationService serviceInterface="no.tornado.tornadofx.idea.TornadoFXSettings" serviceImplementation="no.tornado.tornadofx.idea.TornadoFXSettings"/>
<applicationService serviceImplementation="no.tornado.tornadofx.idea.TornadoFXSettings"/>
<applicationConfigurable instance="no.tornado.tornadofx.idea.TornadoFXConfigurable" groupId="language" id="preferences.TornadoFX"/>
<annotator language="kotlin" implementationClass="no.tornado.tornadofx.idea.annotator.CSSColorAnnotator" order="first"/>
<annotator language="kotlin" implementationClass="no.tornado.tornadofx.idea.annotator.CSSBoxAnnotator" order="first"/>
Expand Down Expand Up @@ -107,6 +112,7 @@
description="Generate a new TornadoFX View" icon="/icons/action.png">
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="Kotlin.NewFile"/>
</action>
<!--suppress PluginXmlCapitalization -->
<action id="injectResource" class="no.tornado.tornadofx.idea.actions.InjectComponentAction" text="Inject TornadoFX Component"
description="Inject TornadoFX Component into the current Component" icon="/icons/action.png">
<add-to-group group-id="GenerateGroup" anchor="last"/>
Expand Down
Loading

0 comments on commit e2258fb

Please sign in to comment.