Access is allowed from event dispatch thread when calling EditorFactory.getInstance().createEditor(document, project, Type, true) from FileEditor#getComponent

On the .beam files (so the equivalent of .class files for Erlang/Elixir), I have <fileEditorProvider implementation="org.elixir_lang.beam.file_editor.Provider"/>. It supplies a second editor tab next to the "Text" one that is provided by the BinaryDecompiler extension point. https://github.com/KronicDeth/intellij-elixir/blob/v7.4.0/screenshots/features/beam_files/Editor%20Tabs.png?raw=true .

Inside the "BEAM Chunks" tab is a com.intellij.openapi.fileEditor.FileEditor. It is that FileEditor's getComponent where I'm trying to make a nested editor because in "BEAM Chunks" tab, I have subtabs for each "Chunk" https://github.com/KronicDeth/intellij-elixir/blob/v7.4.0/screenshots/features/beam_files/beam_chunks/Chunk%20Tabs.png?raw=true. It is the editors I create for those subtabs that raise an error (https://github.com/KronicDeth/intellij-elixir/issues/1050), so how do I make the panels for those tabs? The way I have it written now, invokeLater wouldn't work because FileEditor#getComponent wants the whole JComponent tree. Do I need to do something where I delay making the editors with EditorFactory.getInstance().createEditor(document, project, Type, true) until the subtab comes to the front and is visible?

The full docs with screenshots is in this subsection https://github.com/KronicDeth/intellij-elixir/tree/v7.4.0#beam-files if having visuals makes it easier to help with which UI components I should be using instead. The code (from the FileEditorProvider) can be traced starting here https://github.com/KronicDeth/intellij-elixir/blob/v7.4.0/src/org/elixir_lang/beam/file_editor/Provider.kt.

4 comments
Avatar
Irina Chernushina
Comment actions Permalink
Official comment

The error with JSLinterEditorNotificationPanel was fixed in master.

Comment actions Permalink

One way to fix this would be to change JSLinterEditorNotificationPanel so that it won't call FileEditor.getComponent() from non-EDT thread. Probably it makes sense to do, but if you don't want to wait until that happens, you can go another way - creating your components not lazily, but at FileEditor instance creation. At least, a root component (which is returned by getComponent()) can be created initially, and e.g. when it becomes visible (when user switches to 'BEAM chunks' tab), all containing sub-editors are created.

0
Comment actions Permalink

How do I detect that the user has switched to the tab and that it is safe to create the other components?

0
Comment actions Permalink

I'd try to overwrite addNotify on your component, or use com.intellij.util.ui.update.UiNotifyConnector.

0

Please sign in to leave a comment.