in org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java [1988:2154]
private boolean inputSet(RevCommit prevSelection) {
try {
if (trace)
GitTraceLocation.getTrace().traceEntry(
GitTraceLocation.HISTORYVIEW.getLocation());
if (this.input != null)
return true;
Object o = super.getInput();
if (o == null) {
setErrorMessage(UIText.GitHistoryPage_NoInputMessage);
return false;
}
boolean showHead = false;
boolean showRef = false;
boolean showTag = false;
Repository repo = null;
RevCommit selection = null;
Ref ref = null;
if (o instanceof IResource) {
RepositoryMapping mapping = RepositoryMapping
.getMapping((IResource) o);
if (mapping != null) {
repo = mapping.getRepository();
input = new HistoryPageInput(repo,
new IResource[] { (IResource) o });
showHead = true;
}
} else if (o instanceof RepositoryTreeNode) {
RepositoryTreeNode repoNode = (RepositoryTreeNode) o;
repo = repoNode.getRepository();
switch (repoNode.getType()) {
case FILE:
File file = ((FileNode) repoNode).getObject();
input = new HistoryPageInput(repo, new File[] { file });
showHead = true;
break;
case FOLDER:
File folder = ((FolderNode) repoNode).getObject();
input = new HistoryPageInput(repo, new File[] { folder });
showHead = true;
break;
case REF:
input = new HistoryPageInput(repo);
ref = ((RefNode) repoNode).getObject();
showRef = true;
break;
case ADDITIONALREF:
input = new HistoryPageInput(repo);
ref = ((AdditionalRefNode) repoNode).getObject();
if (ref.getObjectId() == null) {
ref = null;
}
showRef = ref != null;
break;
case TAG:
input = new HistoryPageInput(repo);
ref = ((TagNode) repoNode).getObject();
showTag = true;
break;
default:
input = new HistoryPageInput(repo);
showHead = true;
break;
}
} else if (o instanceof HistoryPageInput) {
input = (HistoryPageInput) o;
repo = input.getRepository();
} else if (o instanceof Path) {
Path path = (Path) o;
repo = ResourceUtil.getRepository(path);
if (repo != null) {
input = new HistoryPageInput(repo,
new File[] { path.toFile() });
}
} else {
IResource resource = AdapterUtils.adaptToAnyResource(o);
if (resource != null) {
RepositoryMapping mapping = RepositoryMapping
.getMapping(resource);
if (mapping != null) {
repo = mapping.getRepository();
input = new HistoryPageInput(repo,
new IResource[] { resource });
}
}
}
if (repo == null) {
GitInfo info = Adapters.adapt(o, GitInfo.class);
if (info != null && info.getRepository() != null) {
repo = info.getRepository();
IPath gitPath = Path.fromPortableString(info.getGitPath());
input = new HistoryPageInput(repo,
new File[] { new File(gitPath.toOSString()) });
} else {
repo = Adapters.adapt(o, Repository.class);
if (repo != null) {
File file = Adapters.adapt(o, File.class);
if (file == null) {
input = new HistoryPageInput(repo);
} else {
input = new HistoryPageInput(repo,
new File[] { file });
}
}
}
}
selection = Adapters.adapt(o, RevCommit.class);
if (input == null || repo == null) {
this.name = ""; //$NON-NLS-1$
setErrorMessage(UIText.GitHistoryPage_NoInputMessage);
return false;
}
final IResource[] inResources = input.getItems();
final File[] inFiles = input.getFileList();
this.name = calculateName(input);
// disable the filters if we have a Repository as input
boolean filtersActive = inResources != null || inFiles != null;
actions.showAllRepoVersionsAction.setEnabled(filtersActive);
// the repository itself has no notion of projects
actions.showAllProjectVersionsAction
.setEnabled(inResources != null);
actions.showAllFolderVersionsAction.setEnabled(filtersActive);
actions.showAllResourceVersionsAction.setEnabled(filtersActive);
setErrorMessage(null);
try {
ObjectId id = null;
if (ref != null) {
id = ref.getLeaf().getObjectId();
} else if (selection != null) {
id = selection.getId();
}
initAndStartRevWalk(false, id);
} catch (IllegalStateException e) {
Activator.handleError(e.getMessage(), e, true);
return false;
}
if (prevSelection != null) {
graph.selectCommitStored(prevSelection);
} else {
if (showHead) {
showHead(repo);
}
if (showRef) {
showRef(ref, repo);
}
if (showTag) {
showTag(ref, repo);
}
if (selection != null) {
graph.selectCommitStored(selection);
}
}
return true;
} finally {
if (trace)
GitTraceLocation.getTrace().traceExit(
GitTraceLocation.HISTORYVIEW.getLocation());
}
}