private static final long serialVersionUID = 1L;
int counter;
@Override
public void populateItem(final Item<RefModel> item) {
RefModel entry = item.getModelObject();
item.add(WicketUtils.createDateLabel("tagDate", entry.getDate(), getTimeZone(), getTimeUtils()));
Class<? extends WebPage> linkClass;
switch (entry.getReferencedObjectType()) {
case Constants.OBJ_BLOB:
linkClass = BlobPage.class;
break;
case Constants.OBJ_TREE:
linkClass = TreePage.class;
break;
case Constants.OBJ_COMMIT:
default:
linkClass = CommitPage.class;
break;
}
item.add(new LinkPanel("tagName", "list name", entry.displayName, linkClass,
WicketUtils.newObjectParameter(repositoryName, entry
.getReferencedObjectId().getName())));
// workaround for RevTag returning a lengthy shortlog. :(
String message = StringUtils.trimString(entry.getShortMessage(),
com.gitblit.Constants.LEN_SHORTLOG);
if (linkClass.equals(BlobPage.class)) {
// Blob Tag Object
item.add(WicketUtils.newImage("tagIcon", "file_16x16.png"));
LinkPanel messageLink = new LinkPanel("tagDescription", "list", message, TagPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()
.getName()));
if (!entry.getShortMessage().equals(message)) {
messageLink.setTooltip(entry.getShortMessage());
}
item.add(messageLink);
Fragment fragment = new Fragment("tagLinks", "blobLinks", this);
fragment.add(new BookmarkablePageLink<Void>("tag", TagPage.class, WicketUtils
.newObjectParameter(repositoryName, entry.getObjectId().getName()))
.setEnabled(entry.isAnnotatedTag()));
fragment.add(new BookmarkablePageLink<Void>("blob", linkClass, WicketUtils
.newObjectParameter(repositoryName, entry.getReferencedObjectId()
.getName())));
String contextUrl = RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot();
String rawUrl = RawServlet.asLink(contextUrl, repositoryName, entry.displayName,
entry.getReferencedObjectId().getName());
fragment.add(new ExternalLink("raw", rawUrl));
item.add(fragment);
} else {
// TODO Tree Tag Object
// Standard Tag Object
if (entry.isAnnotatedTag()) {
item.add(WicketUtils.newImage("tagIcon", "tag_16x16.png"));
LinkPanel messageLink = new LinkPanel("tagDescription", "list", message, TagPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()
.getName()));
if (!message.equals(entry.getShortMessage())) {
messageLink.setTooltip(entry.getShortMessage());
}
item.add(messageLink);
Fragment fragment = new Fragment("tagLinks", "annotatedLinks", this);
fragment.add(new BookmarkablePageLink<Void>("tag", TagPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()
.getName())).setEnabled(entry.isAnnotatedTag()));
fragment.add(new BookmarkablePageLink<Void>("commit", linkClass,
WicketUtils.newObjectParameter(repositoryName, entry
.getReferencedObjectId().getName())));
fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getName())));
item.add(fragment);
} else {
item.add(WicketUtils.newBlankImage("tagIcon"));
item.add(new LinkPanel("tagDescription", "list", message, CommitPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()
.getName())));
Fragment fragment = new Fragment("tagLinks", "lightweightLinks", this);
fragment.add(new BookmarkablePageLink<Void>("commit", CommitPage.class,
WicketUtils.newObjectParameter(repositoryName, entry
.getReferencedObjectId().getName())));
fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getName())));
item.add(fragment);
}
}
WicketUtils.setAlternatingBackground(item, counter);