Getting Icons specific to Content Type
The web is full of code how to add content specific icons for editors, package explorers etc. The kind of icons http://blog.eclipse-tips.com/2008/04/content-type-specific-file-icons.html is talking about.
It is much harder to find how you can get those images when you have a just a file name or IResource to work with. Don’t worry, getting the image is easy:
... IFile[] filesForURI = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(fileUri); if (filesForURI.length > 0) { IContentType contentType = IDE.getContentType(filesForURI[0]); ImageDescriptor imageDescriptor = PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(filesForURI[0].getName(), contentType); return imageDescriptor.createImage(); }