Embedding a Editor in a Tool Window
Answered
I want to embed a Editor in a Tool Window, to display snippets of (Java) code with syntax highlight, i.e. the main editor + a Tool Window with a code snippet that is syntax highlighted.
I have followed this example to create and add a FileEditor instance; https://intellij-support.jetbrains.com/hc/en-us/community/posts/206129029-Embedding-PsiAwareTextEditorImpl-in-a-tool-window-?input_string=Embedding%20a%20Editor%20in%20a%20Tool%20Window
However I can figure out howto update the text displayed in the FileEditor. There seems to be no setFile() or setDocument() methods.
What am I doing wrong?
Please sign in to leave a comment.
Hi,
I suggest checking if the created
FileEditor
is an instance ofTextEditor
and usingTextEditor.getEditor().getDocument().setText()
.See also https://plugins.jetbrains.com/docs/intellij/editor-components.html
Perfect, worked like a charm. The object is a TextEditor and from that I can get set the text.