How to add a new log tab to existing git vcs tool window?

Answered

Hi. I want add a new log tab to the git vcs tool window.

I'm able to get and show the tool window using:

ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
window.show();

However, I'm not sure how to add a new tab. I tried running the code below but that simply replaces the currently opened tab with a new log ui temporarily:

VcsLogData data = VcsProjectLog.getInstance(project).getLogManager().getDataManager();
factory = VcsProjectLog.getInstance(project).getLogManager().getMainLogUiFactory("test", VcsLogFilterObject.collection());
logTab = factory.createLogUi(project, data);
window.getComponent().add(logTab.getMainComponent());

Any help would be appreciated.

1 comment
Comment actions Permalink

>window.getComponent().add(logTab.getMainComponent());
You should not use ToolWindow that way. See ToolWindow.getContentManager(), ContentManager.addContent and etc.

Anyway, it is better to use VcsProjectLog.getInstance(project).openLogTab(filters, kind) instead of manual operations on ToolWindow.
See com.intellij.vcs.log.ui.actions.OpenAnotherLogTabAction as an example.

0

Please sign in to leave a comment.