Eclipse plugins – Programatically get the image associated with a file extension

Well this is extremely easy.

String extension="bmp"
Image img = PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor("test."+extension).createImage();

Or if the file is in the workspace

IContentType ct=IDE.getContentType(iFileObject);
 

then use the IContentType object to get the image.
 

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: