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.dresdenocl.modelbus.ui.internal.wizards.util.ModelLabelProvider.java

License:Open Source License

@Override
public Image getImage(Object element) {

    Image result;/*from   w  ww. j a v a  2  s  .c  o  m*/

    result = null;

    if (element instanceof IModel) {

        IMetamodel aMetaModel;
        IModel aModel;

        aModel = (IModel) element;

        aMetaModel = aModel.getMetamodel();

        /*
         * Check if the model instance type has been added and configured via the
         * modelInstanceTypes extension point.
         */
        if (aMetaModel instanceof IMetamodelDescriptor) {
            IMetamodelDescriptor mmDescriptor;

            mmDescriptor = (IMetamodelDescriptor) aMetaModel;

            ImageDescriptor imageDescriptor;
            imageDescriptor = ImageDescriptor.createFromURL(mmDescriptor.getIconURL());

            if (imageDescriptor == null) {
                imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
            }
            // no else.

            result = this.resources.createImage(imageDescriptor);
        }
        // no else.
    }
    // no else.

    return result;
}

From source file:org.drools.eclipse.DroolsPluginImages.java

License:Apache 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. ja v  a 2 s  . c o  m*/
public final static void declareRegistryImage(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    try {
        desc = ImageDescriptor.createFromURL(makeIconFileURL(path));
    } catch (MalformedURLException e) {
        DroolsEclipsePlugin.log(e);
    }
    imageRegistry.put(key, desc);
}

From source file:org.ebayopensource.vjet.eclipse.internal.ui.view.scriptunit.ScriptUnitTreeLabelProvider.java

License:Open Source License

public Image getImage(Object element) {
    if (!this.checkNode || !(element instanceof IJstNode))
        return null;

    IJstNode jstNode = (IJstNode) element;
    if ((jstNode.getSource() == null) || (jstNode.getRootType() == null))
        return null;

    int startOffset = jstNode.getSource().getStartOffSet();
    int endOffset = jstNode.getSource().getEndOffSet();

    //switch to new version JstUtil
    Object node = JstUtil.getLeafNode(jstNode.getRootType(), startOffset, endOffset);
    //      Object node = JstUtil.getNode(jstNode.getRootType(), startOffset, endOffset);
    if (node == element)
        return null;
    else//from   w  w w.ja v  a2 s  .  c  o m
        return ImageDescriptor.getMissingImageDescriptor().createImage();
}

From source file:org.eclipse.acceleo.ui.interpreter.internal.InterpreterImages.java

License:Open Source License

/**
 * Creates the given image and puts it in the registry for latter use.
 * /*from w w w  .  ja  va 2  s .  c o m*/
 * @param key
 *            Key that will allow us to retrieve the image in the registry.
 * @param path
 *            Path to the image that is to be put into the registry.
 */
private static void createImage(String key, String path) {
    ImageDescriptor image = ImageDescriptor.getMissingImageDescriptor();
    if (BASE_URL == null) {
        // FIXME log this, will have a "missing image" descriptor.
    } else {
        try {
            image = ImageDescriptor.createFromURL(new URL(BASE_URL, path));
        } catch (MalformedURLException e) {
            // FIXME log this, will have a "missing image" descriptor.
        }
    }
    imageRegistry.put(key, image);
}

From source file:org.eclipse.ajdt.examples.AspectJExamplePlugin.java

License:Open Source License

public ImageDescriptor getImageDescriptor(String name) {
    try {/*from   www  .ja v  a  2  s .  c  o m*/
        URL url = new URL(getBundle().getEntry("/"), name); //$NON-NLS-1$
        return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.eclipse.ajdt.internal.ui.resources.AJDTIcon.java

License:Open Source License

/**
 * Build icon from a resource in this plugin's install directory
 *///from w  w w.  jav a  2 s.  c om
public AJDTIcon(String localPath) {
    if (pluginInstallURL == null) {
        pluginInstallURL = AspectJUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
    }
    try {
        URL url = new URL(pluginInstallURL, localPath);
        this.descriptor = ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException malFormedURL) {
        this.descriptor = ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:org.eclipse.ajdt.internal.ui.resources.ImageDescriptorRegistry.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * /*from w  ww .ja v  a 2s  . com*/
 * @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 = (Image) fRegistry.get(descriptor);
    if (result != null)
        return result;

    result = descriptor.createImage();
    if (result != null)
        fRegistry.put(descriptor, result);
    return result;
}

From source file:org.eclipse.ant.internal.ui.AntUIImages.java

License:Open Source License

/**
 * Declare an Image in the registry table.
 * /*from   w  w w . jav  a 2 s  .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(String key, String path) {
    ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
    Bundle bundle = Platform.getBundle(AntUIPlugin.getUniqueIdentifier());
    URL url = null;
    if (bundle != null) {
        url = FileLocator.find(bundle, new Path(path), null);
        desc = ImageDescriptor.createFromURL(url);
    }
    imageRegistry.put(key, desc);
}

From source file:org.eclipse.ant.internal.ui.ImageDescriptorRegistry.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * //from  ww  w  . j a va 2 s .co  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 = fRegistry.get(descriptor);
    if (result != null)
        return result;

    Assert.isTrue(fDisplay == AntUIPlugin.getStandardDisplay(),
            AntUIModelMessages.ImageDescriptorRegistry_Allocating_image_for_wrong_display_1);
    result = descriptor.createImage();
    if (result != null)
        fRegistry.put(descriptor, result);
    return result;
}

From source file:org.eclipse.babel.runtime.Activator.java

License:Open Source License

public static ImageDescriptor createImageDescriptor(String name) {
    try {//from w  w w  . ja  v a  2s.  c om
        URL installURL = getDefault().getBundle().getEntry("/");
        URL url = new URL(installURL, name);
        return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
        // should not happen
        return ImageDescriptor.getMissingImageDescriptor();
    }
}