Search in sources :

Example 31 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project meclipse by flaper87.

the class ViewLabelProvider method getImage.

public Image getImage(Object obj) {
    String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
    ImageRegistry imgReg = MeclipsePlugin.getDefault().getImageRegistry();
    if (obj instanceof Connection) {
        if (((Connection) obj).getMongo() != null) {
            return imgReg.get(MeclipsePlugin.CONNECTION_IMG_ID);
        } else {
            return imgReg.get(MeclipsePlugin.CONNECTION_ERROR_IMG_ID);
        }
    }
    if (obj instanceof Database) {
        return imgReg.get(MeclipsePlugin.DATABASE_IMG_ID);
    }
    if (obj instanceof Collection) {
        return imgReg.get(MeclipsePlugin.COLLECTION_IMG_ID);
    }
    if (obj instanceof Filter) {
        return imgReg.get(MeclipsePlugin.FILTER_IMG_ID);
    }
    if (obj instanceof TreeParent)
        imageKey = ISharedImages.IMG_OBJ_FOLDER;
    return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry)

Example 32 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project eclipse.platform.text by eclipse.

the class XMLCompletionProcessor method getImage.

/**
 * Always return the default image.
 *
 * @param template the template, ignored in this implementation
 * @return the default template image
 */
@Override
protected Image getImage(Template template) {
    ImageRegistry registry = TemplateEditorUI.getDefault().getImageRegistry();
    Image image = registry.get(DEFAULT_IMAGE);
    if (image == null) {
        // $NON-NLS-1$
        ImageDescriptor desc = TemplateEditorUI.imageDescriptorFromPlugin("org.eclipse.ui.examples.javaeditor", DEFAULT_IMAGE);
        registry.put(DEFAULT_IMAGE, desc);
        image = registry.get(DEFAULT_IMAGE);
    }
    return image;
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

Example 33 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project knime-core by knime.

the class KNIMEUIPlugin method getImage.

/**
 * Returns a (cached) image from the image registry.
 *
 * @param descriptor The image descriptor
 * @return The image, or a default image if missing.
 */
public Image getImage(final ImageDescriptor descriptor) {
    if (descriptor == null) {
        return null;
    }
    // create the registry if needed
    if (m_imageRegistry == null) {
        m_imageRegistry = new ImageRegistry();
    }
    // try to lookup previously cached image
    Image img = m_imageRegistry.get(descriptor.toString());
    // requests
    if (img == null) {
        img = descriptor.createImage(true);
        m_imageRegistry.put(descriptor.toString(), img);
    }
    return img;
}
Also used : ThreadsafeImageRegistry(org.knime.workbench.core.util.ThreadsafeImageRegistry) ImageRegistry(org.eclipse.jface.resource.ImageRegistry) Image(org.eclipse.swt.graphics.Image)

Example 34 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project knime-core by knime.

the class KNIMERepositoryPlugin method getImage.

/**
 * Returns a (cached) image from the image registry.
 *
 * @param descriptor The image descriptor
 * @return The image, or a default image if missing.
 */
public Image getImage(final ImageDescriptor descriptor) {
    if (descriptor == null) {
        return null;
    }
    // create the registry if needed
    if (m_imageRegistry == null) {
        // this has to be done when KNIME is started without the eclipse GUI
        if (Display.getCurrent() == null) {
            Display.getDefault();
            assert Display.getCurrent() != null;
        }
        m_imageRegistry = new ImageRegistry();
    }
    // try to lookup previously cached image
    Image img = m_imageRegistry.get(descriptor.toString());
    // requests
    if (img == null) {
        img = descriptor.createImage(true);
        m_imageRegistry.put(descriptor.toString(), img);
    }
    return img;
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) Image(org.eclipse.swt.graphics.Image)

Example 35 with ImageRegistry

use of org.eclipse.jface.resource.ImageRegistry in project yamcs-studio by yamcs.

the class AutoCompleteUIPlugin method getImageFromPlugin.

/**
 * Load the <code>Image</code> from the given path in the given plugin.
 *
 * @param pluginId
 *            The id of the plugin that contains the requested image.
 * @param relativePath
 *            The resource path of the requested image.
 * @return The <code>Image</code> from the given path in the given plugin.
 */
public Image getImageFromPlugin(final String pluginId, final String relativePath) {
    if (imageRegistry == null) {
        imageRegistry = new ImageRegistry(Display.getDefault());
    }
    // $NON-NLS-1$
    String key = pluginId + "." + relativePath;
    // does image exist
    if (imageRegistry.get(key) == null) {
        ImageDescriptor descr = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, relativePath);
        imageRegistry.put(key, descr);
    }
    return imageRegistry.get(key);
}
Also used : ImageRegistry(org.eclipse.jface.resource.ImageRegistry) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Aggregations

ImageRegistry (org.eclipse.jface.resource.ImageRegistry)63 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)25 Image (org.eclipse.swt.graphics.Image)22 URL (java.net.URL)4 ResourceBundle (java.util.ResourceBundle)4 Before (org.junit.Before)4 CoreRuntimePlugin (org.talend.core.runtime.CoreRuntimePlugin)4 CompositeMultiImageDescriptor (com.archimatetool.editor.ui.components.CompositeMultiImageDescriptor)3 ResourceImageDescriptor (de.jaret.util.ui.ResourceImageDescriptor)3 CompositeImageDescriptor (org.eclipse.jface.resource.CompositeImageDescriptor)3 Label (org.eclipse.swt.widgets.Label)3 RepositoryContext (org.talend.core.context.RepositoryContext)3 Project (org.talend.core.model.general.Project)3 User (org.talend.core.model.properties.User)3 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)3 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)3 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)3 IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)3 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)3 RecycleBinNodeConfiguration (org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration)3