Search in sources :

Example 1 with GalleryItem

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

Example 2 with GalleryItem

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

Example 3 with GalleryItem

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

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

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

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