Search in sources :

Example 6 with GalleryItem

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();
}
Also used : Gallery(org.netxms.nebula.widgets.gallery.Gallery) DefaultGalleryGroupRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer) DefaultGalleryItemRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem)

Example 7 with GalleryItem

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();
}
Also used : Gallery(org.netxms.nebula.widgets.gallery.Gallery) DefaultGalleryGroupRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer) DefaultGalleryItemRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem)

Example 8 with GalleryItem

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());
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem) LinkedList(java.util.LinkedList)

Example 9 with GalleryItem

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;
}
Also used : GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem)

Example 10 with GalleryItem

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;
}
Also used : GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem) Item(org.eclipse.swt.widgets.Item) Gallery(org.netxms.nebula.widgets.gallery.Gallery) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem) Point(org.eclipse.swt.graphics.Point)

Aggregations

GalleryItem (org.netxms.nebula.widgets.gallery.GalleryItem)19 Gallery (org.netxms.nebula.widgets.gallery.Gallery)11 ArrayList (java.util.ArrayList)5 DefaultGalleryGroupRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer)5 DefaultGalleryItemRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer)5 List (java.util.List)4 LinkedList (java.util.LinkedList)3 TreePath (org.eclipse.jface.viewers.TreePath)3 LibraryImage (org.netxms.client.LibraryImage)3 HashMap (java.util.HashMap)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)2 Image (org.eclipse.swt.graphics.Image)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 ColumnViewerEditorActivationEvent (org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent)1 ViewerCell (org.eclipse.jface.viewers.ViewerCell)1 ViewerRow (org.eclipse.jface.viewers.ViewerRow)1