How to perform slow operations in a dialog
Answered
Helo,
My plugin opens up a dialog (using UI DSL 2) where I have two combo boxes.
The first combo box allows the user to select the destination module where a new Groovy class will be generated. Once the combo box changes, a list of abstract inheritors of spock.lang.Specification
class is fetched, updating the model of the second combo box.
This inheritor search operation causes an exception saying that Slow operations are prohibited on EDT
. I use ClassInheritorsSearch.search()
method with the module.getModuleWithDependenciesAndLibrariesScope()
scope.
What is the best way of achieving this?
Please sign in to leave a comment.
Hi Pavel,
You can run a non-blocking read action which calculates the result and finishes on EDT/UI thread. Example:
https://github.com/JetBrains/intellij-community/blob/master/java/java-impl/src/com/intellij/ui/logging/JvmLoggingConfigurable.kt#L70-L72
It will execute calculation (using search) on a background thread, and once the result is available, it will execute the code provided to finishOnUiThread in EDT (which should update UI).
I haven't found any nice example like that myself. Thanks, Karol Lewandowski , this helps a lot!!