Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ plugin: Access is allowed from event dispatch thread only

Hello Stack Overflow community. I'm writing a IntelliJ plugin that needs to write some text into an open editor by listening messages over a WebSocket.

The thing is, that I'm getting an Access is allowed from event dispatch thread only exception when trying to access the editor instance by final Editor editor = manager.getSelectedTextEditor();.

This makes totally sense, as the WebSocket's message handler is being executed in another thread.

Do you know any way for writing into the editor from another thread? Or some other workaround?

like image 340
Daniel Ramos Avatar asked Apr 21 '26 11:04

Daniel Ramos


1 Answers

ApplicationManager.getApplication().invokeLater()

http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/general_threading_rules.html

like image 150
Meo Avatar answered Apr 23 '26 23:04

Meo