org.eclipse.ui.decorators这个扩展点可以为对应的节点添加不同的图标显示。
使用方式都差不多,以下就转载一下使用方式:
1、添加扩展点 org.eclipse.ui.decorators
2、修改plugin.xml
<extension
point="org.eclipse.ui.decorators">
<decorator
id="my.ui.decorator"
label="IFolder Decorator"
state="true"
class="my.ui.decorators.LabelDecorator">
<enablement>
<objectClass name="org.eclipse.core.resources.IFolder"/>
</enablement>
</decorator>
</extension>
添加扩展点后,xml里有很多属性,为了单独对指定的文件夹起作用,删掉其他属性,并增加class属性;
enablement的意思是对什么起作用,这里是对文件夹IFolder起作用;
3、my.ui.decorators.LabelDecorator类源码
package my.ui.decorators;
import org.eclipse.core.internal.resources.Folder;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import my.ui.BabaowgtkitUIPlugIn;
/**
* 更改图标
* ClassName:LabelDecorator
*/
@SuppressWarnings({ "restriction", "unused" })
public class LabelDecoratorimplementsILabelDecorator{
/**
*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object)
*/
public Image decorateImage(Image image, Object element) {
//更改src文件夹图标
if (element instanceof Folder
&& ((Folder) element).getName().equals("src")) {
return MyUIPlugIn.getImage("icons/packagefolder_obj.gif");
}
returnnull;
}
public String decorateText(String text, Object element) {
// TODO Auto-generated method stub
return null;
}
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
public void dispose() {
// TODO Auto-generated method stub
}
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
}
上面用到了MyUIPlugIn.getImage的方法,下面贴出源码,目的就是取项目目录下的图标文件;
MyUIPlugIn是建立插件项目时自动生成的,继承了 AbstractUIPlugin;
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
public static Image getImage(String path){
return getImageDescriptor(path).createImage();
}
PLUGIN_ID是插件项目的ID;
分享到:
相关推荐
mybatis源码中文注释版 需要导入模块:需要将mybatis-parent模块导入。mybatis-parent模块 1.兵马未动,日志先行 org.apache.ibatis.logging ...org.apache.ibatis.cache.decorators org.apache.ibatis.cache.i
Fitted: 使用ES7 decorators简化http请求
│ │ ├─org.eclipse.core.resources │ │ │ ├─.history │ │ │ │ ├─0 │ │ │ │ ├─1 │ │ │ │ ├─10 │ │ │ │ ├─11 │ │ │ │ ├─12 │ │ │ │ ├─13 │ │ │ │ ├─14 │ │ │ ...
│ │ org.eclipse.jdt.core.prefs │ │ │ └─src │ │ logging.properties │ │ │ └─com │ └─mine │ │ BigMap.java │ │ LogPack.java │ │ │ └─logging │ ConsoleHandler.java │ Error...
8.删除eclipse\configuration目录下的org.eclipse.update目录;(这个问题困扰了我一晚上,做了好几次尝试,Eclipse始终没有加载已经安装的插件,删除workspace都没用,后来才在csdn论坛找到这个解决办法。这是3.0的...
非常不错的书 Preface . . . . . . . . ....Who Should Read This Book ....Conventions Used ....Code Samples ....Tips, Notes, and Warnings ....Supplementary Materials .... ....Chapter 1 Falling In Love With AngularJS ....
2.4.2. Class Decorators........................................ 54 2.4.2.1. Using a Class Decorator to Add Properties .......... 57 2.4.2.2. Using a Class Decorator Instead of Subclassing...... 58 2.5...
如果您使用的是Babel 7,则此插件不适合您。 Babel 7的@babel/plugin-proposal-decorators正式支持此插件具有的相同逻辑,但与Babel 7的其他插件更好地集成。 您可以启用 { " plugins " : [ [ " @babel/plugin-...
react-decorators, 高级ReactJS组件的集合 React高阶反应组件的集合如何安装 $ npm install react-decorators --save:如何使用import React from 'react';import
通过执行git clone https://github.com/Louis-Navarro/decorators.git或下载.zip文件来下载此存储库。 然后,在文件中打开命令提示符。 输入pip install -e . 在命令提示符下,然后按Enter键以安装软件包。 完毕!...
该项目是在ES Decorators之上易于使用的几乎没有依赖项注入的框架。 基本思想是有一种简单的方法来声明与ES装饰器的依赖关系。 如果您愿意,请花一些时间为该项目加注星标! “ npm star di-decorators”以及...
Decorators............................................3 Types/Classes & Objects.....................3 Class Definition.....................................3 Object Creation...............................
python方法 python_装饰器Decorators
资源来自pypi官网。 资源全名:lambda-decorators-0.5.0.tar.gz
以下示例显示如何在控制器类上使用flask-rest-decorators: # controllers.py from flask_rest_decorators import controller , get , post , put , delete @ controller ( "/api/v1/hello" ) class HelloWorld : ...
springmvc+mybatis+maven+freemarker+urlwrite+decorators
资源分类:Python库 所属语言:Python 资源全名:lambda-decorators-0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
python库。 资源全名:comapsmarthome-lambda-decorators-1.0.1.tar.gz
python库。 资源全名:aws-lambda-decorators-0.51.tar.gz
ember-lifeline-decorators-master.rar