简体   繁体   English

如何从现有的Eclipse视图中更改文件/文件夹资源图标

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

I want to change the appearance of project explorer view in eclipse by changing the default file/folder icons for my custom plugin resources. 我想通过更改自定义插件资源的默认文件/文件夹图标来更改Eclipse中项目浏览器视图的外观。 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? 我知道装饰器-https: //eclipse.org/articles/Article-Decorators/decorators.html ,但是我如何更改现有图标本身,尽管仅放置覆盖图像还是底层图像?

Also I don't want to create a new view , just want to reuse the project explorer with my icons. 另外我也不想创建一个新视图,只想用我的图标重用项目浏览器。

The main icon used is taken from the default editor used for the file as defined by the org.eclipse.ui.editors extension point. 所使用的主图标来自org.eclipse.ui.editors扩展点所定义的文件的默认编辑器。

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. 如果定义新的文件类型和编辑器,则可以指定图标,但不能覆盖现有类型和编辑器的图标。

To modify existing project explorer content first add a org.eclipse.ui.navigator.viewer extension point. 要修改现有项目资源管理器的内容,请首先添加org.eclipse.ui.navigator.viewer扩展点。 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). 在其下添加一个id为org.eclipse.ui.navigator.ProjectExplorerviewerContentBinding元素(这是标准Eclipse项目浏览器视图的ID)。

Under that add a (includes) with a contentExtension element. 在其下添加一个(includes)带有contentExtension元素。 The pattern identifies the IDs of navigator content to include and can contain wildcards, eg com.example.mycontent.* . 该模式标识要包含的导航器内容的ID,并且可以包含通配符,例如com.example.mycontent.*

Next define a org.eclipse.ui.navigator.navigatorContent extension point with a navigatorContent element. 接下来,使用navigatorContent元素定义org.eclipse.ui.navigator.navigatorContent扩展点。 Make sure the id you provide matches the above pattern. 确保您提供的ID与上述格式匹配。 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). 如果内容提供者实现IPipelinedTreeContentProvider ,它将允许您修改现有内容(可能将IPipelinedTreeContentProvider之类的东西包装在标签提供者理解的类中)。 You'll also need to define triggerPoints to identify the items for which your content provider should be called. 您还需要定义triggerPoints以标识应为其调用内容提供程序的项目。

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 . 您可以通过在navigatorContent下使用策略InvokeAlwaysRegardlessOfSuppressedExt和id org.eclipse.ui.navigator.resourceContent指定override元素来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM