* @return
*/
public void createAnnotationList(int selectionOffset, int length) {
annotationList = new ArrayList();
// Projection Annotations
ProjectionAnnotationModel pModel = viewer.getProjectionAnnotationModel();
Iterator i = pModel.getAnnotationIterator();
while (i.hasNext()) {
Object o = i.next();
if (o instanceof ProjectionAnnotation) {
ProjectionAnnotation annotation = (ProjectionAnnotation)o;
Position pos = pModel.getPosition(annotation);
// The annotation is completely inside the selection
if (pos.offset >= selectionOffset
&& pos.offset <= selectionOffset + length) {
boolean collapsed = annotation.isCollapsed();
pModel.expand(annotation);
Position newPos = new Position(pos.offset-selectionOffset,pos.length);
annotationList.add(new AnnotationPosition(annotation,newPos,collapsed));
// Remove the annotation for now.
pModel.removeAnnotation(annotation);
}
// The annotation starts in the selection, but doesn't end in it.
else if(pos.offset >= selectionOffset
&& pos.offset <= selectionOffset + length
&& pos.offset + pos.length >= selectionOffset + length) {
pModel.removeAnnotation(annotation);
}
// The annotation ends in the selection, but doesn't start in it
else if (pos.offset + pos.length >= selectionOffset
&& pos.offset + pos.length <= selectionOffset + length) {
pModel.removeAnnotation(annotation);
}
}
}