Example usage for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor

List of usage examples for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor getMissingImageDescriptor.

Prototype

public static ImageDescriptor getMissingImageDescriptor() 

Source Link

Document

Returns the shared image descriptor for a missing image.

Usage

From source file:org.eclipse.wst.jsdt.debug.internal.rhino.ui.RhinoImageRegistry.java

License:Open Source License

/**
 * Declare an Image in the registry table.
 * @param key    The key to use when registering the image
 * @param path   The path where the image can be found. This path is relative to where
 *            this plugin class is found (i.e. typically the packages directory)
 *///from w  w w.  j ava 2  s .  com
private final static void declareRegistryImage(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    Bundle bundle = Platform.getBundle(RhinoUIPlugin.PLUGIN_ID);
    URL url = null;
    if (bundle != null) {
        url = FileLocator.find(bundle, new Path(path), null);
        if (url != null) {
            desc = ImageDescriptor.createFromURL(url);
        }
    }
    imageRegistry.put(key, desc);
}

From source file:org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptImageRegistry.java

License:Open Source License

/**
 * Declare an Image in the registry table.
 * @param key    The key to use when registering the image
 * @param path   The path where the image can be found. This path is relative to where
 *            this plugin class is found (i.e. typically the packages directory)
 *//*from   www  . j  a  v a2s. c om*/
private final static void declareRegistryImage(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    Bundle bundle = Platform.getBundle(JavaScriptDebugUIPlugin.PLUGIN_ID);
    URL url = null;
    if (bundle != null) {
        url = FileLocator.find(bundle, new Path(path), null);
        if (url != null) {
            desc = ImageDescriptor.createFromURL(url);
        }
    }
    imageRegistry.put(key, desc);
}

From source file:org.eclipse.wst.jsdt.internal.ui.compare.JavaCompareUtilities.java

License:Open Source License

static ImageDescriptor getImageDescriptor(int type) {
    switch (type) {
    case IJavaScriptElement.INITIALIZER:
    case IJavaScriptElement.METHOD:
        return getImageDescriptor("obj16/compare_method.gif"); //$NON-NLS-1$         
    case IJavaScriptElement.FIELD:
        return getImageDescriptor("obj16/compare_field.gif"); //$NON-NLS-1$
    case IJavaScriptElement.IMPORT_DECLARATION:
        return JavaPluginImages.DESC_OBJS_IMPDECL;
    case IJavaScriptElement.IMPORT_CONTAINER:
        return JavaPluginImages.DESC_OBJS_IMPCONT;
    case IJavaScriptElement.JAVASCRIPT_UNIT:
        return JavaPluginImages.DESC_OBJS_CUNIT;
    }/*from   w  w  w .  j ava2 s .  c  om*/
    return ImageDescriptor.getMissingImageDescriptor();
}

From source file:org.eclipse.wst.json.bower.ui.internal.editor.BowerEditorPluginImageHelper.java

License:Open Source License

/**
 * Creates an image from the given resource and adds the image to the image
 * registry.//from   www . ja v  a 2 s  .com
 * 
 * @param resource
 * @return Image
 */
private Image createImage(String resource) {
    ImageDescriptor desc = getImageDescriptor(resource);
    Image image = null;

    if (desc != null) {
        image = desc.createImage();
        // dont add the missing image descriptor image to the image
        // registry
        if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) {
            getImageRegistry().put(resource, image);
        }
    }
    return image;
}

From source file:org.eclipse.wst.server.discovery.internal.ImageResource.java

License:Open Source License

/**
 * Return the image with the given key.//from  w  ww .  ja v a  2  s .  c o  m
 *
 * @param key a key
 * @return an image
 */
public static Image getImage(String key) {
    if (imageRegistry == null)
        initializeImageRegistry();
    Image image = imageRegistry.get(key);
    if (image == null) {
        imageRegistry.put(key, ImageDescriptor.getMissingImageDescriptor());
        image = imageRegistry.get(key);
    }
    return image;
}

From source file:org.eclipse.wst.server.ui.internal.ImageResource.java

License:Open Source License

