AnAction from Swing component that invokes a Git4Idea call
For reference, I've tried the solution from here and here, without success as the Git4Idea call fails.
I have an AnAction (that does some setup when a PR comes in) that I can trigger successfully from a balloon notification. When the action is run, the system first fetches from the appropriate repo, which is successful when in the context of a balloon.
I also need to trigger it from a double-click in a JList containing the names of the PRs. I can successfully trigger the AnAction, using the methods in the linked posts via ActionUtil, however when I call the fetch operation within the AnAction I get an assertion error in `BuiltInServerManagerImpl#waitForStart`, where it checks if we're in a dispatch thread.
java.lang.Throwable: Assertion failed
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:197)
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:206)
at org.jetbrains.ide.BuiltInServerManagerImpl.waitForStart(BuiltInServerManagerImpl.kt:107)
at git4idea.rebase.GitRebaseEditorService.getEditorCommand(GitRebaseEditorService.java:81)
at git4idea.rebase.GitHandlerRebaseEditorManager.prepareEditor(GitHandlerRebaseEditorManager.java:42)
at git4idea.rebase.GitHandlerRebaseEditorManager.lambda$prepareEditor$0(GitHandlerRebaseEditorManager.java:28)
at git4idea.GitUtil.tryRunOrClose(GitUtil.java:1040)
at git4idea.rebase.GitHandlerRebaseEditorManager.prepareEditor(GitHandlerRebaseEditorManager.java:27)
at git4idea.commands.GitImplBase.prepareGeneralPurposeEditor(GitImplBase.java:186)
at git4idea.commands.GitImplBase.run(GitImplBase.java:170)
at git4idea.commands.GitImplBase.runCommand(GitImplBase.java:71)
at git4idea.config.GitConfigUtil.getValue(GitConfigUtil.java:77)
at git4idea.config.GitConfigUtil.getValue(GitConfigUtil.java:70)
at git4idea.fetch.GitFetchSupportImpl.isStoreCredentialsHelperUsed(GitFetchSupportImpl.kt:182)
at git4idea.fetch.GitFetchSupportImpl.getMaxThreads(GitFetchSupportImpl.kt:174)
at git4idea.fetch.GitFetchSupportImpl.fetchInParallel(GitFetchSupportImpl.kt:140)
at git4idea.fetch.GitFetchSupportImpl.access$fetchInParallel(GitFetchSupportImpl.kt:45)
at git4idea.fetch.GitFetchSupportImpl$fetch$1.invoke(GitFetchSupportImpl.kt:104)
at git4idea.fetch.GitFetchSupportImpl$fetch$1.invoke(GitFetchSupportImpl.kt:45)
at git4idea.fetch.GitFetchSupportImpl.withIndicator(GitFetchSupportImpl.kt:211)
at git4idea.fetch.GitFetchSupportImpl.fetch(GitFetchSupportImpl.kt:101)
at git4idea.fetch.GitFetchSupportImpl.fetch(GitFetchSupportImpl.kt:91)
This does all work successfully when it's invoked directly as an action from a `com.intellij.notification.Notification` balloon popup.
How can I get my Swing event to trigger the action in the same context as the Notification does?
Please sign in to leave a comment.
Please clarify what is the ActionID you're calling here, ideally also snippet showing invocation.
My action doesn't have an action ID as it's added to a com.intellij.notification.Notification (in the case where it's working).
In the case where it isn't working, I execute it as:
Please try invoking in non-EDT way using com.intellij.openapi.progress.ProgressManager
Invoking per:
Still produces
It doesn't seem to stop the flow though, not sure what's happening under the hood but my subsequent lines are executed - but it does produce the error log saying that my plugin produced an exception.
The subsequent lines are:
executeNonCancelableSection() runs on invoking thread and thus is not working, please try runProcessWithProgressSynchronously() or background Task
I may need a different way to execute the action then? Executing it as I currently am produces this:
Access is allowed from event dispatch thread with IW lock only.
Which is from the first line of this block:
Hey - sorry, yes, was being dumb :)
I ended up having to execute the action in the EDT, and moved the runProcessWithProgressSynchronously deeper into the action itself, and all seems good now, thanks.