fileIconProvider is not showing Icon for custom LightVirtualFile

Hi,

I've a class DataBaseVirtualFile extends LightVirtualFIle for displaying database table in the editor.

I also implemented FileEditorProvider with below methods.

public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
return file instanceof DataBaseVirtualFile;
}
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) {
return new RecordViewer(project,(DataBaseVirtualFile)file);
}

Everything is working fine. I'm able to open table in editor.

Now For providing icon to table file, I've added fileIconprovider in plugin.xml
<fileIconProvider implementation=".... DBFileIconProvider"/>

public Icon getIcon(@NotNull VirtualFile file, int flags, @Nullable Project project) {
System.out.println("within fileicon provider");
if(file instanceof DataBaseVirtualFile) {
System.out.println("within fileicon provider condition");
return AllIcons.Actions.Refresh;
}
return null;
}

But I'm not getting any Icon for table file. Moreover getIcon() is never been called!!.
Can you please suggest anything wrong in this? Or any diffrent method to provide icon?

Thanks.
0
4 comments

Please debug com.intellij.util.IconUtil#getProvidersIcon

0

Hi Cebron,

I've debugged getProvidersIcon.

List<FileIconProvider> getProviders() is having my FIleIconProvider in the list. But FileIconPatcherImpl.getIcon() is returning non null value for the DataBaseVirtualFile becuase of this DBFileIconProvider.getIcon() is not called.

Also, DataBaseVirtualFile  is not having any extension. It's just an in-memory file.

 

 

0

So which provider is returning an icon? Could you try adding

order="first"

to registration of your <fileIconProvider> in plugin.xml?

0

Thanks for the reply.

After making order=first I'm getting Icon in the file. I'm afraid that this may not be the exact fix for the issue.

FileIconPatcherImpl is returned some Icon but it's not displayed anything.

 

0

Please sign in to leave a comment.