final Gallery gallery = new Gallery(cm, SWT.VIRTUAL | SWT.V_SCROLL | SWT.BORDER);
item.setControl(cm);
gallery.setVertical(false);
final DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
gallery.setGroupRenderer(gr);
gallery.setItemRenderer(new DefaultGalleryItemRenderer() {
protected Image getImage(GalleryItem item) {
final IImageEntry entry = (IImageEntry) item.getData();
try {
return ImageCache.getImage(entry);
} catch (final Exception e) {
e.printStackTrace();
}
return null;
}
});
final DragSource dragSource = new DragSource(gallery, DND.DROP_COPY);
dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dragSource.addDragListener(new DragSourceListener() {
private String[] dataX;
public void dragFinished(DragSourceEvent event) {
this.dataX = null;
}
public void dragSetData(DragSourceEvent event) {
event.data = this.dataX;
}
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());