use of org.netxms.nebula.widgets.gallery.GalleryItem 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.GalleryItem 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();
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryViewerRow method getTreePath.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ViewerRow#getTreePath()
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public TreePath getTreePath() {
LinkedList path = new LinkedList();
path.add(item.getData());
GalleryItem curItem = item;
while (curItem.getParentItem() != null) {
path.addFirst(curItem.getParentItem().getData());
curItem = curItem.getParentItem();
}
return new TreePath(path.toArray());
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryViewerRow method getRowAbove.
protected ViewerRow getRowAbove() {
if (item.getParentItem() == null) {
int index = item.getParent().indexOf(item) - 1;
if (index >= 0) {
return new GalleryViewerRow(item.getParent().getItem(index));
}
} else {
GalleryItem parentItem = item.getParentItem();
int index = parentItem.indexOf(item) - 1;
if (index >= 0) {
return new GalleryViewerRow(parentItem.getItem(index));
}
}
return null;
}
use of org.netxms.nebula.widgets.gallery.GalleryItem in project netxms by netxms.
the class GalleryTreeViewer method getSelection.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.viewers.AbstractTreeViewer#getSelection(org.eclipse
* .swt.widgets.Control)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Item[] getSelection(Control control) {
Item[] selection = ((Gallery) control).getSelection();
if (selection == null) {
return new GalleryItem[0];
}
List notDisposed = new ArrayList(selection.length);
for (int i = 0; i < selection.length; i++) {
if (!selection[i].isDisposed()) {
notDisposed.add(selection[i]);
} else {
System.out.println("GalleryItem was disposed (ignoring)");
}
}
selection = (GalleryItem[]) notDisposed.toArray(new GalleryItem[notDisposed.size()]);
return selection;
}
Aggregations