use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.
the class ProjectionViewer method removeProjectionAnnotationModel.
/**
* Removes the projection annotation model from the given annotation model.
*
* @param model the mode from which the projection annotation model is removed
* @return the removed projection annotation model or <code>null</code> if there was none
*/
private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) {
if (model instanceof IAnnotationModelExtension) {
model.removeAnnotationModelListener(fAnnotationModelListener);
IAnnotationModelExtension extension = (IAnnotationModelExtension) model;
return extension.removeAnnotationModel(ProjectionSupport.PROJECTION);
}
return null;
}
use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.
the class ProjectionViewer method addProjectionAnnotationModel.
/**
* Adds the projection annotation model to the given annotation model.
*
* @param model the model to which the projection annotation model is added
*/
private void addProjectionAnnotationModel(IAnnotationModel model) {
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension = (IAnnotationModelExtension) model;
extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel);
model.addAnnotationModelListener(fAnnotationModelListener);
}
}
use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.
the class ProjectionRulerColumn method setModel.
@Override
public void setModel(IAnnotationModel model) {
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension = (IAnnotationModelExtension) model;
model = extension.getAnnotationModel(ProjectionSupport.PROJECTION);
}
super.setModel(model);
}
use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.
the class ProjectionSummary method createSummaries.
private void createSummaries(IProgressMonitor monitor, IAnnotationModel visualAnnotationModel) {
ProjectionAnnotationModel model = fProjectionViewer.getProjectionAnnotationModel();
if (model == null)
return;
Map<Annotation, Position> additions = new HashMap<>();
Iterator<Annotation> e = model.getAnnotationIterator();
while (e.hasNext()) {
ProjectionAnnotation projection = (ProjectionAnnotation) e.next();
if (projection.isCollapsed()) {
Position position = model.getPosition(projection);
if (position != null) {
IRegion[] summaryRegions = fProjectionViewer.computeCollapsedRegions(position);
if (summaryRegions != null) {
Position summaryAnchor = fProjectionViewer.computeCollapsedRegionAnchor(position);
if (summaryAnchor != null)
createSummary(additions, summaryRegions, summaryAnchor);
}
}
}
if (isCanceled(monitor))
return;
}
if (additions.size() > 0) {
if (visualAnnotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension = (IAnnotationModelExtension) visualAnnotationModel;
if (!isCanceled(monitor))
extension.replaceAnnotations(null, additions);
} else {
Iterator<Annotation> e1 = additions.keySet().iterator();
while (e1.hasNext()) {
AnnotationBag bag = (AnnotationBag) e1.next();
Position position = additions.get(bag);
if (isCanceled(monitor))
return;
visualAnnotationModel.addAnnotation(bag, position);
}
}
}
}
use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.
the class ProjectionSummary method removeSummaries.
private void removeSummaries(IProgressMonitor monitor, IAnnotationModel visualAnnotationModel) {
IAnnotationModelExtension extension = null;
List<Annotation> bags = null;
if (visualAnnotationModel instanceof IAnnotationModelExtension) {
extension = (IAnnotationModelExtension) visualAnnotationModel;
bags = new ArrayList<>();
}
Iterator<Annotation> e = visualAnnotationModel.getAnnotationIterator();
while (e.hasNext()) {
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);
}
}
Aggregations