use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryTest method testClear.
public void testClear() {
Gallery g = createGallery(SWT.V_SCROLL);
// Add content
GalleryItem[] items = new GalleryItem[3];
GalleryItem[][] subItems = new GalleryItem[3][3];
for (int i = 0; i < 3; i++) {
items[i] = new GalleryItem(g, SWT.None);
items[i].setText("i" + i);
for (int j = 0; j < 3; j++) {
subItems[i][j] = new GalleryItem(items[i], SWT.None);
subItems[i][j].setText("si" + i + "_" + j);
}
}
g.clear(0, true);
assertEquals("", items[0].getText());
assertEquals("", subItems[0][0].getText());
assertEquals("", subItems[0][1].getText());
assertEquals("", subItems[0][2].getText());
g.clear(1);
assertEquals("", items[1].getText());
assertFalse("".equals(subItems[1][0].getText()));
assertFalse("".equals(subItems[1][1].getText()));
assertFalse("".equals(subItems[1][2].getText()));
g.clear(2, false);
assertEquals("", items[2].getText());
assertFalse("".equals(subItems[2][0].getText()));
assertFalse("".equals(subItems[2][1].getText()));
assertFalse("".equals(subItems[2][2].getText()));
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryTest method testGalleryAddRemoveClear.
public void testGalleryAddRemoveClear() {
Gallery g = createGallery(SWT.V_SCROLL);
// Create 3 groups
GalleryItem[] items = new GalleryItem[3];
for (int i = 0; i < 3; i++) {
items[i] = new GalleryItem(g, SWT.None);
items[i].setText("i" + i);
}
assertEquals(g.getItemCount(), 3);
// Add content in groups
GalleryItem[][] subItems = new GalleryItem[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
subItems[i][j] = new GalleryItem(items[i], SWT.None);
subItems[i][j].setText("si" + i + "_" + j);
}
assertEquals(items[i].getItemCount(), 3);
}
// dispose si1_1
subItems[1][1].dispose();
assertEquals(2, items[1].getItemCount());
assertEquals("si1_0", items[1].getItem(0).getText());
assertEquals("si1_2", items[1].getItem(1).getText());
// dispose si0
items[0].dispose();
assertEquals(2, g.getItemCount());
assertTrue(subItems[0][1].isDisposed());
// clear si1
items[1].clear();
assertEquals("", items[1].getText());
assertFalse("".equals(subItems[1][0].getText()));
items[1].setText("si1");
// clearAll si1
items[1].clearAll(true);
assertEquals("", subItems[1][0].getText());
g.dispose();
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class Bug212182Test method testBug212182OnGalleryItem.
public void testBug212182OnGalleryItem() {
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 item = new GalleryItem(g, SWT.None);
// Check for NPE or null
GalleryItem[] items = item.getItems();
assertNotNull(items);
assertEquals(0, items.length);
g.dispose();
}
use of org.netxms.nebula.widgets.gallery.GalleryItem 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.GalleryItem 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());
}
Aggregations