private void addAnnotations(Map<Annotation, Position> annotationToPositionMap) { if (fModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel; ame.replaceAnnotations(new Annotation[0], annotationToPositionMap); } else { Set<Entry<Annotation, Position>> entrySet = annotationToPositionMap.entrySet(); for (Entry<Annotation, Position> entry : entrySet) { fModel.addAnnotation(entry.getKey(), entry.getValue()); } } }
private void removeAnnotations(IAnnotationModel model, Set annotations) { if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) model; Annotation[] annotationArray= new Annotation[annotations.size()]; ame.replaceAnnotations((Annotation[]) annotations.toArray(annotationArray), Collections.EMPTY_MAP); } else { for (Iterator iter= annotations.iterator(); iter.hasNext();) { Annotation element= (Annotation) iter.next(); model.removeAnnotation(element); } } }
private void addAnnotations(IAnnotationModel model, Map<Annotation, Position> annotationToPositionMap) { if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) model; ame.replaceAnnotations(new Annotation[0], annotationToPositionMap); } else { for (Entry<Annotation, Position> entry : annotationToPositionMap.entrySet()) { model.addAnnotation(entry.getKey(), entry.getValue()); } } }
private void removeAnnotations(IAnnotationModel model, Set<Annotation> annotations) { if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) model; Annotation[] annotationArray= new Annotation[annotations.size()]; ame.replaceAnnotations(annotations.toArray(annotationArray), Collections.emptyMap()); } else { for (Annotation element : annotations) { model.removeAnnotation(element); } } }
private void addAnnotations(IAnnotationModel model, Map annotationToPositionMap) { if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) model; ame.replaceAnnotations(new Annotation[0], annotationToPositionMap); } else { for (Iterator elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) { Annotation element= (Annotation) elements.next(); Position p= (Position) annotationToPositionMap.get(element); model.addAnnotation(element, p); } } }
private void addAnnotations(Map annotationToPositionMap) { if (fModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel; ame.replaceAnnotations(new Annotation[0], annotationToPositionMap); } else { for (Iterator elements= annotationToPositionMap.keySet().iterator(); elements.hasNext();) { Annotation element= (Annotation) elements.next(); Position p= (Position) annotationToPositionMap.get(element); fModel.addAnnotation(element, p); } } }
private void updateAnnotationModelForRemoves(IAnnotationModel annotationModel) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i = 0, length = fOccurrenceAnnotations.length; i < length; i++) { annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } } fOccurrenceAnnotations = null; }
private void updateAnnotations(IAnnotationModel annotationModel, Map<Annotation, Position> annotationMap) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap); } else { removeOccurrenceAnnotations(); Iterator<Map.Entry<Annotation, Position>> iter = annotationMap.entrySet().iterator(); while (iter.hasNext()) { Entry<Annotation, Position> mapEntry = iter.next(); annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue()); } } fOccurrenceAnnotations = annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]); } }
/** * Removes all override indicators from this manager's annotation model. */ void removeAnnotations() { if (fOverrideAnnotations == null) return; synchronized (fAnnotationModelLockObject) { if (fAnnotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null); } else { for (int i= 0, length= fOverrideAnnotations.length; i < length; i++) fAnnotationModel.removeAnnotation(fOverrideAnnotations[i]); } fOverrideAnnotations= null; } }
/** * Removes all override indicators from this manager's annotation model. */ void removeAnnotations() { if (fOverrideAnnotations == null) return; synchronized (fAnnotationModelLockObject) { if (fAnnotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null); } else { for (int i= 0, length= fOverrideAnnotations.length; i < length; i++) fAnnotationModel.removeAnnotation(fOverrideAnnotations[i]); } fOverrideAnnotations= null; } }
/** * Removes annotations from the given annotation model. The default implementation works for editors that * implement <code>ITextEditor</code>. * Subclasses may override this method. * @param annotations A set containing the annotations to be removed. * @see Annotation */ private void removeAnnotations(Collection<Annotation> annotations) { if (fModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel; Annotation[] annotationArray= new Annotation[annotations.size()]; ame.replaceAnnotations(annotations.toArray(annotationArray), Collections.emptyMap()); } else { for (Annotation element : annotations) { fModel.removeAnnotation(element); } } }
/** * Removes all override indicators from this manager's annotation model. */ void removeAnnotations() { if (fOverrideAnnotations == null) return; synchronized (fAnnotationModelLockObject) { if (fAnnotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null); } else { for (int i= 0, length= fOverrideAnnotations.length; i < length; i++) fAnnotationModel.removeAnnotation(fOverrideAnnotations[i]); } fOverrideAnnotations= null; } }
/** * Removes annotations from the given annotation model. The default implementation works for editors that * implement <code>ITextEditor</code>. * Subclasses may override this method. * @param annotations A set containing the annotations to be removed. * @see Annotation */ private void removeAnnotations(Collection annotations) { if (fModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel; Annotation[] annotationArray= new Annotation[annotations.size()]; ame.replaceAnnotations((Annotation[]) annotations.toArray(annotationArray), Collections.EMPTY_MAP); } else { for (Iterator iter= annotations.iterator(); iter.hasNext();) { Annotation element= (Annotation) iter.next(); fModel.removeAnnotation(element); } } }
public void run() { if (!progress.isCanceled()) { final IAnnotationModel annotationModel = getAnnotationModel(editor); if (annotationModel instanceof IAnnotationModelExtension) ((IAnnotationModelExtension) annotationModel).replaceAnnotations( getExistingOccurrenceAnnotations(annotationModel), annotations); else if(annotationModel != null) throw new IllegalStateException( "AnnotationModel does not implement IAnnotationModelExtension"); //$NON-NLS-1$ } } });
/** * Remove the inlined annotations. */ private void removeInlinedAnnotations() { IAnnotationModel annotationModel= fViewer.getAnnotationModel(); if (annotationModel == null || fInlinedAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension) annotationModel).replaceAnnotations( fInlinedAnnotations.toArray(new Annotation[fInlinedAnnotations.size()]), null); } else { for (AbstractInlinedAnnotation annotation : fInlinedAnnotations) annotationModel.removeAnnotation(annotation); } fInlinedAnnotations= null; } }
/** * Adds a collection of annotations. * * @param annotations the annotations */ @Override public void addedAnnotation(Collection<AnnotationFS> annotations) { IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput()); Map<Annotation, Position> addAnnotationMap = new HashMap<Annotation, Position>(); for (AnnotationFS annotation : annotations) { addAnnotationMap.put(new EclipseAnnotationPeer(annotation), new Position(annotation.getBegin(), annotation.getEnd() - annotation.getBegin())); } annotationModel.replaceAnnotations(null, addAnnotationMap); }
void removeOccurrenceAnnotations() { fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fMarkOccurrenceTargetRegion= null; IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider == null) return; IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); if (annotationModel == null || fOccurrenceAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } fOccurrenceAnnotations= null; } }
void removeOccurrenceAnnotations() { fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fMarkOccurrenceTargetRegion= null; IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider == null) return; IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); if (annotationModel == null || fOccurrenceAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } fOccurrenceAnnotations= null; } }
void removeOccurrenceAnnotations() { fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fMarkOccurrenceTargetRegion= null; IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider == null) return; IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput()); if (annotationModel == null || fOccurrenceAnnotations == null) return; synchronized (getLockObject(annotationModel)) { if (annotationModel instanceof IAnnotationModelExtension) { ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); } else { for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); } fOccurrenceAnnotations= null; } }
/** * Removes a collection of annotations. * * @param deletedAnnotations the deleted annotations */ @Override public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) { if (getSite().getPage().getActivePart() == AnnotationEditor.this) { mFeatureStructureSelectionProvider.clearSelection(); } else { mFeatureStructureSelectionProvider.clearSelectionSilently(); } highlight(0, 0); // TODO: only if removed annotation was selected IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput()); Annotation removeAnnotations[] = new Annotation[deletedAnnotations.size()]; int removeAnnotationsIndex = 0; for (AnnotationFS annotation : deletedAnnotations) { removeAnnotations[removeAnnotationsIndex++] = new EclipseAnnotationPeer(annotation); } annotationModel.replaceAnnotations(removeAnnotations, null); }