It's all about the answers!

Ask a question

How to get the corresponding RTC icon to a file/folder represented as a versionable


0
1
Krasimir Malchev (56631) | asked Jun 21 '16, 8:21 a.m.
edited Jun 21 '16, 8:47 a.m. by David Lafreniere (4.8k7)
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?

Accepted answer


permanent link
David Lafreniere (4.8k7) | answered Jun 21 '16, 8:46 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
 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);
    }
Michael Valenta selected this answer as the correct answer

Comments
Ralph Schoon commented Jun 21 '16, 9:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Cool! Thanks David


Krasimir Malchev commented Jun 29 '16, 2:03 a.m.

Thanks a lot, David!


Krasimir Malchev commented Aug 09 '16, 1:18 a.m.

Hello David.

In relation to the topic: Is there an easy way to get the corresponding icon of a work item and a change set.

Thanks for your help!

One other answer



permanent link
Ralph Schoon (63.5k33646) | answered Jun 21 '16, 9:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This is implemented in Eclipse by providing and registering decorators such as extending org.eclipse.ui.decorators. You can try to search code in the client SDK. It is definitely not a public user API.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.