mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 17:03:12 +07:00
IDEA-148286 Make "Select In Git Log" invisible for files not under Git
This commit is contained in:
+7
@@ -17,6 +17,7 @@ package git4idea.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationGutterActionProvider;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.annotate.UpToDateLineNumberListener;
|
||||
@@ -47,6 +48,12 @@ public class GitShowCommitInLogAnnotationGutterActionProvider implements Annotat
|
||||
return myAnnotation.getLineRevisionNumber(myLineNumber);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected VcsKey getVcsKey(@NotNull AnActionEvent event) {
|
||||
return myAnnotation.getVcsKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(Integer lineNumber) {
|
||||
myLineNumber = lineNumber;
|
||||
|
||||
@@ -25,7 +25,9 @@ import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.VcsKey;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
@@ -38,6 +40,7 @@ import com.intellij.vcs.log.VcsLog;
|
||||
import com.intellij.vcs.log.impl.VcsLogContentProvider;
|
||||
import com.intellij.vcs.log.impl.VcsLogManager;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.i18n.GitBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -132,12 +135,19 @@ public class GitShowCommitInLogAction extends DumbAwareAction {
|
||||
return revision;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected VcsKey getVcsKey(@NotNull AnActionEvent event) {
|
||||
return event.getData(VcsDataKeys.VCS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabled(e.getProject() != null &&
|
||||
VcsLogContentProvider.findLogManager(e.getProject()) != null &&
|
||||
getRevisionNumber(e) != null);
|
||||
Project project = e.getProject();
|
||||
e.getPresentation().setEnabledAndVisible(project != null &&
|
||||
VcsLogContentProvider.findLogManager(project) != null &&
|
||||
getRevisionNumber(e) != null &&
|
||||
Comparing.equal(getVcsKey(e), GitVcs.getKey()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user