/** * Removes all annotations from the model whose associated positions have been * deleted. If requested inform all model listeners about the change. * * @param fireModelChanged indicates whether to notify all model listeners */ protected void cleanup(boolean fireModelChanged) { cleanup(fireModelChanged, true); }
/** * Removes all annotations from the model whose associated positions have been * deleted. If requested inform all model listeners about the change. * * @param fireModelChanged indicates whether to notify all model listeners */ protected void cleanup(boolean fireModelChanged) { cleanup(fireModelChanged, true); }
/** * Returns all annotations managed by this model. <code>cleanup</code> * indicates whether all annotations whose associated positions are * deleted should previously be removed from the model. * * @param cleanup indicates whether annotations with deleted associated positions are removed * @return all annotations managed by this model */ protected Iterator<Annotation> getAnnotationIterator(boolean cleanup) { if (cleanup) cleanup(true); return getAnnotationMap().keySetIterator(); }
/** * Returns all annotations managed by this model. <code>cleanup</code> * indicates whether all annotations whose associated positions are * deleted should previously be removed from the model. * * @param cleanup indicates whether annotations with deleted associated positions are removed * @return all annotations managed by this model */ protected Iterator<Annotation> getAnnotationIterator(boolean cleanup) { if (cleanup) cleanup(true); return getAnnotationMap().keySetIterator(); }
/** * Returns an iterator as specified in {@link IAnnotationModelExtension2#getAnnotationIterator(int, int, boolean, boolean)} * * @param offset region start * @param length region length * @param canStartBefore position can start before region * @param canEndAfter position can end after region * @return an iterator to iterate over annotations in region * @see IAnnotationModelExtension2#getAnnotationIterator(int, int, boolean, boolean) * @since 3.4 */ private Iterator<Annotation> getRegionAnnotationIterator(int offset, int length, boolean canStartBefore, boolean canEndAfter) { if (!(fDocument instanceof AbstractDocument)) return new RegionIterator(getAnnotationIterator(true), this, offset, length, canStartBefore, canEndAfter); AbstractDocument document= (AbstractDocument) fDocument; cleanup(true); try { Position[] positions= document.getPositions(IDocument.DEFAULT_CATEGORY, offset, length, canStartBefore, canEndAfter); return new AnnotationsInterator(positions, fPositions); } catch (BadPositionCategoryException e) { // can happen if e.g. the document doesn't contain such a category, or when removed in a different thread return Collections.<Annotation>emptyList().iterator(); } }
/** * Returns an iterator as specified in {@link IAnnotationModelExtension2#getAnnotationIterator(int, int, boolean, boolean)} * * @param offset region start * @param length region length * @param canStartBefore position can start before region * @param canEndAfter position can end after region * @return an iterator to iterate over annotations in region * @see IAnnotationModelExtension2#getAnnotationIterator(int, int, boolean, boolean) * @since 3.4 */ private Iterator<Annotation> getRegionAnnotationIterator(int offset, int length, boolean canStartBefore, boolean canEndAfter) { if (!(fDocument instanceof AbstractDocument)) return new RegionIterator(getAnnotationIterator(true), this, offset, length, canStartBefore, canEndAfter); AbstractDocument document= (AbstractDocument) fDocument; cleanup(true); try { Position[] positions= document.getPositions(IDocument.DEFAULT_CATEGORY, offset, length, canStartBefore, canEndAfter); return new AnnotationsInterator(positions, fPositions); } catch (BadPositionCategoryException e) { // can happen if e.g. the document doesn't contain such a category, or when removed in a different thread return Collections.<Annotation>emptyList().iterator(); } }