/**
 * Load the server images./*w ww. ja v a 2 s.  c o  m*/
 */
private static void loadServerImages(IConfigurationElement[] cf) {
    int size = cf.length;
    for (int i = 0; i < size; i++) {
        try {
            String name = cf[i].getDeclaringExtension().getContributor().getName();
            String iconPath = cf[i].getAttribute("icon");
            ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(name, iconPath);
            if (imageDescriptor == null && iconPath != null && iconPath.length() > 0)
                imageDescriptor = ImageDescriptor.getMissingImageDescriptor();

            if (imageDescriptor != null) {
                String[] typeIds = ServerUIPlugin.tokenize(cf[i].getAttribute("typeIds"), ",");
                int size2 = typeIds.length;
                for (int j = 0; j < size2; j++) {
                    imageRegistry.put(typeIds[j], imageDescriptor);
                    imageDescriptors.put(typeIds[j], imageDescriptor);
                }
            }
            if (Trace.CONFIG) {
                Trace.trace(Trace.STRING_CONFIG, "  Loaded serverImage: " + cf[i].getAttribute("id"));
            }
        } catch (Throwable t) {
            if (Trace.SEVERE) {
                Trace.trace(Trace.STRING_SEVERE, "  Could not load serverImage: " + cf[i].getAttribute("id"),
                        t);
            }
        }
    }
}

From source file:org.eclipse.wst.xml.ui.internal.wizards.XMLWizard.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String name) {
    try {//  w  w  w. ja  va  2  s.  c  o m
        URL url = new URL(Platform.getBundle("org.eclipse.wst.xml.ui").getEntry("/"), name); //$NON-NLS-1$ //$NON-NLS-2$
        return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.eclipse.wst.xml.xpath.ui.internal.util.XPathPluginImageHelper.java

License:Open Source License

/**
 * Creates an image descriptor from the given imageFilePath and adds the
 * image descriptor to the image descriptor registry. If an image descriptor
 * could not be created, the default "missing" image descriptor is returned
 * but not added to the image descriptor registry.
 * // ww w .  ja  va  2 s  . c  o  m
 * @param imageFilePath
 * @return ImageDescriptor image descriptor for imageFilePath or default
 *         "missing" image descriptor if resource could not be found
 */
@SuppressWarnings("unchecked")
private ImageDescriptor createImageDescriptor(String imageFilePath) {
    ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(XPathUIPlugin.PLUGIN_ID,
            imageFilePath);
    if (imageDescriptor != null) {
        getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
    } else {
        imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
    }

    return imageDescriptor;
}

From source file:org.eclipse.wst.xsl.debug.internal.util.XSLPluginImageHelper.java

License:Open Source License

/**
 * Creates an image descriptor from the given imageFilePath and adds the
 * image descriptor to the image descriptor registry. If an image descriptor
 * could not be created, the default "missing" image descriptor is returned
 * but not added to the image descriptor registry.
 * //from  ww w.ja  v  a2  s  .  c o  m
 * @param imageFilePath
 * @return ImageDescriptor image descriptor for imageFilePath or default
 *         "missing" image descriptor if resource could not be found
 */
@SuppressWarnings("unchecked")
private ImageDescriptor createImageDescriptor(String imageFilePath) {
    ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath);
    if (imageDescriptor != null) {
        getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
    } else {
        imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
    }

    return imageDescriptor;
}

From source file:org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper.java

License:Open Source License

/**
 * Creates an image descriptor from the given imageFilePath and adds the
 * image descriptor to the image descriptor registry. If an image
 * descriptor could not be created, the default "missing" image descriptor
 * is returned but not added to the image descriptor registry.
 * /*w w w . j  av a2  s  . c om*/
 * @param imageFilePath
 * @return ImageDescriptor image descriptor for imageFilePath or default
 *         "missing" image descriptor if resource could not be found
 */
@SuppressWarnings("unchecked")
private ImageDescriptor createImageDescriptor(String imageFilePath) {
    ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(XSLUIPlugin.PLUGIN_ID,
            imageFilePath);
    if (imageDescriptor != null) {
        getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
    } else {
        imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
    }

    return imageDescriptor;
}