rcp(插件开发)org.eclipse.ui.decorators 使用
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 使用的更多相关文章
- 【eclipse插件开发实战】Eclipse插件开发1——eclipse内核结构、扩展点机制
Eclipse插件开发实战1--eclipse内核结构.扩展点机制 一.前言 本系列总体介绍eclipse插件开发基本理论.插件项目结构及开发步骤,最后再给出两个插件开发实例. 总体安排结构如下: 1 ...
- Application "org.eclipse.ui.ide.workbench" could not be found in the registry.问题的解决
今天升级Eclipse,升级完Restart,碰到启动不了让看日志,日志里主要错误信息即是Application "org.eclipse.ui.ide.workbench" co ...
- 【Eclipse】一个简单的 RCP 应用 —— 显示Eclipse 的启动时间。
1 创建一个插件项目 1.1 File - New - Plug-in Project 注: 1 如果 New 下没有 Plug-in Project , 到 Other 里面去找. 2 如上截图的下 ...
- org.eclipse.ui.menus扩展点学习
Eclipse菜单: menu:help?after=addtions menu:navigate?after=open.ext2 menu:window?after=newEditor menu:f ...
- JFace dailog button事件中刷新透视图异常 Trying to execute the disabled command org.eclipse.ui.window.closePerspective
报错的代码为 protected void buttonPressed(int buttonId) { Display.getDefault().syncExec(new Runnable() { p ...
- How to set font and colors of Eclipse UI
The original URL of this article is https://codeyarns.com/2014/11/03/how-to-set-font-and-font-size-o ...
- 【eclipse插件开发实战】 Eclipse插件开发6——eclipse在线翻译插件Translator开发实例详解
Eclipse插件开发6--eclipse在线翻译插件Translator开发实例详解 在上一篇文章中讲到了一个简单的eclipse插件开发实例,主要是对插件工程的基本创建步骤进行了讲解,这篇文章当中 ...
- 【转】RCP中org.eclipse.core.runtime.CoreException
org.eclipse.core.runtime.CoreException: Plug-in TRAIN was unable to load class train.Application. 利用 ...
- org.eclipse.ui.PartInitException: Unable to open editor, unknown editor ID: org.xmen.ui.text.XMLTextEditor
无法打开struts模式的编译xml的编译器,然后打开.project文件,编辑最后一行,找到<natures>结点,增加一条<nature>com.genuitec.ecli ...
随机推荐
- QLinkedList和std::forward_list(都是双向链表,不支持operator[],好处可能是插入和删除都比较快)
forward_list forward_list是C++11版本才有的.forward_list被实现为单链表,而list是一个双向链表,所以forward_list要比list高效一些.forwa ...
- 用Python做2048游戏 网易云课堂配套实验课。通过GUI来体验编程的乐趣。
第1节 认识wxpython 第2节 画几个形状 第3节 再做个计算器 第4节 最后实现个2048游戏 实验1-认识wxpython 一.实验说明 1. 环境登录 无需密码自动登录,系统用户名shiy ...
- Haxe UI框架StablexUI的使用备忘与心得(序)
最近在手上的项目开发中,从原来的使用Sprite全手写UI,开始逐步使用StablexUI,感觉还是相当不错的,强大.高效.轻量.灵活,非常适应我当前的实际需求. 不过作为小种语言的一个小众第三方开源 ...
- SignalR 聊天室实例详解(服务器端推送版)
翻译自:http://www.codeproject.com/Articles/562023/Asp-Net-SignalR-Chat-Room (在这里可以下载到实例的源码) Asp.Net Si ...
- C#对数字添加逗号,千分位
/// <summary> /// 对数字添加”,“号,可以处理负数以及带有小数的情况 /// </summary> /// <param name="vers ...
- [Oracle]TRIGGER
题外话: Oracle 的使用. 以前客户方用的是SQL SERVER,一直在用SQL SERVER,感觉SQL SERVER的用户体验非常好. 不管是开发环境的界面布局到SQL 的写法上,感觉写起来 ...
- C语言指针和数组知识总结(下)
一.数组指针: 数组指针就是一个指针,只不过它指向的是一个数组.可以通过如下方式来定义 typedef int Array[5]; //数组类型 Array* m; //数组定义 还有一种更 ...
- 微软Ajax--UpdatePanel控件
今天用做日历显示本月的考勤记录,用到了UpdatePanel控件,才发现对这个控件并不太了解,所以找了点儿资料,整理了一下给大家发上来! 一.UpdatePanel的结构 <asp:Script ...
- 菜鸟级springmvc+spring+mybatis整合开发用户登录功能(上)
由于本人愚钝,整合ssm框架真是费劲了全身的力气,所以打算写下这篇文章,一来是对整个过程进行一个回顾,二来是方便有像我一样的笨鸟看过这篇文章后对其有所帮助,如果本文中有不对的地方,也请大神们指教. 一 ...
- 云计算Docker全面项目实战(Maven+Jenkins、日志管理ELK、WordPress博客镜像)
2013年,云计算领域从此多了一个名词“Docker”.以轻量著称,更好的去解决应用打包和部署.之前我们一直在构建Iaas,但通过Iaas去实现统一功 能还是相当复杂得,并且维护复杂.将特殊性封装到 ...