I am writing an IntelliJ IDEA plugin for saving sessions of open tabs called Tab Session. This question is a follow-up of IntelliJ IDEA Plugin Development: Save groups of tabs, save them persistently and reload a set of tabs if requested by the user.
Currently, splitted windows are not supported. Therefore i want to do two things:
- Retrieve information about all splitted or unsplitted windows that are containers for editor tabs. I need their position and split direction (horizontal or vertical).
- When this information is saved and a tab session needs to be loaded, i need to reconstruct the splitted panes and their tabs exactly as they were before.
Due to the lack of documentation i am currently browsing through the source code and found this promising piece of code:
private EditorsSplitters getSplittersFromFocus() {
return FileEditorManagerEx.getInstanceEx(myProject).getSplitters();
}
It allows me to iterate through the set of splitted windows by using EditorWindow[] windows = getSplittersFromFocus.getOrderedWindows()
. They contain the editor tabs and information about their width and height. But i did not find any information about the split direction and how to reconstruct the splitted windows as they were before.
Can anyone help?
This is untested code, but as it closely resmbles the procedures inside EditorsSplitters
writeExternal
andwritePanel
functions I am positive this will work.Presented are two methods:
writeExternal
-> should be the more stable API and offers easier access to file informationwriteExternal
creates it's information; sadly there is at least one protected field without getter involved (window.myPanel
insidefindWindowWith
)