mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] IDEA-115980 Don't show Git actions if there are no Git roots
This commit is contained in:
@@ -72,4 +72,10 @@ public interface VcsLog {
|
||||
@NotNull
|
||||
Component getToolbar();
|
||||
|
||||
/**
|
||||
* Returns {@link VcsLogProvider VcsLogProviders} which are active in this log, i.e. which VCS roots are shown in the log.
|
||||
*/
|
||||
@NotNull
|
||||
Collection<VcsLogProvider> getLogProviders();
|
||||
|
||||
}
|
||||
|
||||
@@ -491,6 +491,11 @@ public class VcsLogDataHolder implements Disposable {
|
||||
return myLogProviders.keySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<VcsLogProvider> getLogProviders() {
|
||||
return myLogProviders.values();
|
||||
}
|
||||
|
||||
private static class RecentCommitsInfo {
|
||||
List<TimedVcsCommit> firstBlockCommits;
|
||||
Collection<VcsRef> newRefs;
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.intellij.vcs.log.impl;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsLog;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.*;
|
||||
import com.intellij.vcs.log.data.VcsLogDataHolder;
|
||||
import com.intellij.vcs.log.ui.VcsLogUI;
|
||||
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
|
||||
@@ -115,4 +112,11 @@ public class VcsLogImpl implements VcsLog {
|
||||
public Component getToolbar() {
|
||||
return myUi.getToolbar();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VcsLogProvider> getLogProviders() {
|
||||
return myDataHolder.getLogProviders();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -37,7 +38,10 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcs.log.VcsLog;
|
||||
import com.intellij.vcs.log.VcsLogProvider;
|
||||
import com.intellij.vcsUtil.VcsFileUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import git4idea.branch.GitBranchUtil;
|
||||
@@ -951,4 +955,16 @@ public class GitUtil {
|
||||
repositoryManager.getRepositories()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are Git roots in the VCS log.
|
||||
*/
|
||||
public static boolean logHasGitRoot(@NotNull VcsLog log) {
|
||||
return ContainerUtil.find(log.getLogProviders(), new Condition<VcsLogProvider>() {
|
||||
@Override
|
||||
public boolean value(VcsLogProvider logProvider) {
|
||||
return logProvider.getSupportedVcs().equals(GitVcs.getKey());
|
||||
}
|
||||
}) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class GitLogSingleCommitAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
boolean isValid() {
|
||||
return project != null && log != null;
|
||||
return project != null && log != null && GitUtil.logHasGitRoot(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.*;
|
||||
import git4idea.GitLocalBranch;
|
||||
import git4idea.GitPlatformFacade;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.commands.Git;
|
||||
import git4idea.config.GitVcsSettings;
|
||||
@@ -131,7 +132,13 @@ public class GitCherryPickAction extends DumbAwareAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(enabled(e));
|
||||
final VcsLog log = getVcsLog(e);
|
||||
if (log != null && !GitUtil.logHasGitRoot(log)) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
else {
|
||||
e.getPresentation().setEnabled(enabled(e));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enabled(AnActionEvent e) {
|
||||
|
||||
Reference in New Issue
Block a user