public void handleEvent(Event event) {
final GalleryItem item = (GalleryItem) event.item;
final GalleryItem parentItem = item.getParentItem();
if (parentItem == null) {
final int index = gallery.indexOf(item);
final ItemGroup itemGroup = (ItemGroup) images.get(index);
item.setText(itemGroup.getName());
item.setData(itemGroup);
item.setItemCount(itemGroup.getChildCount());
} else {
final int indexOf = parentItem.indexOf(item);
final ItemGroup ga = (ItemGroup) parentItem.getData();
item.setItemCount(0);
final IImageEntry image = ga.getImage(indexOf);
try {
item.setImage(image.getImage());
} catch (IOException e) {
e.printStackTrace();
}