com.intellij.ide.IconProvider & Editor Icons

Is this intentional that the Editor tabs still just show the icon that is provided by the
FileType and not the one returned by the IconProvider implementation? If yes, how would
one change the editor-tab icons as well?

Sascha

5 comments

dooh now I get a SOE when calling psiElement.getIcon(i) to get the ORIGINAL icon from IDEA to create a LayeredIcon from that :(

0

Yann Cebron wrote:

dooh now I get a SOE when calling psiElement.getIcon(i) to get the ORIGINAL icon from IDEA to create a LayeredIcon from that :(


This should help:

private static final Key> ICON_KEY = Key.create("MY_CUSTOM_ICON"); private boolean active; @Nullable public Icon getIcon(PsiElement element, int flags) { if (active) return null; active = true; try { TIntObjectHashMap icons = element.getUserData(ICON_KEY); if (icons != null) { final Icon icon = icons.get(flags); if (icon != null) { return icon; } } final Icon i = ...; if (i != null) { if (icons == null) { element.putUserData(ICON_KEY, icons = new TIntObjectHashMap]]>(3));
}
icons.put(flags, i);
}
return i;
} finally {
active = false;
}
}

0

for me they do work in EditorTabs, but not always (same is true for all other views, sometimes IDEA forgets "some" of my provided icons)

0

thanks for the code, I was just about to code something like that myself ;)

0

Yann Cebron wrote:

for me they do work in EditorTabs, but not always (same is true for all other views, sometimes IDEA forgets "some" of my provided icons)


Well, it indeed works for classes but not for any other files - which makes it a bug.
IconProvider.getIcon() is not even called for anything other than classes when a new
editor is opened and the parameter is a PsiClass, not a PsiJavaFile.

http://www.jetbrains.net/jira/browse/IDEA-6890

And still nobody bothered to respond to the project-view refresh problem:
http://www.intellij.net/forums/thread.jsp?forum=23&thread=195552#5045439

Sascha

0

Please sign in to leave a comment.