add(new ListView("relatedItems", new ArrayList(item.getRelatedItems())) {
/* (non-Javadoc)
* @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
*/
protected void populateItem(ListItem listItem) {
final ItemItem itemItem = (ItemItem) listItem.getModelObject();
String message = null;
if (itemItem.getType() == DUPLICATE_OF) {
message = localize("item_view.duplicateOf");
} else if (itemItem.getType() == DEPENDS_ON) {
message = localize("item_view.dependsOn");
} else if (itemItem.getType() == RELATED) {
message = localize("item_view.relatedTo");
}
final String refId = itemItem.getRelatedItem().getRefId();
if (hideLinks) {
message = message + " " + refId;
}
listItem.add(new Label("message", message));
Link link = new Link("link") {
public void onClick() {
setResponsePage(ItemViewPage.class, new PageParameters("0=" + refId));
}
};
link.add(new Label("refId", refId));
link.setVisible(!hideLinks);
listItem.add(link);
listItem.add(new Link("remove") {
public void onClick() {
setResponsePage(new ItemRelateRemovePage(item.getId(), itemItem));
}
}.setVisible(!hideLinks));
}
});
} else {
add(new WebMarkupContainer("relatedItems").setVisible(false));
}
if (item.getRelatingItems() != null) {
add(new ListView("relatingItems", new ArrayList(item.getRelatingItems())) {
/* (non-Javadoc)
* @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem)
*/
protected void populateItem(ListItem listItem) {
final ItemItem itemItem = (ItemItem) listItem.getModelObject();
/*
* This looks very similar to related items block above
* but the display strings could be different and in
* future handling of the inverse of the bidirectional
* link could be different as well.
*/
String message = null;
if (itemItem.getType() == DUPLICATE_OF) {
message = localize("item_view.duplicateOfThis");
} else if (itemItem.getType() == DEPENDS_ON) {
message = localize("item_view.dependsOnThis");
} else if (itemItem.getType() == RELATED) {
message = localize("item_view.relatedToThis");
}
final String refId = itemItem.getItem().getRefId();
if (hideLinks) {
message = refId + " " + message;
}
listItem.add(new Label("message", message));