Multi-Tab FileEditor, focusing custom tab on editor open Follow
Answered
Hi,
I have written a custom file type extension and registered it in the plugin.xml file. Further, I have written a new FileEditor implementing com.intellij.openapi.fileEditor.FileEditor interface to open my custom file types.
I have the reference to the PsiFile object which represent one of my custom file type. When I execute
PsiNavigateUtil.navigate(myPsiFile)
the file is opened in my custom editor window as well. This editor has two tabs (Text and UI). I have specified the my UI panel as the
getPreferredFocusedComponent()
But when the editor is opened, the Text tab is always focused. Is there any way to open the editor where UI tab is focused.
Please sign in to leave a comment.
Method `com.intellij.openapi.fileEditor.FileEditor#getPreferredFocusedComponent` returns a component to be focused when a custom editor is selected. Also, `PsiNavigateUtil.navigate(myPsiFile)` simply opens the last opened FileEditor for this file.
Consider implementing com.intellij.openapi.fileEditor.FileEditorProvider#getPolicy
Hi Sergey,
I have solved it in following manner
Above line will open the file in the editor window
Above line will focus the custom editor I have provided. In here the "EDITOR_TYPE_ID" is the String returned by
method in my custom FileEditorProvider implementation.
BTW: Thank you for you answer :)
Great, thanks for sharing this solution.