}
public void dragStart(DragSourceEvent event) {
event.detail = DND.DROP_COPY;
final GalleryItem item2 = gallery.getItem(new Point(event.x, event.y));
if (item2 != null) {
final Object data = item2.getData();
if (data instanceof IImageEntry) {
final IImageEntry e = (IImageEntry) data;
final String file = e.getFile();
this.dataX = new String[] { file };
try {
event.image = e.getImage();
} catch (final IOException e1) {
e1.printStackTrace();
}
}
}
}
});
final IImageEntryCallback cb = new IImageEntryCallback() {
public void imageLoaded() {
gallery.redraw();
}
};
ImageCache.addCallback(cb);
gallery.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
ImageCache.removeCallback(cb);
}
});
item.setData("g", gr);
gr.setItemHeight(56);
gr.setItemWidth(72);
this.fillContextMenu(gallery, gr);
this.tooltip = new ImagesViewTooltip(gallery, gallery);
final ArrayList<Object> images = new ArrayList<Object>(store.getContents());
this.prepareImages(images);
gallery.addListener(SWT.SetData, new Listener() {
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();
}
item.setText(image.getName());
item.setData(image);
}
}
});
final HashSet<Object> expanded = new HashSet<Object>();
item.setData("ga", new Collapser() {
void collapse() {
for (int a = 0; a < gallery.getItemCount(); a++) {
final GalleryItem item2 = gallery.getItem(a);
item2.setExpanded(false);
}
expanded.clear();
}
void expand() {
for (int a = 0; a < gallery.getItemCount(); a++) {
final GalleryItem item2 = gallery.getItem(a);
item2.setExpanded(true);
expanded.add(item2.getData());
}
}
});
gallery.addTreeListener(new TreeListener() {