super.dispose();
}
private Image decorateImage(final Image image, Object element) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
switch (node.getType()) {
case TAG:
// fall through
case ADDITIONALREF:
// fall through
case REF:
// if the branch or tag is checked out,
// we want to decorate the corresponding
// node with a little check indicator
String refName = ((Ref) node.getObject()).getName();
Ref leaf = ((Ref) node.getObject()).getLeaf();
String branchName;
String compareString;
try {
branchName = node.getRepository().getFullBranch();
if (branchName == null)
return image;
if (refName.startsWith(Constants.R_HEADS)) {
// local branch: HEAD would be on the branch
compareString = refName;
} else if (refName.startsWith(Constants.R_TAGS)) {
// tag: HEAD would be on the commit id to which the tag is
// pointing
TagNode tagNode = (TagNode) node;
compareString = tagNode.getCommitId();
} else if (refName.startsWith(Constants.R_REMOTES)) {
// remote branch: HEAD would be on the commit id to which
// the branch is pointing
ObjectId id = node.getRepository().resolve(refName);
if (id == null)
return image;
RevWalk rw = new RevWalk(node.getRepository());
try {
RevCommit commit = rw.parseCommit(id);
compareString = commit.getId().name();
} finally {
rw.release();
}
} else if (refName.equals(Constants.HEAD))
return getDecoratedImage(image);
else {
String leafname = leaf.getName();
if (leafname.startsWith(Constants.R_REFS)
&& leafname.equals(node.getRepository()
.getFullBranch()))
return getDecoratedImage(image);
else if (leaf.getObjectId().equals(
node.getRepository().resolve(Constants.HEAD)))
return getDecoratedImage(image);
// some other symbolic reference
return image;
}
} catch (IOException e1) {