Skip to content

Commit

Permalink
Merge pull request #122 from SchweinchenFuntik/master
Browse files Browse the repository at this point in the history
Support IDEA version 2020.3+
  • Loading branch information
SchweinchenFuntik authored May 10, 2021
2 parents e2258fb + d7527fb commit c02e7b8
Show file tree
Hide file tree
Showing 32 changed files with 99 additions and 123 deletions.
39 changes: 25 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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
idea
java
kotlin("jvm") version "1.4.0"
id("org.jetbrains.intellij") version "0.4.21"
kotlin("jvm") version "1.4.32"
id("org.jetbrains.intellij") version "0.7.3"
}

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

val publishUsername: String by rootProject.extra
val publishPassword: String by rootProject.extra
Expand All @@ -21,26 +20,38 @@ repositories {
}

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

tasks {
// withType<PatchPluginXmlTask> { }
patchPluginXml {
version(project.version)
sinceBuild("203")
untilBuild("")
}

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

withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}

withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
runIde {
jvmArgs("--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED")
}

buildSearchableOptions {
jvmArgs("--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED")
}
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

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-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="no.tornado.tornadofx.idea.configurations.TornadoFXSettingsEditor">
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="11" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="93687" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="9" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="53" y="36" width="708" height="374"/>
<xy x="53" y="36" width="788" height="402"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="eeb03">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="50b09" class="com.intellij.execution.ui.CommonJavaParametersPanel" binding="myCommonProgramParameters">
Expand Down Expand Up @@ -57,28 +57,13 @@
</constraints>
<properties/>
</component>
<component id="b45cf" class="javax.swing.JCheckBox" binding="myShowSwingInspectorCheckbox">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ExecutionBundle" key="show.swing.inspector"/>
</properties>
</component>
<vspacer id="f4215">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
<vspacer id="7cceb">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
<component id="8a028" class="com.intellij.openapi.ui.LabeledComponent" binding="typeWrapper" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class TornadoFXSettingsEditor extends SettingsEditor<TornadoFXConfigurati

private final ConfigurationModuleSelector myModuleSelector;
private JrePathEditor myJrePathEditor;
private JCheckBox myShowSwingInspectorCheckbox;
private LabeledComponent<JPanel> typeWrapper;
private LabeledComponent<JPanel> myDevOptions;
private final JreVersionDetector myVersionDetector;
Expand Down Expand Up @@ -94,8 +93,6 @@ public void applyEditorTo(@NotNull final TornadoFXConfiguration configuration) t
configuration.LIVE_VIEWS = liveViewsButton.isSelected();
configuration.setAlternativeJrePath(myJrePathEditor.getJrePathOrName());
configuration.setAlternativeJrePathEnabled(myJrePathEditor.isAlternativeJreSelected());
configuration.setSwingInspectorEnabled((myVersionDetector.isJre50Configured(configuration) || myVersionDetector.isModuleJre50Configured(configuration)) && myShowSwingInspectorCheckbox.isSelected());
updateShowSwingInspector(configuration);
}

public void resetEditorFrom(@NotNull final TornadoFXConfiguration configuration) {
Expand All @@ -116,19 +113,6 @@ public void resetEditorFrom(@NotNull final TornadoFXConfiguration configuration)
dumpStylesheetsButton.setSelected(configuration.DUMP_STYLESHEETS);
liveViewsButton.setSelected(configuration.LIVE_VIEWS);
myJrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled());
updateShowSwingInspector(configuration);
}

private void updateShowSwingInspector(final TornadoFXConfiguration configuration) {
if (myVersionDetector.isJre50Configured(configuration) || myVersionDetector.isModuleJre50Configured(configuration)) {
myShowSwingInspectorCheckbox.setEnabled(true);
myShowSwingInspectorCheckbox.setSelected(configuration.isSwingInspectorEnabled());
myShowSwingInspectorCheckbox.setText(ExecutionBundle.message("show.swing.inspector"));
} else {
myShowSwingInspectorCheckbox.setEnabled(false);
myShowSwingInspectorCheckbox.setSelected(false);
myShowSwingInspectorCheckbox.setText(ExecutionBundle.message("show.swing.inspector.disabled"));
}
}

