这里有人知道如何删除资源上的特定装饰器吗?我将 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]");
}
}
最佳答案
对于遇到相同问题的任何人,可以使用 LabelProviderChangedEvent
进行修复
关于java - 如何删除资源上先前添加的装饰器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9998339/