Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?

1

0 votes


Accepted answer

Permanent link
 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

2 votes

Comments

Cool! Thanks David

Thanks a lot, David!

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
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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937
× 1,202

Question asked: Jun 21 '16, 8:21 a.m.

Question was seen: 4,382 times

Last updated: Aug 09 '16, 1:18 a.m.

Confirmation Cancel Confirm