@Override
protected void populateItem(Item item) {
try {
if (item.getModelObject() instanceof Image){
Image imageProperties = (Image) item.getModelObject();
if (!imageProperties.getFile().getCanonicalPath().startsWith(
settings.getImageDirectoryRoot().getCanonicalPath()))
throw new RuntimeException("Requested image directory not within the root image directory");
WebMarkupContainer link;
String imagePath = imageUtils.getRelativePath(imageProperties.getFile());
PageParameters params = new PageParameters();
params.add("uri", imagePath);
item.add(link = new WebMarkupContainer("link"));
link.add(new AttributeModifier("href", true, new Model(getRequest()
.getRelativePathPrefixToContextRoot()
+ PickwickApplication.IMAGE_PAGE_PATH + "/" + imagePath)));
WebComponent image;
link.add(image = new WebComponent("thumbnail"));
image.add(new AttributeModifier("src", true, new Model(getRequest()
.getRelativePathPrefixToContextRoot()
+ PickwickApplication.THUMBNAIL_IMAGE_PATH + "/" + imagePath)));
link.add(new Label("thumbnailLabel", imageProperties.getTitle()));
} else if (item.getModelObject() instanceof Folder){
final Folder folder = (Folder) item.getModelObject();
Sequence sequence = imageUtils.readSequence(folder.getFile());
WebMarkupContainer link;
item.add(link = new WebMarkupContainer("link"){