use of org.eclipse.egit.ui.internal.blame.BlameOperation in project egit by eclipse.
the class ShowBlameActionHandler method execute.
/**
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = getSelection(event);
if (selection.size() != 1) {
return null;
}
Object element = selection.getFirstElement();
IResource resource = AdapterUtils.adapt(element, IResource.class);
if (resource instanceof IFile) {
RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
if (mapping != null) {
String repoRelativePath = mapping.getRepoRelativePath(resource);
Shell shell = HandlerUtil.getActiveShell(event);
IWorkbenchPage page = HandlerUtil.getActiveSite(event).getPage();
JobUtil.scheduleUserJob(new BlameOperation(mapping.getRepository(), (IFile) resource, repoRelativePath, null, shell, page), UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
}
} else if (element instanceof CommitFileRevision) {
Shell shell = HandlerUtil.getActiveShell(event);
IWorkbenchPage page = HandlerUtil.getActiveSite(event).getPage();
JobUtil.scheduleUserJob(new BlameOperation((CommitFileRevision) element, shell, page), UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
}
return null;
}
use of org.eclipse.egit.ui.internal.blame.BlameOperation in project egit by eclipse.
the class CommitFileDiffViewer method showAnnotations.
private void showAnnotations(FileDiff d) {
try {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
RevCommit commit = d.getChange().equals(ChangeType.DELETE) ? d.getCommit().getParent(0) : d.getCommit();
String path = d.getPath();
IFileRevision rev = CompareUtils.getFileRevision(path, commit, getRepository(), d.getChange().equals(ChangeType.DELETE) ? d.getBlobs()[0] : d.getBlobs()[d.getBlobs().length - 1]);
if (rev instanceof CommitFileRevision) {
BlameOperation op = new BlameOperation((CommitFileRevision) rev, window.getShell(), page);
JobUtil.scheduleUserJob(op, UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
} else {
String message = NLS.bind(UIText.DiffViewer_notContainedInCommit, path, d.getCommit().getId().getName());
Activator.showError(message, null);
}
} catch (IOException e) {
Activator.logError(UIText.GitHistoryPage_openFailed, e);
Activator.showError(UIText.GitHistoryPage_openFailed, null);
}
}
use of org.eclipse.egit.ui.internal.blame.BlameOperation in project egit by eclipse.
the class ShowBlameHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
GitHistoryPage page = getPage(event);
if (page == null) {
return null;
}
Object input = page.getInputInternal().getSingleItem();
if (input == null) {
return null;
}
Repository repo = getRepository(event);
if (repo == null) {
return null;
}
String path = getPath(repo, page);
if (path == null) {
return null;
}
RevCommit commit = getSelectedCommit(event);
if (commit == null) {
return null;
}
try {
IFileRevision revision = CompareUtils.getFileRevision(path, commit, repo, null);
if (revision instanceof CommitFileRevision) {
BlameOperation op = new BlameOperation((CommitFileRevision) revision, HandlerUtil.getActiveShell(event), page.getSite().getPage());
JobUtil.scheduleUserJob(op, UIText.ShowBlameHandler_JobName, JobFamilies.BLAME);
}
} catch (IOException e) {
Activator.showError(UIText.ShowBlameHandler_errorMessage, e);
}
return null;
}
Aggregations