问题
Does anyone here knows how to remove a particular decorator on a resource? I extended org.eclipse.ui.decorators to my project and created a class that implements ILightweightLabelDecorator. In the decorator class I tested if the entry was a project and other test before calling decorator.addOverlay(). I did not implemented the other functions such as removeListener, isLabelProperty, dispose, addListener since I currently do not see the use.
Any idea, resources, comment on how to proceed would greatly help.
Code: decorator function
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]");
}
}
回答1:
For anyone who is having that same issue, it can be fixed with LabelProviderChangedEvent
来源:https://stackoverflow.com/questions/9998339/how-to-remove-a-previously-added-decorator-on-a-resource