use of org.eclipse.egit.core.internal.IRepositoryCommit in project egit by eclipse.
the class AbstractHistoryCommandHandler method getRepository.
protected Repository getRepository(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = getSelection(event);
if (!selection.isEmpty()) {
IRepositoryCommit commit = AdapterUtils.adapt(selection.getFirstElement(), IRepositoryCommit.class);
if (commit != null) {
return commit.getRepository();
}
}
Object input = getInput(event);
if (input == null) {
return null;
}
if (input instanceof HistoryPageInput) {
return ((HistoryPageInput) input).getRepository();
}
if (input instanceof RepositoryTreeNode) {
return ((RepositoryTreeNode) input).getRepository();
}
Repository repo = AdapterUtils.adapt(input, Repository.class);
if (repo != null) {
return repo;
}
IResource resource = AdapterUtils.adaptToAnyResource(input);
if (resource != null) {
Repository repository = ResourceUtil.getRepository(resource);
if (repository != null) {
return repository;
}
}
throw new ExecutionException(UIText.AbstractHistoryCommanndHandler_CouldNotGetRepositoryMessage);
}
Aggregations