Search in sources :

Example 1 with ImageProvider

use of org.netxms.ui.eclipse.imagelibrary.shared.ImageProvider in project netxms by netxms.

the class ImageSelectionDialog method refreshImages.

/**
 */
private void refreshImages() {
    final ImageProvider provider = ImageProvider.getInstance(getShell().getDisplay());
    final List<LibraryImage> imageLibrary = provider.getImageLibrary();
    Map<String, List<LibraryImage>> categories = new HashMap<String, List<LibraryImage>>();
    for (LibraryImage image : imageLibrary) {
        final String category = image.getCategory();
        final Image swtImage = provider.getImage(image.getGuid());
        final Rectangle bounds = swtImage.getBounds();
        if (bounds.height <= maxHeight && bounds.width <= maxWidth) {
            if (!categories.containsKey(category)) {
                categories.put(category, new ArrayList<LibraryImage>());
            }
            categories.get(category).add(image);
        }
    }
    // this.knownCategories = categories.keySet();
    gallery.removeAll();
    for (String category : categories.keySet()) {
        final GalleryItem categoryItem = new GalleryItem(gallery, SWT.NONE);
        categoryItem.setText(category);
        final List<LibraryImage> categoryImages = categories.get(category);
        for (LibraryImage image : categoryImages) {
            final GalleryItem imageItem = new GalleryItem(categoryItem, SWT.NONE);
            imageItem.setText(image.getName());
            imageItem.setImage(provider.getImage(image.getGuid()));
            imageItem.setData(image);
        }
    }
    gallery.redraw();
}
Also used : HashMap(java.util.HashMap) Rectangle(org.eclipse.swt.graphics.Rectangle) ArrayList(java.util.ArrayList) List(java.util.List) LibraryImage(org.netxms.client.LibraryImage) Image(org.eclipse.swt.graphics.Image) LibraryImage(org.netxms.client.LibraryImage) GalleryItem(org.netxms.nebula.widgets.gallery.GalleryItem) ImageProvider(org.netxms.ui.eclipse.imagelibrary.shared.ImageProvider)

Example 2 with ImageProvider

use of org.netxms.ui.eclipse.imagelibrary.shared.ImageProvider in project netxms by netxms.

the class PredefinedMap method dispose.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.networkmaps.views.NetworkMap#dispose()
	 */
@Override
public void dispose() {
    ImageProvider p = ImageProvider.getInstance(display);
    if (p != null)
        p.removeUpdateListener(this);
    if (defaultLinkColor != null)
        defaultLinkColor.dispose();
    super.dispose();
}
Also used : ImageProvider(org.netxms.ui.eclipse.imagelibrary.shared.ImageProvider)

Aggregations

ImageProvider (org.netxms.ui.eclipse.imagelibrary.shared.ImageProvider)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Image (org.eclipse.swt.graphics.Image)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 LibraryImage (org.netxms.client.LibraryImage)1 GalleryItem (org.netxms.nebula.widgets.gallery.GalleryItem)1