use of git4idea.GitVcs in project intellij-community by JetBrains.
the class GitShowExternalLogAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
final GitVcs vcs = ObjectUtils.assertNotNull(GitVcs.getInstance(project));
final List<VirtualFile> roots = getGitRootsFromUser(project);
if (roots.isEmpty()) {
return;
}
if (project.isDefault() || !ProjectLevelVcsManager.getInstance(project).hasActiveVcss()) {
ProgressManager.getInstance().run(new ShowLogInDialogTask(project, roots, vcs));
return;
}
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
final Runnable showContent = () -> {
ContentManager cm = window.getContentManager();
if (checkIfProjectLogMatches(project, vcs, cm, roots) || checkIfAlreadyOpened(cm, roots)) {
return;
}
String tabName = calcTabName(cm, roots);
MyContentComponent component = createManagerAndContent(project, vcs, roots, tabName);
Content content = ContentFactory.SERVICE.getInstance().createContent(component, tabName, false);
content.setDisposer(component.myDisposable);
content.setDescription("Log for " + StringUtil.join(roots, VirtualFile::getPath, "\n"));
content.setCloseable(true);
cm.addContent(content);
cm.setSelectedContent(content);
};
if (!window.isVisible()) {
window.activate(showContent, true);
} else {
showContent.run();
}
}
Aggregations