Skip to content

Commit

Permalink
fix: open FileChooser at AWT Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
tangcent committed Nov 23, 2022
1 parent e0c29af commit c31aa3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {

implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

implementation('com.itangcent:commons:1.4.2') {
implementation('com.itangcent:commons:1.4.32-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}
Expand Down
8 changes: 4 additions & 4 deletions idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar'])


implementation('com.itangcent:intellij-idea:1.4.2') {
implementation('com.itangcent:intellij-idea:1.4.32-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}

implementation('com.itangcent:intellij-kotlin-support:1.4.2') {
implementation('com.itangcent:intellij-kotlin-support:1.4.32-SNAPSHOT') {
exclude group: 'com.google.inject'
exclude group: 'com.google.code.gson'
}

// implementation('com.itangcent:intellij-scala-support:1.4.2') {
// implementation('com.itangcent:intellij-scala-support:1.4.32-SNAPSHOT') {
// exclude group: 'com.google.inject'
// exclude group: 'com.google.code.gson'
// }
Expand Down Expand Up @@ -122,7 +122,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.mockito/mockito-inline
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.11.0'

testImplementation('com.itangcent:intellij-idea-test:1.4.2') {
testImplementation('com.itangcent:intellij-idea-test:1.4.32-SNAPSHOT') {
exclude group: 'com.nhaarman.mockitokotlin2', module: 'mockito-kotlin'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ import com.itangcent.intellij.jvm.element.ExplicitMethod
import com.itangcent.intellij.jvm.element.ExplicitParameter
import com.itangcent.intellij.logger.Logger
import com.itangcent.intellij.psi.ClassRuleConfig
import com.itangcent.intellij.jvm.JsonOption
import com.itangcent.intellij.psi.PsiClassUtils
import java.util.LinkedList
import java.util.*
import javax.script.ScriptContext
import javax.script.ScriptEngine
import javax.script.SimpleScriptContext
Expand Down Expand Up @@ -319,7 +318,7 @@ abstract class ScriptRuleParser : RuleParser {
}

fun sourceCode(): String? {
return psiElement?.text
return actionContext.callInReadUI { psiElement?.text }
}

fun defineCode(): String? {
Expand Down Expand Up @@ -426,11 +425,11 @@ abstract class ScriptRuleParser : RuleParser {
}

override fun getName(): String? {
return psiClass.qualifiedName
return actionContext.callInReadUI { psiClass.qualifiedName }
}

override fun getSimpleName(): String? {
return psiClass.name
return actionContext.callInReadUI { psiClass.name }
}

override fun toJson(): String? {
Expand Down Expand Up @@ -746,7 +745,7 @@ abstract class ScriptRuleParser : RuleParser {
}

override fun getName(): String? {
return psiMethod.name
return actionContext.callInReadUI { psiMethod.name }
}

fun jsonName(): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class IdeaFileChooserHelper private constructor(
if (lastLocation != null) {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation)
}
actionContext.runInSwingUI {
actionContext.runInAWT {
val chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, null)
val files = chooser.choose(project, toSelect)
if (files.isNotEmpty()) {
Expand Down

0 comments on commit c31aa3e

Please sign in to comment.