Retrieving and setting split window settings
I am currently working on a plugin called "Tab Session" which is quite useful if you want to save and load certain sets of open tabs. It works well, but an important feature is still missing: Splitted Tabs are ignored and are lost when reloading a session.
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 browsed 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 usingEditorWindow[] windows = getSplittersFromFocus.getOrderedWindows(). They contain the editor tabs and information about their width and height. But i did not found any information about the split direction and how to reconstruct the splitted windows as they were before. I also looked at FileEditorManagerImpl but didn't find anything useful.
I also asked at Stackoverflow, but got no attention:
http://stackoverflow.com/questions/19728469/retrieving-and-setting-split-window-settings-for-intellij-idea-plugin-developmen
Maybe someone can help me with this. I find it quite diffictult to find the right methods without a documentation.
Please sign in to leave a comment.
The state of a split window is stored by the EditorsSplitters.writeExternal() method. You can see how it's implemented and implement similar logic in your own code.
To restore the split state, you can use the EditorWindow.split() method.
Thank you.
The writeExternal() method is not very interesting afaik:
Did you mean the writePanel() method?
That could be interesting, but i didn't find any way to find the Element "splitter".
Also, there is no split() method in EditorWindow.
https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java#L690
Thank you! I looked at the wrong EditorWindow class.
I reviewed the EditorWindow class, and indeed there are some very useful bits in there. There is a huge problem though: no getter for the panel or splitter components.
In the class the protected field myPanel holds the panel, and myPanel.getParent() is the Splitter container which i need to get information about orientation, size and position of the splitted window (see https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java#L826).
Is there any other way to get to the splitter instance of a window?
Maybe this thread was forgotten. Can anyone provide me with new input? I am quite stuck here.
This is my current progess of things:
That method is package private and getParent is not pssible to call either. what a shit