use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.
the class Bug280635Test method testBug280635.
public void testBug280635() {
final Gallery g = createGallery(SWT.V_SCROLL | SWT.VIRTUAL);
g.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
GalleryItem item = (GalleryItem) event.item;
int index;
if (item.getParentItem() != null) {
index = item.getParentItem().indexOf(item);
item.setItemCount(0);
} else {
index = g.indexOf(item);
item.setItemCount(100);
}
// $NON-NLS-1$
System.out.println("setData index " + index);
// Your image here
// item.setImage(eclipseImage);
// $NON-NLS-1$
item.setText("Item " + index);
}
});
g.setItemCount(1);
g.getItem(0).dispose();
assertEquals(g.getItemCount(), 0);
g.dispose();
}
use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.
the class GalleryVirtualBehaviorTest method testGalleryVirtualNew.
public void testGalleryVirtualNew() {
Gallery widget = createGallery(SWT.V_SCROLL | SWT.VIRTUAL);
final ArrayList<Object> setDataCalls = new ArrayList<Object>();
widget.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
setDataCalls.add(event.item);
}
});
assertEquals(0, widget.getItemCount());
GalleryItem item1 = new GalleryItem(widget, SWT.NONE);
assertEquals(1, widget.getItemCount());
assertEquals(item1, widget.getItem(0));
assertFalse(setDataCalls.contains(item1));
GalleryItem item2 = new GalleryItem(item1, SWT.NONE);
assertEquals(1, widget.getItemCount());
assertEquals(1, item1.getItemCount());
assertEquals(item2, item1.getItem(0));
assertFalse(setDataCalls.contains(item2));
item1.dispose();
assertEquals(0, widget.getItemCount());
assertTrue(item2.isDisposed());
// Test removeAll
item1 = new GalleryItem(widget, SWT.NONE);
assertEquals(1, widget.getItemCount());
assertEquals(item1, widget.getItem(0));
assertFalse(setDataCalls.contains(item1));
widget.removeAll();
assertEquals(0, widget.getItemCount());
}
use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.
the class GalleryVirtualBehaviorTest method createGallery.
private Gallery createGallery(int flags) {
Gallery g = new Gallery(s, flags);
// Renderers
DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
gr.setMinMargin(2);
gr.setItemHeight(56);
gr.setItemWidth(72);
gr.setAutoMargin(true);
g.setGroupRenderer(gr);
DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
g.setItemRenderer(ir);
return g;
}
use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.
the class Bug216204Test method testBug212182OnGallery.
public void testBug212182OnGallery() {
Gallery g = new Gallery(s, SWT.V_SCROLL);
// Set Renderers
DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
g.setGroupRenderer(gr);
DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
g.setItemRenderer(ir);
// Create an item
GalleryItem item1 = new GalleryItem(g, SWT.NONE);
g.setSelection(new GalleryItem[] { item1 });
GalleryItem[] selection = g.getSelection();
assertEquals(1, selection.length);
assertEquals(item1, selection[0]);
// Dispose item
item1.dispose();
selection = g.getSelection();
assertEquals(0, selection.length);
// Create a lot of items
GalleryItem[] items = new GalleryItem[10];
GalleryItem[] children = new GalleryItem[10];
for (int i = 0; i < 10; i++) {
items[i] = new GalleryItem(g, SWT.None);
}
for (int i = 0; i < 10; i++) {
children[i] = new GalleryItem(items[0], SWT.None);
}
assertEquals(10, g.getItemCount());
assertEquals(10, items[0].getItemCount());
g.setSelection(new GalleryItem[] { children[5], items[5] });
selection = g.getSelection();
// This gallery can only have a single selection
assertEquals(1, selection.length);
assertEquals(items[5], selection[0]);
// Clean
g.dispose();
}
use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.
the class Bug276435Test method testBug276435.
public void testBug276435() {
Gallery g = new Gallery(s, SWT.V_SCROLL);
// Set Renderers
DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
g.setGroupRenderer(gr);
DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
g.setItemRenderer(ir);
GalleryItem group = new GalleryItem(g, SWT.NONE);
GalleryItem item1 = new GalleryItem(group, SWT.NONE);
GalleryItem item2 = new GalleryItem(group, SWT.NONE);
g.remove(item2);
assertEquals(0, g.indexOf(group));
assertEquals(0, g.indexOf(item1));
assertEquals(-1, g.indexOf(item2));
g.dispose();
}
Aggregations