Example usage for org.eclipse.jface.resource ResourceLocator imageDescriptorFromBundle

List of usage examples for org.eclipse.jface.resource ResourceLocator imageDescriptorFromBundle

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ResourceLocator imageDescriptorFromBundle.

Prototype

public static Optional<ImageDescriptor> imageDescriptorFromBundle(Class<?> classFromBundle,
        String imageFilePath) 

Source Link

Document

Returns a new Optional < ImageDescriptor > for an image file located within the specified bundle or Optional#empty() .

Usage

From source file:org.eclipse.n4js.json.ui.labeling.JSONImageDescriptorCache.java

License:Open Source License

private synchronized Optional<ImageDescriptor> getImageDescriptor(final ImageRef ref) {
    final JsonActivator activator = JsonActivator.getInstance();
    if (null == activator) {
        return absent();
    }/*from ww w .j a  v a2  s  . c  o m*/
    final ImageRegistry registry = activator.getImageRegistry();
    if (null == registry) {
        return absent();
    }
    ImageDescriptor descriptor = registry.getDescriptor(ref.fileName);
    if (null == descriptor) {
        final String imageFilePath = ICON_FOLDER + separator + ref.fileName;
        descriptor = ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, imageFilePath).orElse(null);
        registry.put(ref.fileName, descriptor);
    }
    return Optional.fromNullable(descriptor);
}

From source file:org.eclipse.n4js.product.N4ProductActivator.java

License:Open Source License

/**
 * Returns an image descriptor for the image file at the given plug-in relative path.
 *
 * @param path/*from w w  w .  j av  a  2s  .  c om*/
 *            the path.
 * @return the image descriptor.
 */
public static ImageDescriptor getImageDescriptor(final String path) {
    return ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, path).orElse(null);
}

From source file:org.eclipse.n4js.tester.ui.TesterUiActivator.java

License:Open Source License

public ImageDescriptor imageDescriptor(final String path) {
    return ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, PATH_TO_ICONS + path).orElse(null);
}

From source file:org.eclipse.n4js.ui.ImageDescriptorCache.java

License:Open Source License

private synchronized Optional<ImageDescriptor> getImageDescriptor(final ImageRef ref) {
    final N4JSActivator activator = N4JSActivator.getInstance();
    if (null == activator) {
        return absent();
    }/*from   w w  w. j  a  v  a 2 s  . co m*/
    final ImageRegistry registry = activator.getImageRegistry();
    if (null == registry) {
        return absent();
    }
    ImageDescriptor descriptor = registry.getDescriptor(ref.fileName);
    if (null == descriptor) {
        final String imageFilePath = ICON_FOLDER + separator + ref.fileName;
        descriptor = ResourceLocator.imageDescriptorFromBundle(PLUGIN_ID, imageFilePath).orElse(null);
        registry.put(ref.fileName, descriptor);
    }
    return Optional.fromNullable(descriptor);
}

From source file:org.eclipse.n4js.xpect.ui.results.XpectLabelProvider.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(String name) {
    String iconPath = "icons/";
    return ResourceLocator.imageDescriptorFromBundle(N4IDEXpectUIPlugin.PLUGIN_ID, iconPath + name)
            .orElse(null);/*from   w  w w .jav a  2 s.c o m*/
}