AR> I just want to give some - not all - plain text files a special AR> icon.
Where are is no way to 'direct set icon in the selected editor'. The way about i said - is define new virtual file system, that will have the custom FileType with your own icon. In this case, then you open your file throught FileEditorManager, then IDEA set icon to Editor tab from your FileType.
BTW, to do it you also must have FileEditorProvider for your own VirtualFile implementation, becouse IDEA will no open it by default.
But it a true - it a very complex workaround, maybe easy to ask JB for directly setting icon via Open API.
FileIconProvider is not an interface that needs to be implemented by your VirtualFile instance. Your implementation of this interface needs to be registered an an extension in your plugin.xml (the extension point name is fileIconProvider).
public class ComponentEditorIconProvider implements FileIconProvider {
@Override public Icon getIcon(@NotNull VirtualFile virtualFile, int i, @Nullable Project project) { if (virtualFile instanceof ComponentVF) { return MyIcons.getEditorImage(); } return null; } }
my "File" is completely virtual, loaded from a web service and has no file name (or extension) really. I make up a URL for it with my own protocol comp://<server>/<comp-name>
The cause is in 12.0 as a base. When I change the SDK to 13.1.X it works as well as with 14.0.2. The IconProvider gets called and the icon appears. :-) Thanks for the help Dimitry
Hello Alain,
AR> Is there a way - even a workaround - to change an editor tab icon?
Yes, throught implementing your own VFS...
(see SystemTools console sources for example)
Thanks!
--
Alexey Efimov, Java Developer
Tops BI
http://www.topsbi.ru
Alexey
(just to be sure, before I delve into this new territory)
I just want to give some - not all - plain text files a special icon.
Alain
Hello Alain,
AR> I just want to give some - not all - plain text files a special
AR> icon.
Where are is no way to 'direct set icon in the selected editor'. The way
about i said - is define new virtual file system, that will have the custom
FileType with your own icon. In this case, then you open your file throught
FileEditorManager, then IDEA set icon to Editor tab from your FileType.
BTW, to do it you also must have FileEditorProvider for your own VirtualFile
implementation, becouse IDEA will no open it by default.
But it a true - it a very complex workaround, maybe easy to ask JB for directly
setting icon via Open API.
Thanks!
--
Alexey Efimov, Java Developer
Tops BI
http://www.topsbi.ru
Alexey
>
I'll try this way and wait a little.
Thanks anyway for your solution: I may eventually have to use it.
Alain
Hi ,
I too have a same requirement.
Please help me by explaining how to implement the editor tab with new icon and also how to customize the tooltip for the tab.
Thanks in Advance.
To control the icon, implement FileIconProvider and return an icon for the virtual file which you're showing in your custom editor.
Editor tab tooltips are controlled by the platform and cannot be changed by plugins.
Thanks Dmitry
I have implemented FileIconProvider for VirtualFile still editor icon is not displaying.
Did i implement in right way ? Please suggest.
public class CustomVF extends VirtualFile implements FileIconProvider {
CustomDetail customDetail = null;
public customVF(CustomDetail customDetail) {
this.customDetail = customDetail;
}
@NotNull
@Override
public String getName() {
return customDetail.getName();
}
@NotNull
@Override
public VirtualFileSystem getFileSystem() {
return CustomVFS.getInstance();
}
@NotNull
@Override
public String getPath() {
return customDetail.getId();
}
@Override
public boolean isWritable() {
return true;
}
@Override
public boolean isDirectory() {
return false;
}
@Override
public boolean isValid() {
return true;
}
@Override
public VirtualFile getParent() {
return CustomVF.this;
}
@Override
public VirtualFile[] getChildren() {
return new VirtualFile[0];
}
@NotNull
@Override
public OutputStream getOutputStream(Object o, long l, long l2) throws IOException {
return NullStreams.OUTPUT;
}
@NotNull
@Override
public byte[] contentsToByteArray() throws IOException {
return new byte[0];
}
@Override
public long getTimeStamp() {
return 0;
}
@Override
public long getLength() {
return 0;
}
@Override
public void refresh(boolean b, boolean b2, @Nullable Runnable runnable) {
}
@Override
public InputStream getInputStream() throws IOException {
return null;
}
@NotNull
@Override
public Icon getIcon(@NotNull VirtualFile virtualFile, int i, @Nullable Project project) {
return CustomImages.getDemoImage();
}
}
FileIconProvider is not an interface that needs to be implemented by your VirtualFile instance. Your implementation of this interface needs to be registered an an extension in your plugin.xml (the extension point name is fileIconProvider).
Dimitry,
facing the same problem. The getIcon() method on my FileIconProvider is never called
plugin.xml
ComponentEditorIconProvider
my "File" is completely virtual, loaded from a web service and has no file name (or extension) really. I make up a URL for it with my own protocol comp://<server>/<comp-name>
Building the plugin against 12.0 SDK.
Any ideas why the IconProvider is not called?
The cause is in 12.0 as a base. When I change the SDK to 13.1.X it works as well as with 14.0.2. The IconProvider gets called and the icon appears. :-) Thanks for the help Dimitry