How to change file/folder resource icons from existing eclipse views

淺唱寂寞╮ 提交于 2019-12-25 04:24:30

问题


I want to change the appearance of project explorer view in eclipse by changing the default file/folder icons for my custom plugin resources. I am aware of Decorators - https://eclipse.org/articles/Article-Decorators/decorators.html , But how can I change the existing icons itself inspite of just putting an overlay or underlay image?

Also I don't want to create a new view , just want to reuse the project explorer with my icons.


回答1:


The main icon used is taken from the default editor used for the file as defined by the org.eclipse.ui.editors extension point.

If you defining new file types and editors you can specify the icon, but you can't override the icon for existing types and editors.




回答2:


To modify existing project explorer content first add a org.eclipse.ui.navigator.viewer extension point. Under that add a viewerContentBinding element with the id org.eclipse.ui.navigator.ProjectExplorer (that's the id of the standard Eclipse project explorer view).

Under that add a (includes) with a contentExtension element. The pattern identifies the IDs of navigator content to include and can contain wildcards, e.g. com.example.mycontent.*.

Next define a org.eclipse.ui.navigator.navigatorContent extension point with a navigatorContent element. Make sure the id you provide matches the above pattern. Set the content and label providers. If the content provider implements IPipelinedTreeContentProvider it will allow you to modify existing content (possibly wrapping things like IFolder inside classes your label provider understands). You'll also need to define triggerPoints to identify the items for which your content provider should be called.

It may be useful/necessary to suppress standard navigator content. You can do this by specifying an override element under navigatorContent with the policy InvokeAlwaysRegardlessOfSuppressedExt and id org.eclipse.ui.navigator.resourceContent.



来源:https://stackoverflow.com/questions/27718357/how-to-change-file-folder-resource-icons-from-existing-eclipse-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!