Get default IDE icon for a file.

Hi All,

I have a file which may or may not exist on the file system. Can I obtain the default icon that IDE would show for this resource. I do not have its VirtualFile instance. I just have the file path.

Thanks
Devang Shah

5 comments

Maybe somthing like this:

FileTypeManager.getInstance().getFileTypeByExtension(]]>).getIcon()

0

Or even better:

FileTypeManager.getInstance().getFileTypeByFileName(]]>).getIcon()

0

I can get appropriate icon for a file. How can i get for a folder? Is it possible to get the same icon as shown in the project view? Like, if the folder is a Module, then get the icon for Module, if a source directory, then get its appropriate icon.

0

Hello Devang,

I can get appropriate icon for a file. How can i get for a folder? Is
it possible to get the same icon as shown in the project view? Like,
if the folder is a Module, then get the icon for Module, if a source
directory, then get its appropriate icon.


PsiDirectory.getIcon()

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

There is also getFileTypeByFile() method. If you have VirtualFile object, you may use:

FileTypeManager.getInstance().getFileTypeByFile(virtualFile).getIcon()

0

Please sign in to leave a comment.