I'm writing a custom editor in Eclipse and just integrated custom error recognition. Now I'm facing a strange issue: I can add Markers to my editor that get displayed all fine, I can also delete them while the editor is running.
What doesn't work: When I close my editor I want the markers to disappear/get deleted.
What I'm doing right now, is
creating the Markers with the transient property set like this:
marker.setAttribute(IMarker.TRANSIENT, true);
This doesn't seem to change anything though.trying to delete all Annotations via the source viewers annotation-model. This doesn't work, cause when I try to hook into my editors
dispose()
method or add aDisposeListener
to my sourceviewers textwidget, the sourceviewer already has been disposed of andgetSourceViewer().getAnnotationModel();
returnsnull
.
My deleteMarkers
method:
private void deleteMarkers() {
IAnnotationModel anmod = getSourceViewer().getAnnotationModel();
Iterator<Annotation> it = anmod.getAnnotationIterator();
while (it.hasNext()) {
SimpleMarkerAnnotation a = (SimpleMarkerAnnotation) it.next();
anmod.removeAnnotation(a);
try {
a.getMarker().delete();
} catch (CoreException e) {
e.printStackTrace();
}
}
}
Any help is appreciated ^^