How to get the corresponding RTC icon to a file/folder represented as a versionable
When we open a stream's repository files view (for example) each file / folder is preceded by a corresponding icon in RTC. That is, if the file is Java file, then the icon correspond to that type of a file (.java). If there is a folder, then the icon in front of the folder denotes that.
How can I fetch the appropriate icon based on the type of a versionable (and its extension/MIME type, maybe) with the RTC API?
How can I fetch the appropriate icon based on the type of a versionable (and its extension/MIME type, maybe) with the RTC API?
Accepted answer
Here is how you get the corresponding icon:
/**
* Returns the image descriptor used by the Eclipse Workbench for the given
* filename. Filename may or may not have path information. e.g. readme.txt and
* /src/readme.txt are both valid and yield the same result i.e. the image
* descriptor registered for .txt files.
* <p>
* If the argument filename is <code>null</code> then the image descriptor
* corresponding to a folder is returned.
*/
public static ImageDescriptor getFileSystemImageDescriptor(String filename) {
if (filename == null) {
return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
}
return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(filename);
}