private boolean isCanceled(IProgressMonitor monitor) {
return monitor != null && monitor.isCanceled();
}
private void removeSummaries(IProgressMonitor monitor, IAnnotationModel visualAnnotationModel) {
IAnnotationModelExtension extension= null;
List bags= null;
if (visualAnnotationModel instanceof IAnnotationModelExtension) {
extension= (IAnnotationModelExtension)visualAnnotationModel;
bags= new ArrayList();
}
Iterator e= visualAnnotationModel.getAnnotationIterator();
while (e.hasNext()) {
Annotation annotation= (Annotation) e.next();
if (annotation instanceof AnnotationBag) {
if (bags == null)
visualAnnotationModel.removeAnnotation(annotation);
else
bags.add(annotation);
}
if (isCanceled(monitor))
return;
}
if (bags != null && bags.size() > 0) {
Annotation[] deletions= new Annotation[bags.size()];
bags.toArray(deletions);
if (!isCanceled(monitor))
extension.replaceAnnotations(deletions, null);
}
}