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.symbian.tools.tmw.internal.ui.deployment.DeploymentTargetTypeDescriptor.java

License:Open Source License

public ImageDescriptor getImageDescriptor() {
    if (imageDescriptor == null) {
        final String image = element.getAttribute("icon");
        if (image == null) {
            imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
        } else {// w  w w. j a v a 2s .  co m
            imageDescriptor = TMWCoreUI.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), image);
        }
    }
    return imageDescriptor;
}

From source file:org.valable.viewsupport.ImageDescriptorRegistry.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * //  w  ww .j  a  v a 2s . co  m
 * @param descriptor the image descriptor for which the registry 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.
 */
public Image get(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.whole.lang.ui.util.UIUtils.java

License:Open Source License

public static ImageDescriptor getImageDescriptor(String bundleId, String relativePath) {
    URL entry = Platform.getBundle(bundleId).getEntry(relativePath);
    if (entry == null)
        relativePath.length();/*w  w  w . ja va  2 s  . com*/
    ImageDescriptor createFromURL = ImageDescriptor.createFromURL(entry);
    if (createFromURL == ImageDescriptor.getMissingImageDescriptor())
        relativePath.length();
    return createFromURL;
}

From source file:org.whole.lang.ui.WholeImageDescriptorRegistry.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * /*from  ww w . java2  s .  c  o  m*/
 * @param descriptor the image descriptor for which the registry manages an image
 * @return the image associated with the image descriptor or <code>null</code>
 *  if the image descriptor can't create the requested image.
 */
public Image get(ImageDescriptor descriptor) {
    if (descriptor == null)
        descriptor = ImageDescriptor.getMissingImageDescriptor();

    Image result = registryMap.get(descriptor);
    if (result != null)
        return result;

    Assert.isTrue(display == getStandardDisplay(), "Allocating image for wrong display."); //$NON-NLS-1$
    result = descriptor.createImage();
    if (result != null)
        registryMap.put(descriptor, result);
    return result;
}

From source file:org.xmind.gef.service.ImageRegistryService.java

License:Open Source License

private ImageDescriptor getErrorImageCreator() {
    if (errorImageDescriptor != null)
        return errorImageDescriptor;
    return ImageDescriptor.getMissingImageDescriptor();
}

From source file:org.xmind.ui.color.ColorPicker.java

License:Open Source License

/**
 * Updates the images for this action.//  w  ww.  j  ava 2 s  .  c o  m
 * 
 * @param forceImage
 *            <code>true</code> if some form of image is compulsory, and
 *            <code>false</code> if it is acceptable for this item to have
 *            no image
 * @return <code>true</code> if there are images for this action,
 *         <code>false</code> if not
 */
private boolean updateImages(boolean forceImage) {

    ResourceManager parentResourceManager = JFaceResources.getResources();

    if (widget instanceof ToolItem) {
        if (USE_COLOR_ICONS) {
            ImageDescriptor image = action.getHoverImageDescriptor();
            if (image == null) {
                image = action.getImageDescriptor();
            }
            ImageDescriptor disabledImage = action.getDisabledImageDescriptor();

            // Make sure there is a valid image.
            if (image == null && forceImage) {
                image = ImageDescriptor.getMissingImageDescriptor();
            }

            LocalResourceManager localManager = new LocalResourceManager(parentResourceManager);

            // performance: more efficient in SWT to set disabled and hot image before regular image
            ((ToolItem) widget).setDisabledImage(
                    disabledImage == null ? null : localManager.createImageWithDefault(disabledImage));
            ((ToolItem) widget).setImage(image == null ? null : localManager.createImageWithDefault(image));

            disposeOldImages();
            imageManager = localManager;

            return image != null;
        }
        ImageDescriptor image = action.getImageDescriptor();
        ImageDescriptor hoverImage = action.getHoverImageDescriptor();
        ImageDescriptor disabledImage = action.getDisabledImageDescriptor();

        // If there is no regular image, but there is a hover image,
        // convert the hover image to gray and use it as the regular image.
        if (image == null && hoverImage != null) {
            image = ImageDescriptor.createWithFlags(action.getHoverImageDescriptor(), SWT.IMAGE_GRAY);
        } else {
            // If there is no hover image, use the regular image as the hover image,
            // and convert the regular image to gray
            if (hoverImage == null && image != null) {
                hoverImage = image;
                image = ImageDescriptor.createWithFlags(action.getImageDescriptor(), SWT.IMAGE_GRAY);
            }
        }

        // Make sure there is a valid image.
        if (hoverImage == null && image == null && forceImage) {
            image = ImageDescriptor.getMissingImageDescriptor();
        }

        // Create a local resource manager to remember the images we've allocated for this tool item
        LocalResourceManager localManager = new LocalResourceManager(parentResourceManager);

        // performance: more efficient in SWT to set disabled and hot image before regular image
        ((ToolItem) widget).setDisabledImage(
                disabledImage == null ? null : localManager.createImageWithDefault(disabledImage));
        ((ToolItem) widget)
                .setHotImage(hoverImage == null ? null : localManager.createImageWithDefault(hoverImage));
        ((ToolItem) widget).setImage(image == null ? null : localManager.createImageWithDefault(image));

        // Now that we're no longer referencing the old images, clear them out.
        disposeOldImages();
        imageManager = localManager;

        return image != null;
    } else if (widget instanceof Item || widget instanceof Button) {

        // Use hover image if there is one, otherwise use regular image.
        ImageDescriptor image = action.getHoverImageDescriptor();
        if (image == null) {
            image = action.getImageDescriptor();
        }
        // Make sure there is a valid image.
        if (image == null && forceImage) {
            image = ImageDescriptor.getMissingImageDescriptor();
        }

        // Create a local resource manager to remember the images we've allocated for this widget
        LocalResourceManager localManager = new LocalResourceManager(parentResourceManager);

        if (widget instanceof Item) {
            ((Item) widget).setImage(image == null ? null : localManager.createImageWithDefault(image));
        } else if (widget instanceof Button) {
            ((Button) widget).setImage(image == null ? null : localManager.createImageWithDefault(image));
        }

        // Now that we're no longer referencing the old images, clear them out.
        disposeOldImages();
        imageManager = localManager;

        return image != null;
    }
    return false;
}

From source file:org.xmind.ui.richtext.AlignmentGroup.java

License:Open Source License

/**
 * Updates the images for this action.//from   www.  j a  v a 2  s.c om
 * 
 * @param forceImage
 *            <code>true</code> if some form of image is compulsory, and
 *            <code>false</code> if it is acceptable for this item to have
 *            no image
 * @return <code>true</code> if there are images for this action,
 *         <code>false</code> if not
 */
private boolean updateImages(boolean forceImage) {
    ResourceManager parentResourceManager = JFaceResources.getResources();

    ImageDescriptor image = currentAction.getHoverImageDescriptor();
    if (image == null) {
        image = currentAction.getImageDescriptor();
    }
    ImageDescriptor disabledImage = currentAction.getDisabledImageDescriptor();

    // Make sure there is a valid image.
    if (image == null && forceImage) {
        image = ImageDescriptor.getMissingImageDescriptor();
    }

    LocalResourceManager localManager = new LocalResourceManager(parentResourceManager);

    // performance: more efficient in SWT to set disabled and hot
    // image before regular image
    widget.setDisabledImage(disabledImage == null ? null : localManager.createImageWithDefault(disabledImage));
    widget.setImage(image == null ? null : localManager.createImageWithDefault(image));

    disposeOldImages();
    imageManager = localManager;

    return image != null;
}

From source file:org2.eclipse.php.internal.debug.ui.PHPDebugUIImages.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)
 *//*  w w  w.  j a  v  a 2 s.c o m*/
