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.springframework.ide.eclipse.beans.core.BeansCoreImages.java

License:Open Source License

private static ImageDescriptor create(String prefix, String name) {
    try {//w  ww .ja v  a2s.  c o m
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (MalformedURLException e) {
        BeansCorePlugin.log(e);
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.BeansUIImages.java

License:Open Source License

private static ImageDescriptor createManaged(String prefix, String name) {
    try {/*from ww  w . j a va2  s. co  m*/
        ImageDescriptor result = ImageDescriptor
                .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
        if (imageDescriptors == null) {
            imageDescriptors = new HashMap<String, ImageDescriptor>();
        }
        imageDescriptors.put(name, result);
        return result;
    } catch (MalformedURLException e) {
        BeansUIPlugin.log(e);
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.BeansUIImages.java

License:Open Source License

private static ImageDescriptor create(String prefix, String name) {
    try {/* w w w.  j  av  a  2s  .  c o  m*/
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (MalformedURLException e) {
        BeansUIPlugin.log(e);
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.editor.outline.webflow.WebflowConfigUIImages.java

License:Open Source License

/**
 * /*from   w  w  w. ja va2 s  . c  om*/
 * 
 * @param prefix 
 * @param name 
 * 
 * @return 
 */
private static ImageDescriptor createManaged(String prefix, String name) {
    try {
        ImageDescriptor result = ImageDescriptor
                .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
        if (imageDescriptors == null) {
            imageDescriptors = new HashMap<String, ImageDescriptor>();
        }
        imageDescriptors.put(name, result);
        if (imageRegistry != null) {
        }
        return result;
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.editor.outline.webflow.WebflowConfigUIImages.java

License:Open Source License

/**
 * //  w w w .j  a  v a  2s. c  o  m
 * 
 * @param prefix 
 * @param name 
 * 
 * @return 
 */
private static ImageDescriptor create(String prefix, String name) {
    try {
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.graph.BeansGraphImages.java

License:Open Source License

@SuppressWarnings("unchecked")
private static ImageDescriptor createManaged(String prefix, String name) {
    try {//from w w  w.  ja  v  a2  s .  c o  m
        ImageDescriptor result = ImageDescriptor
                .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
        if (imageDescriptors == null) {
            imageDescriptors = new HashMap();
        }
        imageDescriptors.put(name, result);
        if (imageRegistry != null) {
            BeansGraphPlugin.log("Image registry already defined", null);
        }
        return result;
    } catch (MalformedURLException e) {
        BeansGraphPlugin.log(e);
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.graph.BeansGraphImages.java

License:Open Source License

private static ImageDescriptor create(String prefix, String name) {
    try {//  w w w .  j ava2s .com
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (MalformedURLException e) {
        BeansGraphPlugin.log(e);
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.livegraph.LiveGraphUIImages.java

License:Open Source License

private static ImageDescriptor createManaged(String prefix, String name) {
    try {/*from ww  w .  j  av a 2 s . co m*/
        ImageDescriptor result = ImageDescriptor
                .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
        if (imageDescriptors == null) {
            imageDescriptors = new HashMap<String, ImageDescriptor>();
        }
        imageDescriptors.put(name, result);
        return result;
    } catch (MalformedURLException e) {
        LiveGraphUiPlugin.log(e);
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.util.ToolbarPulldownContributionItem.java

License:Open Source License

/**
 * Updates the images for this action./*w w  w.j  a  va2s. 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.springframework.ide.eclipse.boot.restart.RestartPluginImages.java

License:Open Source License

private final static void declareRegistryImage(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    Bundle bundle = Platform.getBundle(RestartConstants.PLUGIN_ID);
    URL url = null;//  www .j a va  2s .  c  o m
    if (bundle != null) {
        url = FileLocator.find(bundle, new Path(path), null);
        if (url != null) {
            desc = ImageDescriptor.createFromURL(url);
        }
    }
    imageRegistry.put(key, desc);
}