public Position getPosition(Annotation annotation) { if(delegate != null) { return delegate.getPosition(annotation); } else { return null; } }
public Iterator getAnnotationIterator() { if(delegate != null) { return delegate.getAnnotationIterator(); } else { return null; } }
protected void announceAnnotationChanged(Annotation annotation) { if (annotationModel instanceof XtextResourceMarkerAnnotationModel) ((XtextResourceMarkerAnnotationModel) annotationModel).fireAnnotationChangedEvent(annotation); else { Position position = annotationModel.getPosition(annotation); if (annotationModel instanceof IAnnotationModelExtension) ((IAnnotationModelExtension) annotationModel).modifyAnnotationPosition(annotation, position); else { annotationModel.removeAnnotation(annotation); annotationModel.addAnnotation(annotation, position); } } }
private void setDiffer(IAnnotationModel differ) { if (differ instanceof ILineDiffer || differ == null) { if (fLineDiffer != differ) { if (fLineDiffer != null) ((IAnnotationModel) fLineDiffer).removeAnnotationModelListener(fAnnotationListener); fLineDiffer = (ILineDiffer) differ; if (fLineDiffer != null) ((IAnnotationModel) fLineDiffer).addAnnotationModelListener(fAnnotationListener); } } }
@Override public IAnnotationModel removeAnnotationModel(Object key) { IAnnotationModel ret= fAttachments.remove(key); if (ret != null) { for (int i= 0; i < fOpenConnections; i++) ret.disconnect(fDocument); ret.removeAnnotationModelListener(fModelListener); } return ret; }
@Override public void addAnnotationModel(Object key, IAnnotationModel attachment) { Assert.isNotNull(attachment); if (!fAttachments.containsValue(attachment)) { fAttachments.put(key, attachment); for (int i= 0; i < fOpenConnections; i++) attachment.connect(fDocument); attachment.addAnnotationModelListener(fModelListener); } }
private List<ICompletionProposal> computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) { int offset= context.getOffset(); ArrayList<SpellingProblem> annotationList= new ArrayList<>(); Iterator<Annotation> iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation= iter.next(); if (canFix(annotation)) { Position pos= model.getPosition(annotation); if (isAtPosition(offset, pos)) { collectSpellingProblems(annotation, annotationList); } } } SpellingProblem[] spellingProblems= annotationList.toArray(new SpellingProblem[annotationList.size()]); return computeProposals(context, spellingProblems); }
@Override public void endCollecting() { List<Annotation> toRemove= new ArrayList<>(); synchronized (fLockObject) { Iterator<Annotation> iter= fAnnotationModel.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation= iter.next(); if (SpellingAnnotation.TYPE.equals(annotation.getType())) toRemove.add(annotation); } Annotation[] annotationsToRemove= toRemove.toArray(new Annotation[toRemove.size()]); if (fAnnotationModel instanceof IAnnotationModelExtension) ((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(annotationsToRemove, fAddAnnotations); else { for (Annotation element : annotationsToRemove) { fAnnotationModel.removeAnnotation(element); } for (Entry<Annotation, Position> entry : fAddAnnotations.entrySet()) { fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue()); } } } fAddAnnotations= null; } }
protected void updateAnnotations(IProgressMonitor monitor, List<Annotation> toBeRemoved, Map<Annotation, Position> annotationToPosition) { if (monitor.isCanceled()) { return; } if (annotationModel instanceof IAnnotationModelExtension) { Annotation[] removedAnnotations = toBeRemoved.toArray(new Annotation[toBeRemoved.size()]); ((IAnnotationModelExtension) annotationModel).replaceAnnotations(removedAnnotations, annotationToPosition); } else { for (Annotation annotation : toBeRemoved) { if (monitor.isCanceled()) { return; } annotationModel.removeAnnotation(annotation); } for (Map.Entry<Annotation, Position> entry : annotationToPosition.entrySet()) { if (monitor.isCanceled()) { return; } annotationModel.addAnnotation(entry.getKey(), entry.getValue()); } } }
@Override public void removeRangeIndication() { if (fRangeIndicator != null && fVisualAnnotationModel != null) fVisualAnnotationModel.removeAnnotation(fRangeIndicator); }
public void addAnnotation(Annotation annotation, Position position) { if(delegate != null) { delegate.addAnnotation(annotation, position); } }
public void disconnect(IDocument document) { if(delegate != null) { delegate.disconnect(document); } }
public void connect(IDocument document) { if(delegate != null) { delegate.connect(document); } }
/** * Constructs this column with the given arguments. * * @param model the annotation model to get the annotations from * @param width the width of the vertical ruler */ public AnnotationRulerColumn(IAnnotationModel model, int width) { fWidth= width; fAllowSetModel= false; fModel= model; fModel.addAnnotationModelListener(fInternalListener); }
/** * Disposes of this painter and releases any resources. */ private void handleDispose() { if (fLineDiffer != null) { ((IAnnotationModel) fLineDiffer).removeAnnotationModelListener(fAnnotationListener); fLineDiffer= null; } }
private List computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) { int offset= context.getOffset(); ArrayList annotationList= new ArrayList(); Iterator iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation= (Annotation)iter.next(); if (canFix(annotation)) { Position pos= model.getPosition(annotation); if (isAtPosition(offset, pos)) { collectSpellingProblems(annotation, pos, annotationList); } } } SpellingProblem[] spellingProblems= (SpellingProblem[]) annotationList.toArray(new SpellingProblem[annotationList.size()]); return computeProposals(context, spellingProblems); }
private void calculateLightBulb(IAnnotationModel model, IInvocationContext context) { boolean needsAnnotation= JavaCorrectionProcessor.hasAssists(context); if (fIsAnnotationShown) { model.removeAnnotation(fAnnotation); } if (needsAnnotation) { model.addAnnotation(fAnnotation, new Position(context.getSelectionOffset(), context.getSelectionLength())); } fIsAnnotationShown= needsAnnotation; }
private void removeLightBulb(IAnnotationModel model) { synchronized (this) { if (fIsAnnotationShown) { model.removeAnnotation(fAnnotation); fIsAnnotationShown= false; } } }
@Override public void setModel(IAnnotationModel model) { if (fAllowSetModel && model != fModel) { if (fModel != null) fModel.removeAnnotationModelListener(fAnnotationListener); fModel= model; if (fModel != null) fModel.addAnnotationModelListener(fAnnotationListener); postRedraw(); } }
@Override public void endCollecting() { synchronized (fLockObject) { for (Entry<SpellingAnnotation, Position> entry : fAddAnnotations.entrySet()) { fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue()); } deleteNonstringSpellingAnnotations(fAddAnnotations.keySet().iterator()); } fAddAnnotations = null; } }