I want to parse other application command to jump to target file in intelliJ,but I cannot get the Editor instance in socket thread or Timer thread.Because of that I cannot jump to target file.So i want to trig editor mouse event,then jump to target file.Or could you provide me some ways can get the instance of editor in Timer thread or socket thread.Thank you very much.
java.lang.Throwable: Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction()) at com.intellij.openapi.diagnostic.Logger.error(Logger.java:154) at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1048) at com.intellij.psi.impl.file.impl.FileManagerImpl.findFile(FileManagerImpl.java:346) at com.intellij.psi.impl.PsiManagerImpl.findFile(PsiManagerImpl.java:187) at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer.GoToFile(HiCoderSocketServer.java:91) at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer.access$300(HiCoderSocketServer.java:23) at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer$1$1.run(HiCoderSocketServer.java:46) at java.lang.Thread.run(Thread.java:748)
As editor is a UI-related component, it should be accessed on event dispatch thread (EDT) only, use ApplicationManager.getApplication().invokeLater/invokeAndWait to execute something on EDT.
PSI-related operations can also be performed on other threads, but they need to be executed in a 'read action' (under read lock), the latter is done via ApplicationManager.getApplication().runReadAction.
Could you please clarify what do you want to achieve?
i want to annotator file ,but the event can only trig by editor,can i trig event by use api?
The same to mouse event,i don't want to click mouse,i want trig by api.
What effect of mouse clicking do you want to achieve? Is it putting caret to a certain place in editor?
this is one of the scenes.i also want to do something in the mouse event function.
Still not sure I understand what you need, but if you want to put caret somewhere, you don't need to emulate mouse click, you can do that directly:
If you need to listen to mouse events in editor, you can register a listener:
Thank you for patient.
I want to parse other application command to jump to target file in intelliJ,but I cannot get the Editor instance in socket thread or Timer thread.Because of that I cannot jump to target file.So i want to trig editor mouse event,then jump to target file.Or could you provide me some ways can get the instance of editor in Timer thread or socket thread.Thank you very much.
java.lang.Throwable: Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:154)
at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1048)
at com.intellij.psi.impl.file.impl.FileManagerImpl.findFile(FileManagerImpl.java:346)
at com.intellij.psi.impl.PsiManagerImpl.findFile(PsiManagerImpl.java:187)
at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer.GoToFile(HiCoderSocketServer.java:91)
at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer.access$300(HiCoderSocketServer.java:23)
at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer$1$1.run(HiCoderSocketServer.java:46)
at java.lang.Thread.run(Thread.java:748)
As editor is a UI-related component, it should be accessed on event dispatch thread (EDT) only, use ApplicationManager.getApplication().invokeLater/invokeAndWait to execute something on EDT.
PSI-related operations can also be performed on other threads, but they need to be executed in a 'read action' (under read lock), the latter is done via ApplicationManager.getApplication().runReadAction.
Thank you sooooo much.It's helpful!