The ImageRegistry is intended to be used for Images
that appear frequently in your plugnin UI.
To use ImageRegistry make sure your Plugin class a subclass of org.eclipse.ui.plugin.AbstractUIPlugin.
This class creates an ImageRegistry automatically (one per plug-in instance) and
override/implement the following methods.
public Image getImage(String id)
{
ImageRegistry ir= getImageRegistry();
return (Image)ir.get(id);
}
public ImageDescriptor getImageDescriptor(String id)
{
ImageRegistry ir= getImageRegistry();
return (ImageDescriptor)ir.getDescriptor(id);
}
protected void initializeImageRegistry(ImageRegistry image_registry)
{
ImageDescriptor desc = ImageDescriptor.createFromURL(generateURL("myOwnImage1.gif"));
image_registry.put("myOwnImage1",desc);
}
private URL generateURL(String file_name)
{
Bundle bundle = Platform.getBundle(PLUGIN_ID);
String iconPath = "icons/";
String completePath= iconPath+file_name;
IPath path = new Path(completePath);
URL url = Platform.find(bundle,path);
return url;
}
No comments:
Post a Comment