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:de.volanakis.ribbonide.internal.d.ICD.java

License:Open Source License

private static Image createImage(String fileName) {
    Image img = null;/*from  ww  w .j  a  v  a  2 s . c  o m*/
    InputStream is = ICD.class.getResourceAsStream(fileName);
    if (is != null) {
        img = new Image(Display.getDefault(), is);
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        System.err.println("Requested image not found: " + fileName);
        img = ImageDescriptor.getMissingImageDescriptor().createImage();
    }
    return img;
}

From source file:de.volanakis.ribbonide.internal.e.ICE.java

License:Open Source License

private static Image createImage(String fileName) {
    Image img = null;//from   w  w  w .j  a va 2s . c o  m
    InputStream is = ICE.class.getResourceAsStream(fileName);
    if (is != null) {
        img = new Image(Display.getDefault(), is);
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        System.err.println("Requested image not found: " + fileName);
        img = ImageDescriptor.getMissingImageDescriptor().createImage();
    }
    return img;
}

From source file:de.walware.ecommons.ui.actions.HandlerContributionItem.java

License:Open Source License

private void updateIcons() {
    if (widget instanceof MenuItem) {
        final MenuItem item = (MenuItem) widget;
        final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
        try {//from   w w  w .jav  a2 s .  co m
            item.setImage(icon == null ? null : m.createImage(icon));
        } catch (final DeviceResourceException e) {
            icon = ImageDescriptor.getMissingImageDescriptor();
            item.setImage(m.createImage(icon));
            // as we replaced the failed icon, log the message once.
            StatusManager.getManager()
                    .handle(new Status(IStatus.ERROR, SharedUIResources.PLUGIN_ID, "Failed to load image", e)); //$NON-NLS-1$
        }
        disposeOldImages();
        localResourceManager = m;
    } else if (widget instanceof ToolItem) {
        final ToolItem item = (ToolItem) widget;
        final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
        item.setDisabledImage(disabledIcon == null ? null : m.createImage(disabledIcon));
        item.setHotImage(hoverIcon == null ? null : m.createImage(hoverIcon));
        item.setImage(icon == null ? null : m.createImage(icon));
        disposeOldImages();
        localResourceManager = m;
    }
}

From source file:de.walware.ecommons.ui.actions.SimpleContributionItem.java

License:Open Source License

private void updateIcons() {
    if (this.widget instanceof MenuItem) {
        final MenuItem item = (MenuItem) this.widget;
        final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
        try {/* w  w w  .  java  2  s  .  c o m*/
            item.setImage(this.icon == null ? null : m.createImage(this.icon));
        } catch (final DeviceResourceException e) {
            this.icon = ImageDescriptor.getMissingImageDescriptor();
            item.setImage(m.createImage(this.icon));
            // as we replaced the failed icon, log the message once.
            StatusManager.getManager()
                    .handle(new Status(IStatus.ERROR, SharedUIResources.PLUGIN_ID, "Failed to load image", e)); //$NON-NLS-1$
        }
        disposeOldImages();
        this.localResourceManager = m;
    } else if (this.widget instanceof ToolItem) {
        final ToolItem item = (ToolItem) this.widget;
        final LocalResourceManager m = new LocalResourceManager(JFaceResources.getResources());
        item.setDisabledImage(this.disabledIcon == null ? null : m.createImage(this.disabledIcon));
        item.setHotImage(this.hoverIcon == null ? null : m.createImage(this.hoverIcon));
        item.setImage(this.icon == null ? null : m.createImage(this.icon));
        disposeOldImages();
        this.localResourceManager = m;
    }
}

From source file:de.walware.ecommons.ui.util.ImageDescriptorRegistry.java

License:Open Source License

/**
 * Returns the image associated with the given image descriptor.
 * /*  w w  w  .  j  a  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();
    }
    synchronized (fRegistry) {
        Image result = fRegistry.get(descriptor);
        if (result == null && !fDisposed) {
            result = descriptor.createImage();
            if (result != null) {
                fRegistry.put(descriptor, result);
            }
        }
        return result;
    }
}

From source file:de.walware.ecommons.ui.util.ImageRegistryUtil.java

License:Open Source License

protected ImageDescriptor createDescriptor(final String prefix, final String name) {
    try {//from ww  w . j  a  v  a2s.  c om
        return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    } catch (final MalformedURLException e) {
        fPlugin.getLog().log(new Status(IStatus.ERROR, fPlugin.getBundle().getSymbolicName(), 0,
                "Error occured while loading an image descriptor. (internal, unexpected)", e)); //$NON-NLS-1$
        return ImageDescriptor.getMissingImageDescriptor();
    }
}

From source file:de.walware.statet.rtm.base.ui.RtModelUIPlugin.java

License:Open Source License

@Override
protected void initializeImageRegistry(final ImageRegistry reg) {
    if (!fStarted) {
        throw new IllegalStateException("The plug-in is not started.");
    }/*  w  w  w  .  j a v a2 s . c o  m*/
    final ImageRegistryUtil util = new ImageRegistryUtil(this);

    reg.put(OBJ_UNKOWN_TYPE_IMAGE_ID, ImageDescriptor.getMissingImageDescriptor());

    util.register(OBJ_REXPR_TYPE_IMAGE_ID, ImageRegistryUtil.T_OBJ, "rtyped-expr.png");
    util.register(OBJ_DATAFRAME_TYPE_IMAGE_ID, ImageRegistryUtil.T_OBJ, "rtyped-dataframe.png");
    util.register(OBJ_COLUMN_TYPE_IMAGE_ID, ImageRegistryUtil.T_OBJ, "rtyped-column.png");
    util.register(OBJ_COLOR_TYPE_IMAGE_ID, ImageRegistryUtil.T_OBJ, "rtyped-color.png");
    util.register(OBJ_TEXT_TYPE_IMAGE_ID, ImageRegistryUtil.T_OBJ, "rtyped-text.png");
}

From source file:descent.astview.ASTViewImages.java

License:Open Source License

public static void setImageDescriptors(IAction action, String type) {
    ImageDescriptor id = create("d", type); //$NON-NLS-1$
    if (id != null)
        action.setDisabledImageDescriptor(id);
    id = create("c", type); //$NON-NLS-1$
    if (id != null) {
        action.setHoverImageDescriptor(id);
        action.setImageDescriptor(id);//from www  .j  a v a2s  .  c  o  m
    } else {
        action.setImageDescriptor(ImageDescriptor.getMissingImageDescriptor());
    }
}

From source file:descent.internal.ui.viewsupport.ImageDescriptorRegistry.java

License:Open Source License

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

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

From source file:descent.internal.unittest.DescentUnittestPlugin.java

License:Open Source License

/**
 * Creates an image descriptor for the given path in a bundle. The path can
 * contain variables like $NL$. If no image could be found,
 * <code>useMissingImageDescriptor</code> decides if either the 'missing
 * image descriptor' is returned or <code>null</code>.
 * /*from w  w w .j a  v  a2  s. co  m*/
 * @param bundle
 * @param path
 * @param useMissingImageDescriptor
 * @return an {@link ImageDescriptor}, or <code>null</code> iff there's
 *         no image at the given location and
 *         <code>useMissingImageDescriptor</code> is <code>true</code>
 */
private static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path,
        boolean useMissingImageDescriptor) {
    URL url = FileLocator.find(bundle, path, null);
    if (url != null) {
        return ImageDescriptor.createFromURL(url);
    }
    if (useMissingImageDescriptor) {
        return ImageDescriptor.getMissingImageDescriptor();
    }
    return null;
}