rcp(插件开发)org.eclipse.ui.decorators 使用,可以对应的节点添加不同的图标显示
来源:互联网 发布:ps cs6去掉元数据 编辑:程序博客网 时间:2024/05/23 21:56
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;
效果图:
- rcp(插件开发)org.eclipse.ui.decorators 使用,可以对应的节点添加不同的图标显示
- rcp(插件开发)org.eclipse.ui.decorators 使用
- rcp(插件开发)org.eclipse.ui.menus-可以添加在视图上
- rcp(插件开发) org.eclipse.ui.actions.ActionGroup 使用
- rcp(插件开发)org.eclipse.ui.propertyPages 扩展点使用
- rcp(插件开发)org.eclipse.ui.menus扩展点使用
- rcp(插件开发)org.eclipse.core.resources.builders扩展点-转载二进制兄弟的文章
- rcp(插件开发)程序发布到不同的平台
- rcp(插件开发)Eclipse下的Java反编译插件
- Eclipse RCP开发:使用Maven的Tycho插件打包部署
- Eclipse开发Swing, SWT, RCP的插件
- rcp(插件开发)屏蔽eclipse的菜单项
- org.eclipse.ui.decorators得用法
- Eclipse插件开发之org.eclipse.ui.editorActions使用
- rcp(插件开发) 如何获取eclipse or rcp的安装目录
- Eclipse的rcp插件,在Perspective中添加ViewPart无效
- Eclipse RCP 插件开发中经常调用的几个方法
- Eclipse RCP 插件开发中经常调用的几个方法
- 第十章、Tiny4412 U-BOOT移植十 DDR工作时序与原理二
- 删除两个双向循环链表的相同节点
- lwip在window下的udp测试代码
- 单例 Singleton
- Android ADT 23.0.0更新地址
- rcp(插件开发)org.eclipse.ui.decorators 使用,可以对应的节点添加不同的图标显示
- autoit实现自动化上传下载探索之路
- 用递归和迭代分别处理斐波那契数列
- 判断输入的是否为汉字或者数字
- Android JNI知识简介
- 多线程之多生产多消费者
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法
- Ubuntu 14.04 LTS 更新后无法启动VirtualBox和Genymotion 错误Kernel driver not installed (rc=-1908)
- x集成测试状态迁移