Plugin - Add gap between editor tabs Follow
Answered
Hello IDEA Community,
I am trying to write a plugin which sorts the editor tabs based on the file extension.
For example, all Java Files are next to each other and if there is another file extension, there is a gap between those files.
After some research, I only found a solution by achieving this when I rewrite the whole tab bar.
This includes basicly the whole file handling, opening files, closing files and to hide the current editor bar, so only my custom one gets displayed.
Is there a clean solution to do this, without rewriting the whole editor tab bar?
Please sign in to leave a comment.
Hello! Try to override JBEditorTabs.createSingleRowLayout() in your Tabs implementation. There are three implementations now: SingleRowLayout, CompressibleSingleRowLayout and ScrollableSingleRowLayout. You're welcome to add new one, say GroupingSingleRowLayout.
Hello Vassiliy,
thanks for your answer, this seems like the right way to do it.
I followed your suggestion and made a new class for my grouping style.
Also I made a custom JBEditorTabs, to let him call my new style in the constructor.
Is this right so far?
Where can I call my JBEditorCUstomTabs instead of JBEditorTabs, so the new "GroupingSingleRowLayout" gets called?
Spent some time chasing for solution and... Sorry, unfortunately JBEditorTabs as well as its SingleRowLayout are not designed to be replaced with custom implementation.
Hello Vassiliy Kudryashov,
thanks for your time searching for a solution.
Well, if there is no way doing it this way, than I have to hide the EditorTabs and add custom JComponent's
Is there a possibility to do this at the position of the EditorTab bar, I couldnt find a documentation or image where every single component is mentioned, so I couldn't try it myself.
At the moment I just know about the FileEditorManager, but If I do it this way, I need to do this for every single tab, and haven't got something like a "global" component where those components are stored. This means if I open or close a new tab, I have to iterate over each editor and add or delete a component.
If you setup tabs placement like this
UISettings.getInstance().setEditorTabPlacement(UISettings.TABS_NONE)
your top component would replace tabs completely.
Yes, you have to handle it for every editor with FileEditorManagerListener.
Hello Vassiliy Kudryashov,
thanks for your answer.
Thats what I wanted to avoid, listening for multiple Events and handle the TopComponent separatly for each editor doesn't make sense.
JetBrains editors are really powerfull and nice to use, but if you are working with multiple files it is impossible to get a clean sorted navigation.
Sorting by filetype or user dependent attributes would be really nice.
Nevertheless, thanks for your time, patience and all your effort you put into this!
Hello Vassiliy Kudryashov,
I played arround a little bit and at the moment it looks like this.

I use JButtons at the moment embedded inside an JPanel.
Is there any way to use the same "build" function for those tabs like IntelliJ itself?
I had a quick look inside those methods and there is a lot of logic for theme separation (Dracula, etc.) so the correct tab color gets returned.
If I write my own tab component, than I have to implement the theme and color management myself.
Is there a method which I can call with a VirtualFile and it returns a EditorTab component?
Actually 'tabs' are not components, it's just a model for JBTabsImpl. So you have to borrow a lot of logic from JBEditorTabs etc. to use proper names, icons and colors, but it's still possible.