有没有人知道如何删除资源上的特定装饰器?我将org.eclipse.ui.decorators
扩展到了我的项目,并创建了一个实现ILightweightLabelDecorator
的类。在装饰器类中,我在调用decorator.addOverlay()
之前测试了条目是否是项目和其他测试。我没有实现其他功能,例如removeListener
,isLabelProperty
,dispose
,addListener
,因为我目前看不到使用。
任何想法,资源,如何进行评论都会有很大帮助。
代码:装饰函数
QualifiedName decorator = new QualifiedName("decorator", "value");
if (element instanceof IProject) {
IProject res = (IProject) element;
if (!res.isOpen()) {
return;
}
String val = null;
try {
val = res.getPersistentProperty(decorator);
} catch (CoreException e) {
e.printStackTrace();
}
if (val != null && val.equals(DecoratorState.ACTIVE)) {
decoration.addOverlay(ImageDescriptor.createFromFile(MyDecorator.class,
"/icons/sample.gif"), IDecoration.BOTTOM_RIGHT);
decoration.addSuffix(" [Using Enhancement]");
}
}
答案 0 :(得分:1)
对于遇到相同问题的任何人,可以使用LabelProviderChangedEvent