Associating icons with folders.

Hi All,

Can I associate icon for folders? I followed the following implementation, however it did not work.

Icon openIcon = abstractTreeNode.getOpenIcon(); Icon closedIcon = abstractTreeNode.getClosedIcon(); LayeredIcon newOpenIcon = new LayeredIcon(2); newOpenIcon.setIcon(openIcon, 0); newOpenIcon.setIcon(iconToSet, 1, 10, 11); LayeredIcon newClosedIcon = new LayeredIcon(2); newClosedIcon.setIcon(closedIcon, 0); newClosedIcon.setIcon(iconToSet, 1, 10, 11); PresentationData presentationData = (PresentationData) abstractTreeNode.getPresentation(); presentationData.setOpenIcon(openIcon); presentationData.setClosedIcon(closedIcon); ]]>

Am I missing something? I am able to associate overlay icons on files.

Thanks
Devang Shah

3 comments
Comment actions Permalink

Hello Devang,

Can I associate icon for folders? I followed the following
implementation, however it did not work.

<code>

Icon openIcon = abstractTreeNode.getOpenIcon();
Icon closedIcon = abstractTreeNode.getClosedIcon();
LayeredIcon newOpenIcon = new LayeredIcon(2);
newOpenIcon.setIcon(openIcon, 0);
newOpenIcon.setIcon(iconToSet, 1, 10, 11);
LayeredIcon newClosedIcon = new LayeredIcon(2);
newClosedIcon.setIcon(closedIcon, 0);
newClosedIcon.setIcon(iconToSet, 1, 10, 11);
PresentationData presentationData = (PresentationData)
abstractTreeNode.getPresentation();
presentationData.setOpenIcon(openIcon);
presentationData.setClosedIcon(closedIcon);
</code>

Am I missing something? I am able to associate overlay icons on files.


The correct way to implement this is to provide an implementation of the
IconProvider interface and to return the necessary icons from your getIcon()
method when you're asked for an icon of a PsiDirectory. Your implementation
needs to be registered as an ]]> extension in plugin.xml.

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


0
Comment actions Permalink

Hi,

Can you please provide me with the ]]> tag information?

Thanks
Devang Shah

0
Comment actions Permalink

If you can't see your icon in the project structure view, it's important to set the tag priority:

<iconProvider implementation="..." order="first"/>
0

Please sign in to leave a comment.