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.xtend.check.ui.editor.EditorImages.java

License:Open Source License

/**
 * Declare an Image in the registry table.
 * /*  ww  w . j  a  va2 s  .  co  m*/
 * @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)
 */
private final static void declareRegistryImage(final String key, final String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    try {
        desc = ImageDescriptor.createFromURL(makeIconFileURL(path));
    } catch (final MalformedURLException me) {
        XtendLog.logError(me);
    }
    EditorImages.imageRegistry.put(key, desc);
}

From source file:org.eclipse.xtext.ui.PluginImageHelper.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * /*www.ja va 2  s  .  co m*/
 * @param descriptor
 *            the image descriptor for which the helper manages an image, or <code>null</code> for a missing image
 *            descriptor
 * @return the image associated with the image descriptor or <code>null</code> if the image descriptor can't create
 *         the requested image.
 */
@Override
public Image getImage(ImageDescriptor descriptor) {
    if (descriptor == null) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
    }

    Image result = registry.get(descriptor);
    if (result != null) {
        return result;
    }
    result = descriptor.createImage();
    if (result != null) {
        registry.put(descriptor, result);
    }
    return result;
}

From source file:org.elbe.relations.RelationsImages.java

License:Open Source License

private static Image createImage(final String inName, final ImageDescriptor inDescriptor) {
    ImageDescriptor lDescriptor = null;/*from  w  ww .j  av a 2  s.  c om*/
    try {
        lDescriptor = ImageDescriptor.createFromURL(Activator.getEntry(ICONS_DIR + inName));
    } catch (final Exception exc) {
        lDescriptor = ImageDescriptor.getMissingImageDescriptor();
    }
    return lDescriptor.createImage();
}

From source file:org.emftext.language.xpath2.resource.xpath2.ui.Xpath2ImageProvider.java

License:Open Source License

/**
 * Returns the image for the given key. Possible keys are:
 * <ul>/*from w w w  . j a  v  a 2 s . co m*/
 * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
 * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
 * </ul>
 */
public ImageDescriptor getImageDescriptor(String key) {
    IPath path = new Path(key);
    org.emftext.language.xpath2.resource.xpath2.ui.Xpath2UIPlugin plugin = org.emftext.language.xpath2.resource.xpath2.ui.Xpath2UIPlugin
            .getDefault();
    if (plugin == null) {
        return null;
    }

    ImageDescriptor descriptor = ImageDescriptor
            .createFromURL(FileLocator.find(plugin.getBundle(), path, null));
    if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
        // try loading image from any bundle
        try {
            URL pluginUrl = new URL(key);
            descriptor = ImageDescriptor.createFromURL(pluginUrl);
            if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
                return null;
            }
        } catch (MalformedURLException mue) {
            org.emftext.language.xpath2.resource.xpath2.ui.Xpath2UIPlugin
                    .logError("IconProvider can't load image (URL is malformed).", mue);
        }
    }
    return descriptor;
}

From source file:org.emftext.language.xpath3.resource.xpath3.ui.Xpath3ImageProvider.java

License:Open Source License

/**
 * <p>/*from ww  w  .  j av a2 s  .co m*/
 * Returns the image for the given key. Possible keys are:
 * </p>
 * <p>
 * <ul>
 * </p>
 * <p>
 * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
 * </p>
 * <p>
 * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
 * </p>
 * <p>
 * </ul>
 * </p>
 */
public ImageDescriptor getImageDescriptor(String key) {
    IPath path = new Path(key);
    org.emftext.language.xpath3.resource.xpath3.ui.Xpath3UIPlugin plugin = org.emftext.language.xpath3.resource.xpath3.ui.Xpath3UIPlugin
            .getDefault();
    if (plugin == null) {
        return null;
    }

    ImageDescriptor descriptor = ImageDescriptor
            .createFromURL(FileLocator.find(plugin.getBundle(), path, null));
    if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
        // try loading image from any bundle
        try {
            URL pluginUrl = new URL(key);
            descriptor = ImageDescriptor.createFromURL(pluginUrl);
            if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
                return null;
            }
        } catch (MalformedURLException mue) {
            org.emftext.language.xpath3.resource.xpath3.ui.Xpath3UIPlugin
                    .logError("IconProvider can't load image (URL is malformed).", mue);
        }
    }
    return descriptor;
}

From source file:org.emftext.sdk.concretesyntax.resource.cs.ui.CsImageProvider.java

License:Open Source License

/**
 * <p>/*from  w  w  w  . j a  va 2s .  co  m*/
 * Returns the image for the given key. Possible keys are:
 * </p>
 * <p>
 * <ul>
 * </p>
 * <p>
 * <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
 * </p>
 * <p>
 * <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
 * </p>
 * <p>
 * </ul>
 * </p>
 */
public ImageDescriptor getImageDescriptor(String key) {
    IPath path = new Path(key);
    org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIPlugin plugin = org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIPlugin
            .getDefault();
    if (plugin == null) {
        return null;
    }

    ImageDescriptor descriptor = ImageDescriptor
            .createFromURL(FileLocator.find(plugin.getBundle(), path, null));
    if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
        // try loading image from any bundle
        try {
            URL pluginUrl = new URL(key);
            descriptor = ImageDescriptor.createFromURL(pluginUrl);
            if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
                return null;
            }
        } catch (MalformedURLException mue) {
            org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIPlugin
                    .logError("IconProvider can't load image (URL is malformed).", mue);
        }
    }
    return descriptor;
}

From source file:org.erlide.ui.ErlideImage.java

License:Open Source License

private static void registerAllImages() {
    for (final ErlideImage key : values()) {
        ImageDescriptor descriptor;/*from  www . j av  a2s  . co m*/
        try {
            final URL url = key.url();
            descriptor = ImageDescriptor.createFromURL(url);
        } catch (final MalformedURLException e) {
            descriptor = ImageDescriptor.getMissingImageDescriptor();
        }
        registry.put(key.name(), descriptor);
    }
}

From source file:org.erlide.ui.ErlideUIDebugImages.java

License:Open Source License

/**
 * Declare an Image in the registry table.
 * /*from w w  w .  j a  v  a  2s. c o  m*/
 * @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)
 */
private final static void declareRegistryImage(final String key, final String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    try {
        desc = ImageDescriptor.createFromURL(makeIconFileURL(path));
    } catch (final MalformedURLException me) {
        // ErlideUIPlugin.log(me);
    }
    fgImageRegistry.put(key, desc);
}

From source file:org.erlide.ui.ErlideUIPluginImages.java

License:Open Source License

private static ImageDescriptor createManaged(final String prefix, final String name) {
    try {/*from w  w  w  . jav a 2s  .  c  o m*/
        final ImageDescriptor result = ImageDescriptor
                .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
        if (fgAvoidSWTErrorMap == null) {
            fgAvoidSWTErrorMap = new HashMap<String, ImageDescriptor>();
        }
        fgAvoidSWTErrorMap.put(name, result);
        if (fgImageRegistry != null) {
            ErlideUIPlugin.logErrorMessage("Image registry already defined");
        }
        return result;
    } catch (final MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.erlide.ui.ErlideUIPluginImages.java

License:Open Source License

private static ImageDescriptor create(final String prefix, final String name) {
    try {/*from   w ww . java 2s  .  c o  m*/
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (final MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}