use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.
the class VcsCherryPickAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
FileDocumentManager.getInstance().saveAllDocuments();
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
VcsCherryPickManager.getInstance(project).cherryPick(log);
}
use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.
the class VcsCherryPickAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
e.getPresentation().setVisible(true);
final VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
Project project = e.getProject();
if (project == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
VcsCherryPickManager cherryPickManager = VcsCherryPickManager.getInstance(project);
List<VcsCherryPicker> cherryPickers = getActiveCherryPickersForProject(project);
if (log == null || cherryPickers.isEmpty()) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
List<CommitId> commits = VcsLogUtil.collectFirstPack(log.getSelectedCommits(), VcsLogUtil.MAX_SELECTED_COMMITS);
if (commits.isEmpty() || cherryPickManager.isCherryPickAlreadyStartedFor(commits)) {
e.getPresentation().setEnabled(false);
return;
}
final Map<VirtualFile, List<Hash>> groupedByRoot = groupByRoot(commits);
VcsCherryPicker activeCherryPicker = getActiveCherryPicker(cherryPickers, groupedByRoot.keySet());
String description = activeCherryPicker != null ? activeCherryPicker.getInfo(log, groupedByRoot) : SEVERAL_VCS_DESCRIPTION;
e.getPresentation().setEnabled(description == null);
e.getPresentation().setText(activeCherryPicker == null ? concatActionNamesForAllAvailable(cherryPickers) : activeCherryPicker.getActionTitle());
e.getPresentation().setDescription(description == null ? "" : description);
}
use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.
the class GoToHashOrRefAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
VcsLogUtil.triggerUsage(e);
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
VcsLogUi ui = e.getRequiredData(VcsLogDataKeys.VCS_LOG_UI);
assert ui instanceof AbstractVcsLogUi;
AbstractVcsLogUi logUi = (AbstractVcsLogUi) ui;
Set<VirtualFile> visibleRoots = VcsLogUtil.getVisibleRoots(logUi);
GoToHashOrRefPopup popup = new GoToHashOrRefPopup(project, logUi.getDataPack().getRefs(), visibleRoots, log::jumpToReference, vcsRef -> logUi.jumpToCommit(vcsRef.getCommitHash(), vcsRef.getRoot()), logUi.getColorManager(), new VcsGoToRefComparator(logUi.getDataPack().getLogProviders()));
popup.show(logUi.getTable());
}
use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.
the class GitShowCommitInLogAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
final Project project = event.getRequiredData(CommonDataKeys.PROJECT);
final VcsRevisionNumber revision = getRevisionNumber(event);
if (revision == null) {
return;
}
boolean logReady = findLog(project) != null;
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
ContentManager cm = window.getContentManager();
Content[] contents = cm.getContents();
for (Content content : contents) {
if (VcsLogContentProvider.TAB_NAME.equals(content.getDisplayName())) {
cm.setSelectedContent(content);
break;
}
}
final VcsLog log = findLog(project);
if (log == null) {
showLogNotReadyMessage(project);
return;
}
Runnable selectAndOpenLog = new Runnable() {
@Override
public void run() {
Runnable selectCommit = new Runnable() {
@Override
public void run() {
jumpToRevisionUnderProgress(project, log, revision);
}
};
if (!window.isVisible()) {
window.activate(selectCommit, true);
} else {
selectCommit.run();
}
}
};
if (logReady) {
selectAndOpenLog.run();
return;
}
VcsProjectLog projectLog = VcsProjectLog.getInstance(project);
if (projectLog == null) {
showLogNotReadyMessage(project);
return;
}
VcsLogUiImpl logUi = projectLog.getMainLogUi();
if (logUi == null) {
showLogNotReadyMessage(project);
return;
}
logUi.invokeOnChange(selectAndOpenLog);
}
use of com.intellij.vcs.log.VcsLog in project intellij-community by JetBrains.
the class VcsLogSingleCommitAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
CommitId commit = ContainerUtil.getFirstItem(log.getSelectedCommits());
assert commit != null;
Repo repository = getRepositoryForRoot(project, commit.getRoot());
assert repository != null;
actionPerformed(repository, commit.getHash());
}
Aggregations