Search in sources :

Example 6 with DefaultGalleryItemRenderer

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

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

the class ImageLibrary method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(final Composite parent) {
    final IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
    // $NON-NLS-1$
    currentIconSize = ps.getInt("IMAGE_LIBRARY.ZOOM");
    if (currentIconSize == 0)
        currentIconSize = MIN_GRID_ICON_SIZE;
    final FillLayout layout = new FillLayout();
    parent.setLayout(layout);
    display = getSite().getShell().getDisplay();
    session = (NXCSession) ConsoleSharedData.getSession();
    gallery = new Gallery(parent, SWT.V_SCROLL | SWT.MULTI);
    DefaultGalleryGroupRenderer galleryGroupRenderer = new DefaultGalleryGroupRenderer();
    galleryGroupRenderer.setMinMargin(2);
    galleryGroupRenderer.setItemHeight(currentIconSize);
    galleryGroupRenderer.setItemWidth(currentIconSize);
    galleryGroupRenderer.setAutoMargin(true);
    galleryGroupRenderer.setAlwaysExpanded(true);
    gallery.setGroupRenderer(galleryGroupRenderer);
    DefaultGalleryItemRenderer itemRenderer = new DefaultGalleryItemRenderer();
    gallery.setItemRenderer(itemRenderer);
    createActions();
    createPopupMenu();
    contributeToActionBars();
    gallery.addMenuDetectListener(new MenuDetectListener() {

        @Override
        public void menuDetected(MenuDetectEvent e) {
            menuEvent = e;
        }
    });
    try {
        refreshImages();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    ImageProvider.getInstance(display).addUpdateListener(this);
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // $NON-NLS-1$
            ps.setValue("IMAGE_LIBRARY.ZOOM", currentIconSize);
            ImageProvider.getInstance(display).removeUpdateListener(ImageLibrary.this);
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) Gallery(org.netxms.nebula.widgets.gallery.Gallery) DefaultGalleryGroupRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) FillLayout(org.eclipse.swt.layout.FillLayout) DefaultGalleryItemRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) DisposeEvent(org.eclipse.swt.events.DisposeEvent) SWTException(org.eclipse.swt.SWTException) IOException(java.io.IOException) NXCException(org.netxms.client.NXCException)

Example 8 with DefaultGalleryItemRenderer

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

the class Bug216204Test method testBug212182OnGalleryMulti.

public void testBug212182OnGalleryMulti() {
    Gallery g = new Gallery(s, SWT.V_SCROLL | SWT.MULTI);
    // 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);
        items[i].setText("G" + i);
    }
    for (int i = 0; i < 10; i++) {
        children[i] = new GalleryItem(items[0], SWT.None);
        children[i].setText("G0-" + i);
    }
    assertEquals(10, g.getItemCount());
    assertEquals(10, items[0].getItemCount());
    g.setSelection(new GalleryItem[] { children[5], items[5] });
    selection = g.getSelection();
    assertEquals(2, selection.length);
    assertEquals(children[5], selection[0]);
    assertEquals(items[5], selection[1]);
    items[0].dispose();
    selection = g.getSelection();
    // Since we disposed the parent of a selected item, it should have been
    // removed from the 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 9 with DefaultGalleryItemRenderer

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

the class Bug212182Test 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);
    // Check for NPE or Null
    GalleryItem[] items = g.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 10 with DefaultGalleryItemRenderer

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

the class ImageSelectionDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    final FillLayout layout = new FillLayout();
    dialogArea.setLayout(layout);
    gallery = new Gallery(dialogArea, SWT.V_SCROLL);
    DefaultGalleryGroupRenderer galleryGroupRenderer = new DefaultGalleryGroupRenderer();
    galleryGroupRenderer.setMinMargin(2);
    galleryGroupRenderer.setItemHeight(48);
    galleryGroupRenderer.setItemWidth(48);
    galleryGroupRenderer.setAutoMargin(true);
    galleryGroupRenderer.setAlwaysExpanded(true);
    gallery.setGroupRenderer(galleryGroupRenderer);
    DefaultGalleryItemRenderer itemRenderer = new DefaultGalleryItemRenderer();
    gallery.setItemRenderer(itemRenderer);
    gallery.addSelectionListener(this);
    gallery.addMouseListener(this);
    ImageProvider.getInstance(getShell().getDisplay()).addUpdateListener(this);
    refreshImages();
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Gallery(org.netxms.nebula.widgets.gallery.Gallery) DefaultGalleryGroupRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer) FillLayout(org.eclipse.swt.layout.FillLayout) DefaultGalleryItemRenderer(org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer)

Aggregations

DefaultGalleryGroupRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryGroupRenderer)10 DefaultGalleryItemRenderer (org.netxms.nebula.widgets.gallery.DefaultGalleryItemRenderer)10 Gallery (org.netxms.nebula.widgets.gallery.Gallery)10 GalleryItem (org.netxms.nebula.widgets.gallery.GalleryItem)5 FillLayout (org.eclipse.swt.layout.FillLayout)2 IOException (java.io.IOException)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)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 Composite (org.eclipse.swt.widgets.Composite)1 NXCException (org.netxms.client.NXCException)1