Search in sources :

Example 16 with GitVcs

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();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GitVcs(git4idea.GitVcs) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ChangesViewContentManager(com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager) ContentManager(com.intellij.ui.content.ContentManager)

Aggregations

GitVcs (git4idea.GitVcs)16 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Project (com.intellij.openapi.project.Project)8 NotNull (org.jetbrains.annotations.NotNull)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Task (com.intellij.openapi.progress.Task)2 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)2 VcsException (com.intellij.openapi.vcs.VcsException)2 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)2 ToolWindow (com.intellij.openapi.wm.ToolWindow)2 Content (com.intellij.ui.content.Content)2 ContentManager (com.intellij.ui.content.ContentManager)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 Disposable (com.intellij.openapi.Disposable)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 FileChooser (com.intellij.openapi.fileChooser.FileChooser)1