Coloring Tabs - Looking for pointers

Hi,


I decided I want to create a plugin for IntelliJ to provide an alternative means of coloring tabs, instead of using the default "File Colors" functionality.


I want the user to be able to right-click an editor tab and set a color for it.


This is handy for me because I sometimes work on several things at a time within a project, and having the tabs color-coded would be a good way to group them.


I've read as much documentation as I can find on IntelliJ Plugins, but I'm struggling to get any further and I'm looking for some pointers.


To get me started, I created an Action which successfully sets the background colour of a tab, but it's flakey at best -- it doesn't seem to persist the color for long, and falls apart when you have multiple IntelliJ tabbed panes open at the same time. So this probably isn't the right way to do it.

        final Project project = e.getData(CommonDataKeys.PROJECT);
        final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
        final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
        EditorWindow activeWindow = fileEditorManager.getCurrentWindow();
        final int index = activeWindow.findEditorIndex(activeWindow.findFileComposite(file));
        activeWindow.getTabbedPane().setBackgroundColorAt(index, getColour());


Can anyone give me pointers on how to implement this properly? Perhaps the Action class shouldn't be the thing that actually colors the tab, but some sort of tab color manager that runs in the background, so that I can persist the colors?



Maybe there's some documentation I've missed that might show me how to achieve such a thing with tabs?


It's my first plugin, so advice is much appreciated!


Thanks =)
0
1 comment

You need to implement the EditorTabColorProvider interface and return the color that you want to use for the tab of a particular file.

0

Please sign in to leave a comment.