【发布时间】:2014-06-13 00:46:26
【问题描述】:
我正在尝试将叠加图片添加到 TreeViewer 的特定项目。我已经阅读了 10 多篇关于 stackoverflow 的帖子以及关于 ILightweightLabelDecorator 的其他 Google 结果。
但我在 this guy 遇到了同样的问题:ILightweightLabelDecorator 的 decorate 方法永远不会被调用。
这是我所做的:
...
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new MyViewLabelProvider());
...
//the MyViewLabelProvider class
public class MyViewLabelProvider extends LabelProvider implements ILightweightLabelDecorator{
public void decorate(Object element, IDecoration decoration) {
if(element instanceof MyObject){
decoration.addOverlay(ImageUtil.getImageDescriptor("icons/decorate.gif"), IDecoration.TOP_RIGHT);
}
}
...
完成所有这些事情后,它仍然无法正常工作,所以我什至尝试了 plugin.xml 中的声明方式,但仍然从未调用过 decorate 方法。
<decorator
lightweight="true"
location="TOP_RIGHT"
label="ViewLabelProvider Decorator"
class="com.myplugin.MyViewLabelProvider"
id="com.myplugin.viewlabelprovider.decorator"
state="true">
<enablement>
<objectClass name="com.myplugin.model.MyObject"/>
</enablement>
</decorator>
我错过了什么吗?有人给点提示吗?
【问题讨论】:
标签: java swt jface eclipse-plugin eclipse-pde