Register and Control FileEditorProvider from an Action.


I am developing a IntelliJ plugin where an action can be performed on a file and as result of action a web page (URL of web page changes each time) will be opened into browser (JCEF) in editor workspace, but I am struggling to show the web page in editor workspace, I want to open a new editor and attach JCEF browser with it. 

My Approach:- I read about FileEditorProvider and I created derivatives of FileEditorProvider and FileEditor class, which is returning a JComponent. Now I am creating and opening a tmp file from actionPerformed() using openTextEditor API of FileEditorManager classafter this tmp file is opened into editor workspace having a custom editor where FileEditorPolicy is set to HIDE_DEFAULT_EDITOR, so only custom tab will be seen in file and it would look like a browser window is opened in editor workspace and web page will load each time.

My Problem:- The URL to web page changes every time when action is performed, hence I need to register FileEditorProvider from actionPerformed() method and pass new URL to the FileEditor each time, after registration I will have to open tmp file which is created earlier into editor workspace, so that web page from updated URL is shown in editor tab. This is the part where I am struggling. I explored examples of FileEditorProvider from GitHub repos but could not get any plugin, where FileEditorProvider is registered and controlled from an action at runtime.

Please provide me some guidance or any example for this, any help to achieve my objective is much appreciated,

Thank You....

Comment actions Permalink

You could register a "dummy" VirtualFileSystem using custom prefix to distinguish such "files" and handle them accordingly.

See  org.jetbrains.idea.devkit.testAssistant.vfs.TestDataGroupFileSystem from Plugin Devkit as sample.

com.intellij.openapi.fileEditor.FileEditorProvider should be registered in extension point com.intellij.fileEditorProvider in plugin.xml and not via Action.

Comment actions Permalink

Thanks for the guidance, I will explore Devkit Plugin.


Please sign in to leave a comment.