@Override public void connect(IDocument document) { Assert.isTrue(fDocument == null || fDocument == document); if (fDocument == null) { fDocument= document; Iterator<Position> e= getAnnotationMap().valuesIterator(); while (e.hasNext()) try { addPosition(document, e.next()); } catch (BadLocationException x) { // ignore invalid position } } ++ fOpenConnections; if (fOpenConnections == 1) { document.addDocumentListener(fDocumentListener); connected(); } for (Iterator<Object> it= fAttachments.keySet().iterator(); it.hasNext();) { IAnnotationModel model= fAttachments.get(it.next()); model.connect(document); } }
/** * Adds the given annotation to this model. Associates the * annotation with the given position. If requested, all annotation * model listeners are informed about this model change. If the annotation * is already managed by this model nothing happens. * * @param annotation the annotation to add * @param position the associate position * @param fireModelChanged indicates whether to notify all model listeners * @throws BadLocationException if the position is not a valid document position */ protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException { if (!fAnnotations.containsKey(annotation)) { addPosition(fDocument, position); fAnnotations.put(annotation, position); fPositions.put(position, annotation); synchronized (getLockObject()) { getAnnotationModelEvent().annotationAdded(annotation); } if (fireModelChanged) fireModelChanged(); } }
/** * Adds the given annotation to this model. Associates the * annotation with the given position. If requested, all annotation * model listeners are informed about this model change. If the annotation * is already managed by this model nothing happens. * * @param annotation the annotation to add * @param position the associate position * @param fireModelChanged indicates whether to notify all model listeners * @throws BadLocationException if the position is not a valid document position */ protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException { if (!fAnnotations.containsKey(annotation)) { addPosition(fDocument, position); fAnnotations.put(annotation, position); fPositions.put(position, annotation); synchronized (getLockObject()) { getAnnotationModelEvent().annotationAdded(annotation); } if (fireModelChanged) fireModelChanged(); } }
@Override public void connect(IDocument document) { Assert.isTrue(fDocument == null || fDocument == document); if (fDocument == null) { fDocument= document; Iterator<Position> e= getAnnotationMap().valuesIterator(); while (e.hasNext()) try { addPosition(document, e.next()); } catch (BadLocationException x) { // ignore invalid position } } ++ fOpenConnections; if (fOpenConnections == 1) { document.addDocumentListener(fDocumentListener); connected(); } for (IAnnotationModel model : fAttachments.values()) { model.connect(document); } }