use of com.intellij.vcs.log.history.FileHistoryUi in project intellij-community by JetBrains.
the class CompareRevisionsFromHistoryAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
FileHistoryUi ui = e.getRequiredData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH);
if (e.getInputEvent() instanceof MouseEvent && ui.getTable().isResizingColumns()) {
// disable action during columns resize
return;
}
VcsLogUtil.triggerUsage(e);
List<CommitId> commits = ui.getVcsLog().getSelectedCommits();
if (commits.size() != 1 && commits.size() != 2)
return;
List<Integer> commitIds = ContainerUtil.map(commits, c -> ui.getLogData().getCommitIndex(c.getHash(), c.getRoot()));
ui.getLogData().getCommitDetailsGetter().loadCommitsData(commitIds, details -> {
if (details.size() == 2) {
VcsFileRevision newestRevision = ui.createRevision(details.get(0));
VcsFileRevision olderRevision = ui.createRevision(details.get(1));
if (olderRevision != null && newestRevision != null) {
myDiffHandler.showDiffForTwo(project, filePath, olderRevision, newestRevision);
}
} else if (details.size() == 1) {
VcsFullCommitDetails detail = ObjectUtils.notNull(ContainerUtil.getFirstItem(details));
List<Change> changes = ui.collectRelevantChanges(detail);
if (filePath.isDirectory()) {
VcsDiffUtil.showChangesDialog(project, "Changes in " + detail.getId().toShortString() + " for " + filePath.getName(), ContainerUtil.newArrayList(changes));
} else {
ShowDiffAction.showDiffForChange(project, changes, 0, new ShowDiffContext());
}
}
}, null);
}
use of com.intellij.vcs.log.history.FileHistoryUi in project intellij-community by JetBrains.
the class FileHistorySingleCommitAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
Project project = e.getProject();
FileHistoryUi ui = e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
if (project == null || ui == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setVisible(true);
List<VcsFullCommitDetails> details = ui.getVcsLog().getSelectedDetails();
if (details.isEmpty()) {
e.getPresentation().setEnabled(false);
return;
}
VcsFullCommitDetails detail = getFirstItem(details);
if (detail instanceof LoadingDetails)
detail = null;
e.getPresentation().setEnabled(details.size() == 1 && isEnabled(ui, detail, e));
}
use of com.intellij.vcs.log.history.FileHistoryUi in project intellij-community by JetBrains.
the class FileHistorySingleCommitAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
VcsLogUtil.triggerUsage(e);
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
FileHistoryUi ui = e.getRequiredData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
List<CommitId> commits = ui.getVcsLog().getSelectedCommits();
if (commits.size() != 1)
return;
CommitId commit = notNull(getFirstItem(commits));
List<Integer> commitIndex = Ints.asList(ui.getLogData().getCommitIndex(commit.getHash(), commit.getRoot()));
ui.getLogData().getCommitDetailsGetter().loadCommitsData(commitIndex, details -> {
if (!details.isEmpty()) {
performAction(project, ui, notNull(getFirstItem(details)), e);
}
}, null);
}
use of com.intellij.vcs.log.history.FileHistoryUi in project intellij-community by JetBrains.
the class VcsLogActionPromoter method promote.
@Override
public List<AnAction> promote(@NotNull List<AnAction> actions, @NotNull DataContext context) {
List<AnAction> promoted = ContainerUtil.newArrayList();
VcsLogUi ui = VcsLogDataKeys.VCS_LOG_UI.getData(context);
if (ui != null && ui instanceof FileHistoryUi) {
CompareRevisionsFromHistoryAction compareAction = ContainerUtil.findInstance(actions, CompareRevisionsFromHistoryAction.class);
if (compareAction != null)
promoted.add(compareAction);
}
return promoted;
}
use of com.intellij.vcs.log.history.FileHistoryUi in project intellij-community by JetBrains.
the class CompareRevisionsFromHistoryAction method update.
public void update(@NotNull AnActionEvent e) {
Project project = e.getProject();
FileHistoryUi ui = e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI);
FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
if (project == null || ui == null || filePath == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setVisible(true);
List<VcsFullCommitDetails> details = ui.getVcsLog().getSelectedDetails();
if (e.getInputEvent() instanceof KeyEvent) {
e.getPresentation().setEnabled(true);
} else {
if (details.size() == 2) {
VcsFullCommitDetails detail0 = details.get(0);
VcsFullCommitDetails detail1 = details.get(1);
if (detail0 != null && !(detail0 instanceof LoadingDetails) && detail1 != null && !(detail1 instanceof LoadingDetails)) {
VcsFileRevision newestRevision = ui.createRevision(detail0);
VcsFileRevision olderRevision = ui.createRevision(detail1);
e.getPresentation().setEnabled(newestRevision != null && olderRevision != null && !filePath.isDirectory());
} else {
e.getPresentation().setEnabled(!filePath.isDirectory());
}
} else {
e.getPresentation().setEnabled(details.size() == 1);
}
}
if (details.size() == 2) {
e.getPresentation().setText(COMPARE_TEXT);
e.getPresentation().setDescription(COMPARE_DESCRIPTION);
} else {
e.getPresentation().setText(DIFF_TEXT);
e.getPresentation().setDescription(DIFF_DESCRIPTION);
}
}
Aggregations