Java Code Examples for org.eclipse.jface.resource.ImageRegistry#getDescriptor()

The following examples show how to use org.eclipse.jface.resource.ImageRegistry#getDescriptor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIPlugin.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static ImageDescriptor getImageDescriptor(String imageName) {
    final ImageRegistry reg = getDefault().getImageRegistry();

    ImageDescriptor result = reg.getDescriptor(imageName);

    if (result != null) {
        return result;
    }

    final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
    if (descriptor != null) {
        result = descriptor;
    }

    reg.remove(imageName);
    if (result != null) {
        reg.put(imageName, result);
    }

    return result;
}
 
Example 2
Source File: Images.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
public static ImageDescriptor getImageDescriptor( String name ) {
  ImageDescriptor result = null;
  ImageRegistry imageRegistry = getImageRegistry();
  if( imageRegistry != null ) {
    result = imageRegistry.getDescriptor( name );
  }
  return result;
}
 
Example 3
Source File: Images.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
public static ImageDescriptor getImageDescriptor( String name ) {
  ImageDescriptor result = null;
  ImageRegistry imageRegistry = getImageRegistry();
  if( imageRegistry != null ) {
    result = imageRegistry.getDescriptor( name );
  }
  return result;
}
 
Example 4
Source File: AbstractGeneratorConfigurationBlock.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the image descriptor.
 *
 * @param imagePath the image path.
 * @return the image descriptor.
 */
@SuppressWarnings("static-method")
protected ImageDescriptor getImageDescriptor(String imagePath) {
	final LangActivator activator = LangActivator.getInstance();
	final ImageRegistry registry = activator.getImageRegistry();
	ImageDescriptor descriptor = registry.getDescriptor(imagePath);
	if (descriptor == null) {
		descriptor = ResourceLocator.imageDescriptorFromBundle(activator.getBundle().getSymbolicName(), imagePath).orElse(null);
		if (descriptor != null) {
			registry.put(imagePath, descriptor);
		}
	}
	return descriptor;
}
 
Example 5
Source File: UIHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This is a convenience method to get an imgIcon from a URL.
 * 
 * @param sPluginRelativePath
 *            The URL for the imgIcon.
 * @return The imgIcon represented by the given URL.
 * @see #setImageCached( boolean )
 */
public static ImageDescriptor getImageDescriptor( String sPluginRelativePath )
{
	ImageRegistry registry = JFaceResources.getImageRegistry( );
	ImageDescriptor image = registry.getDescriptor( sPluginRelativePath );
	if ( image == null )
	{
		registry.put( sPluginRelativePath,
				createImage( sPluginRelativePath ) );
		image = registry.getDescriptor( sPluginRelativePath );
	}
	return image;
}
 
Example 6
Source File: ReportPlugin.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Relative to UI plugin directory, example: "icons/usertableicon.gif".
 * 
 * @param key
 * @return an Image descriptor, this is useful to preserve the original
 *         color depth for instance.
 */
public static ImageDescriptor getImageDescriptor( String key )
{
	ImageRegistry imageRegistry = ReportPlugin.getDefault( )
			.getImageRegistry( );

	ImageDescriptor imageDescriptor = imageRegistry.getDescriptor( key );

	if ( imageDescriptor == null )
	{
		URL url = ReportPlugin.getDefault( ).find( new Path( key ) );

		if ( null != url )
		{
			imageDescriptor = ImageDescriptor.createFromURL( url );
		}

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

		imageRegistry.put( key, imageDescriptor );
	}

	return imageDescriptor;
}
 
Example 7
Source File: LibraryElementImageDecorator.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Image decorateImage( Image image, Object element )
{
	int flag =  getElementFlag( element );
	if ((flag&Normal_Element) != 0)
	{
		return image;
	}
	String key = ""; //$NON-NLS-1$
	if (element instanceof DesignElementHandle)
	{
		DesignElementHandle handle = (DesignElementHandle)element;
		key = handle.getElement( ).getDefn( ).getName( );
	}
	else if (element instanceof EmbeddedImageHandle)
	{
		EmbeddedImageHandle imageHandle = (EmbeddedImageHandle)element;
		key = imageHandle.getQualifiedName( );
	}
	
	ImageDescriptor descriptor = null;
	if ((flag&Library_Element) != 0)
	{
		key = key + Library_Key;
		descriptor = new LibraryImageDescriptor( image, ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_REPORT_LIBRARY_OVER ) );
	}
	else if ((flag&Local_Library_Element) != 0)
	{
		key = key + Local_Library_Key;
		descriptor = new LibraryImageDescriptor( image, ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_REPORT_LOCAL_LIBRARY_OVER ) );
	}
	ImageRegistry regiest = ReportPlugin.getDefault( ).getImageRegistry( );
	ImageDescriptor temp = regiest.getDescriptor( key );
	if (temp != null)
	{
		return temp.createImage( );
	}
	else if(descriptor != null)
	{
		regiest.put( key, descriptor );
		return descriptor.createImage( );
	}
	//ReportPlugin.getDefault( ).getImageRegistry( ).get
	return image;
}
 
Example 8
Source File: TypeScriptImagesRegistry.java    From typescript.java with MIT License 2 votes vote down vote up
/**
 * Returns the image descriptor from the image registry with the given key.
 * 
 * @param key
 *            of the image
 * @return the image descriptor from the image registry with the given key.
 */
public static ImageDescriptor getImageDescriptor(String key) {
	ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
	return imageRegistry.getDescriptor(key);
}