Search in sources :

Example 1 with Gallery

use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.

the class GalleryTest 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 2 with Gallery

use of org.netxms.nebula.widgets.gallery.Gallery 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 3 with Gallery

use of org.netxms.nebula.widgets.gallery.Gallery 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 4 with Gallery

use of org.netxms.nebula.widgets.gallery.Gallery 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 5 with Gallery

use of org.netxms.nebula.widgets.gallery.Gallery in project netxms by netxms.

the class Bug280635Test 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)

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