Search in sources :

Example 6 with Gallery

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

Example 7 with Gallery

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

Example 8 with Gallery

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

Example 9 with Gallery

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();
}
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 10 with Gallery

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();
}
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)

Aggregations

Gallery (org.netxms.nebula.widgets.gallery.Gallery)16 GalleryItem (org.netxms.nebula.widgets.gallery.GalleryItem)11 DefaultGalleryGroupRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer)10 DefaultGalleryItemRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer)10 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 TreePath (org.eclipse.jface.viewers.TreePath)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 SWTException (org.eclipse.swt.SWTException)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 MenuDetectEvent (org.eclipse.swt.events.MenuDetectEvent)1 MenuDetectListener (org.eclipse.swt.events.MenuDetectListener)1