use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.
the class ShowSelectionHistoryAction method actionPerformed.
@Override
protected void actionPerformed(@NotNull Project p, @NotNull IdeaGateway gw, @NotNull VirtualFile f, @NotNull AnActionEvent e) {
VcsSelection sel = notNull(getSelection(e));
int from = sel.getSelectionStartLineNumber();
int to = sel.getSelectionEndLineNumber();
new SelectionHistoryDialog(p, gw, f, from, to).show();
}
use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.
the class SelectedBlockHistoryAction method update.
protected void update(@NotNull VcsContext context, @NotNull Presentation presentation) {
presentation.setEnabled(isEnabled(context));
VcsSelection selection = VcsSelectionUtil.getSelection(context);
if (selection != null) {
presentation.setText(selection.getActionName());
}
}
use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.
the class SelectedBlockHistoryAction method isEnabled.
protected boolean isEnabled(VcsContext context) {
Project project = context.getProject();
if (project == null)
return false;
VcsSelection selection = VcsSelectionUtil.getSelection(context);
if (selection == null)
return false;
VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
if (file == null)
return false;
final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
final BackgroundableActionEnabledHandler handler = vcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.HISTORY_FOR_SELECTION);
if (handler.isInProgress(VcsBackgroundableActions.keyFrom(file)))
return false;
AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
if (activeVcs == null)
return false;
VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();
if (provider == null)
return false;
if (!AbstractVcs.fileInVcsByFileStatus(project, VcsUtil.getFilePath(file)))
return false;
return true;
}
use of com.intellij.vcsUtil.VcsSelection in project intellij-community by JetBrains.
the class SelectedBlockHistoryAction method actionPerformed.
public void actionPerformed(@NotNull final VcsContext context) {
try {
final Project project = context.getProject();
assert project != null;
final VcsSelection selection = VcsSelectionUtil.getSelection(context);
assert selection != null;
final VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
assert file != null;
final AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
assert activeVcs != null;
final VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();
assert provider != null;
final int selectionStart = selection.getSelectionStartLineNumber();
final int selectionEnd = selection.getSelectionEndLineNumber();
new VcsHistoryProviderBackgroundableProxy(activeVcs, provider, activeVcs.getDiffProvider()).createSessionFor(activeVcs.getKeyInstanceMethod(), VcsUtil.getFilePath(file), new Consumer<VcsHistorySession>() {
public void consume(VcsHistorySession session) {
if (session == null)
return;
final VcsSelectionHistoryDialog vcsHistoryDialog = new VcsSelectionHistoryDialog(project, file, selection.getDocument(), provider, session, activeVcs, Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd), selection.getDialogTitle());
vcsHistoryDialog.show();
}
}, VcsBackgroundableActions.HISTORY_FOR_SELECTION, false, null);
} catch (Exception exception) {
reportError(exception);
}
}
Aggregations