private final static void declareRegistryImage(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    Bundle bundle = Platform.getBundle(PHPDebugEPLPlugin.PLUGIN_ID);
    URL url = null;
    if (bundle != null) {
        url = FileLocator.find(bundle, new Path(path), null);
        desc = ImageDescriptor.createFromURL(url);
    }
    fgImageRegistry.put(key, desc);
}

From source file:sernet.gs.ui.rcp.main.ImageCache.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String url) {
    ImageDescriptor descriptor;/*from  w ww  . ja  v  a  2s  .  c o m*/
    try {
        descriptor = ImageDescriptor.createFromURL(new URL(imagePath, url));
    } catch (MalformedURLException e) {
        descriptor = ImageDescriptor.getMissingImageDescriptor();
    }
    return descriptor;

}

From source file:sernet.gs.ui.rcp.main.ImageCache.java

License:Open Source License

public Image getCustomImage(String url) {
    ImageDescriptor descriptor = null;// ww w .j  a v  a2  s. c o m
    if (new File(url).isAbsolute()) {
        descriptor = ImageDescriptor.createFromFile(null, url);
    } else {
        descriptor = ImageDescriptor.createFromURL(FileLocator.find(bundle, new Path(url), null));
    }
    if (descriptor.equals(ImageDescriptor.getMissingImageDescriptor())) {
        LOG.warn("Image not found: " + url);
        descriptor = ImageDescriptor
                .createFromURL(FileLocator.find(bundle, new Path(getIconPath(UNKNOWN)), null));
    }
    return getImage(descriptor);
}