public EditorTextFieldWithBrowseButton getViewClassField() {
Expand Down
68 changes: 33 additions & 35 deletions src/main/kotlin/no/tornado/tornadofx/idea/FXTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,46 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.supertypes

class FXTools {
companion object {
fun isComponent(psiClass: PsiClass) = isType("tornadofx.Component", psiClass)
fun isFragment(psiClass: PsiClass) = isType("tornadofx.Fragment", psiClass)
fun isUIComponent(psiClass: PsiClass) = isType("tornadofx.UIComponent", psiClass)
fun isApp(psiClass: PsiClass) = isType("tornadofx.App", psiClass)
fun isView(psiClass: PsiClass) = isType("tornadofx.View", psiClass)
fun isStylesheet(psiClass: PsiClass) = isType("tornadofx.Stylesheet", psiClass)
object FXTools {
fun isComponent(psiClass: PsiClass) = isType("tornadofx.Component", psiClass)
fun isFragment(psiClass: PsiClass) = isType("tornadofx.Fragment", psiClass)
fun isUIComponent(psiClass: PsiClass) = isType("tornadofx.UIComponent", psiClass)
fun isApp(psiClass: PsiClass) = isType("tornadofx.App", psiClass)
fun isView(psiClass: PsiClass) = isType("tornadofx.View", psiClass)
fun isStylesheet(psiClass: PsiClass) = isType("tornadofx.Stylesheet", psiClass)

fun isType(type: String, psiClass: PsiClass): Boolean {
for (supa in psiClass.supers)
if (type == supa.qualifiedName) {
return true
} else {
val superIs = isType(type, supa)
if (superIs) return true
}
fun isType(type: String, psiClass: PsiClass): Boolean {
for (supa in psiClass.supers)
if (type == supa.qualifiedName) {
return true
} else {
val superIs = isType(type, supa)
if (superIs) return true
}

return false
}
return false
}

fun isTornadoFXType(psiClass: PsiClass): Boolean {
for (supa in psiClass.supers)
if (supa.qualifiedName?.startsWith("tornadofx.") == true) {
return true
} else {
val superIs = isTornadoFXType(supa)
if (superIs) return true
}
fun isTornadoFXType(psiClass: PsiClass): Boolean {
for (supa in psiClass.supers)
if (supa.qualifiedName?.startsWith("tornadofx.") == true) {
return true
} else {
val superIs = isTornadoFXType(supa)
if (superIs) return true
}

return false
}
return false
}

fun containsTornadoFXImports(file: KtFile) = file.importList?.imports?.find {
it.importedFqName?.asString()?.contains("tornadofx") ?: false
} != null
fun containsTornadoFXImports(file: KtFile) = file.importList?.imports?.find {
it.importedFqName?.asString()?.contains("tornadofx") ?: false
} != null

fun psiClass(className: String, project: Project) =
JavaPsiFacade.getInstance(project).findClass(className, project.projectScope())
fun psiClass(className: String, project: Project) =
JavaPsiFacade.getInstance(project).findClass(className, project.projectScope())

fun isJavaFXProperty(type: KotlinType?) = type?.supertypes()?.find { it.getJetTypeFqName(false) == "javafx.beans.property.Property" } != null
}
fun isJavaFXProperty(type: KotlinType?) = type?.supertypes()?.find { it.getJetTypeFqName(false) == "javafx.beans.property.Property" } != null

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.intellij.psi.util.PsiTreeUtil
import com.intellij.ui.EditorTextField
import com.intellij.ui.EditorTextFieldWithBrowseButton
import no.tornado.tornadofx.idea.FXTools
import no.tornado.tornadofx.idea.FXTools.Companion.isComponent
import no.tornado.tornadofx.idea.FXTools.isComponent
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.search.allScope
import org.jetbrains.kotlin.idea.search.projectScope
Expand Down Expand Up @@ -72,7 +72,7 @@ class InjectComponentAction : AnAction() {
return
}

val psiFacade = JavaPsiFacade.getInstance(e.project)
val psiFacade = JavaPsiFacade.getInstance(e.project!!)
val psiClass = psiFacade.findClass(ktClass.fqName.toString(), e.project!!.allScope())!!

e.presentation.isEnabled = isComponent(psiClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class NewViewAction : AnAction() {
.createHtmlTextBalloonBuilder("TornadoFX was not found on your classpath. You must add it to reliably use the TornadoFX plugin.", MessageType.WARNING, null)
.setFadeoutTime(7500)
.createBalloon()
.show(RelativePoint.getCenterOf(statusBar.component), Balloon.Position.atRight);
.show(RelativePoint.getCenterOf(statusBar.component), Balloon.Position.atRight)
return true
} else {
return layouts.findMethodsByName(builderName, true).isNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import no.tornado.tornadofx.idea.FXTools.Companion.isStylesheet
import no.tornado.tornadofx.idea.FXTools.isStylesheet
import no.tornado.tornadofx.idea.quickfixes.css.BoxQuickFix
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
import org.jetbrains.kotlin.idea.references.KtInvokeFunctionReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CSSColorAnnotator : Annotator {
val resolvedRef = element.mainReference.resolve()

if( resolvedRef is KtProperty) {
val expr = resolvedRef.children.last();
val expr = resolvedRef.children.last()
if (expr is KtExpression) {
handelProperty(
resolvedRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.intellij.execution.configurations.runConfigurationType
import com.intellij.openapi.util.Ref
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElement
import no.tornado.tornadofx.idea.FXTools.Companion.isApp
import no.tornado.tornadofx.idea.FXTools.isApp
import no.tornado.tornadofx.idea.configurations.TornadoFXConfiguration.RunType.App
import no.tornado.tornadofx.idea.configurations.TornadoFXConfiguration.RunType.View
import no.tornado.tornadofx.idea.firstModuleWithTornadoFXLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TornadoFXRunLineMarkerContributor : RunLineMarkerContributor() {
if (isApp || isView) {
return Info(
PluginIcons.ACTION,
Function<PsiElement, String> { "Run TornadoFX ${if (isApp) "Application" else "View"}" },
{ "Run TornadoFX ${if (isApp) "Application" else "View"}" },
*ExecutorAction.getActions(0)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class ErrorDialog(project: Project, private val error: String) : DialogWrapper(p
init()
}

override fun createCenterPanel(): JComponent? = JLabel(error)
override fun createCenterPanel(): JComponent = JLabel(error)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package no.tornado.tornadofx.idea.dialog

import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.psi.PsiFile
import com.intellij.ui.components.JBTextField
import java.awt.GridBagConstraints
import java.awt.GridBagLayout
import java.awt.Insets
import javax.swing.JComboBox
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
Expand All @@ -21,8 +21,8 @@ class ExtractStringToResourceDialog(
private val okAction: (String, String, PsiFile) -> Unit
) : DialogWrapper(project) {

private val resourcePathComboBox = JComboBox<String>(resourcePathStrings).apply {
resourcePathStrings.maxBy { it.length }?.let {
private val resourcePathComboBox = ComboBox(resourcePathStrings).apply {
resourcePathStrings.maxByOrNull { it.length }?.let {
prototypeDisplayValue = it
}
}
Expand All @@ -38,7 +38,7 @@ class ExtractStringToResourceDialog(
init()
}

override fun createCenterPanel(): JComponent? = JPanel(GridBagLayout()).apply {
override fun createCenterPanel(): JComponent = JPanel(GridBagLayout()).apply {
addGrid(0, 0, JLabel("resource:"))
addGrid(1, 0, resourcePathComboBox)

Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/no/tornado/tornadofx/idea/editors/ViewEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ class ViewEditor(val project: Project, val myFile: VirtualFile) : FileEditor {
}

override fun getComponent(): JComponent {
return panel;
return panel
}

override fun getPreferredFocusedComponent(): JComponent? {
return null;
return null
}

override fun deselectNotify() {
}

override fun getBackgroundHighlighter(): BackgroundEditorHighlighter? {
return null;
return null
}

override fun isValid(): Boolean {
return true;
return true
}

override fun isModified(): Boolean {
return false;
return false
}

override fun addPropertyChangeListener(listener: PropertyChangeListener) {
Expand All @@ -111,7 +111,7 @@ class ViewEditor(val project: Project, val myFile: VirtualFile) : FileEditor {
}

override fun getCurrentLocation(): FileEditorLocation? {
return null;
return null
}

override fun removePropertyChangeListener(listener: PropertyChangeListener) {
Expand Down
Loading

0 comments on commit c02e7b8

Please sign in to comment.