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()); } } }
/** * Creates the visual annotation model on top of the given annotation model. * * @param annotationModel the wrapped annotation model * @return the visual annotation model on top of the given annotation model * @since 3.0 */ protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel) { IAnnotationModelExtension model= new AnnotationModel(); model.addAnnotationModel(MODEL_ANNOTATION_MODEL, annotationModel); return (IAnnotationModel) model; }
@Override public IAnnotationModel getAnnotationModel() { if (fVisualAnnotationModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; return extension.getAnnotationModel(MODEL_ANNOTATION_MODEL); } return null; }
private void ensureAnnotationModelInstalled() { LinkedPositionAnnotations lpa= fCurrentTarget.fAnnotationModel; if (lpa != null) { ITextViewer viewer= fCurrentTarget.getViewer(); if (viewer instanceof ISourceViewer) { ISourceViewer sv= (ISourceViewer) viewer; IAnnotationModel model= sv.getAnnotationModel(); if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ext= (IAnnotationModelExtension) model; IAnnotationModel ourModel= ext.getAnnotationModel(getUniqueKey()); if (ourModel == null) { ext.addAnnotationModel(getUniqueKey(), lpa); } } } } }
/** * Sync annotations. */ private void syncAnnotations() { removeAllAnnotations(); // Remove all annotation from the model IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput()); ((IAnnotationModelExtension) annotationModel).removeAllAnnotations(); // Add all annotation to the model // copy annotations into annotation model final Iterator<AnnotationFS> mAnnotations = getDocument().getCAS().getAnnotationIndex() .iterator(); // TODO: Build first a map, and then pass all annotations at once Map annotationsToAdd = new HashMap(); while (mAnnotations.hasNext()) { AnnotationFS annotationFS = mAnnotations.next(); annotationsToAdd.put(new EclipseAnnotationPeer(annotationFS), new Position( annotationFS.getBegin(), annotationFS.getEnd() - annotationFS.getBegin())); } ((IAnnotationModelExtension) annotationModel).replaceAnnotations(null, annotationsToAdd); }
modelExtension.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID); modelExtension.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, newDiffer);
/** * Removes the projection annotation model from the given annotation model. * * @param model the mode from which the projection annotation model is removed * @return the removed projection annotation model or <code>null</code> if there was none */ private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) { if (model instanceof IAnnotationModelExtension) { model.removeAnnotationModelListener(fAnnotationModelListener); IAnnotationModelExtension extension= (IAnnotationModelExtension) model; return extension.removeAnnotationModel(ProjectionSupport.PROJECTION); } return null; }
@Override public void setRangeIndication(int start, int length, boolean moveCursor) { if (moveCursor) { setSelectedRange(start, 0); revealRange(start, length); } if (fRangeIndicator != null && fVisualAnnotationModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); } }
/** * Removes the all annotations. */ private void removeAllAnnotations() { // Remove all annotation from the model IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput()); ((IAnnotationModelExtension) annotationModel).removeAllAnnotations(); }
private void ensureAnnotationModelInstalled() { LinkedPositionAnnotations lpa= fCurrentTarget.fAnnotationModel; if (lpa != null) { ITextViewer viewer= fCurrentTarget.getViewer(); if (viewer instanceof ISourceViewer) { ISourceViewer sv= (ISourceViewer) viewer; IAnnotationModel model= sv.getAnnotationModel(); if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ext= (IAnnotationModelExtension) model; IAnnotationModel ourModel= ext.getAnnotationModel(getUniqueKey()); if (ourModel == null) { ext.addAnnotationModel(getUniqueKey(), lpa); } } } } }
modelExtension.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID); modelExtension.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, newDiffer);
/** * Removes the projection annotation model from the given annotation model. * * @param model the mode from which the projection annotation model is removed * @return the removed projection annotation model or <code>null</code> if there was none */ private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) { if (model instanceof IAnnotationModelExtension) { model.removeAnnotationModelListener(fAnnotationModelListener); IAnnotationModelExtension extension= (IAnnotationModelExtension) model; return extension.removeAnnotationModel(ProjectionSupport.PROJECTION); } return null; }
@Override public void setRangeIndication(int start, int length, boolean moveCursor) { if (moveCursor) { setSelectedRange(start, 0); revealRange(start, length); } if (fRangeIndicator != null && fVisualAnnotationModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); } }
( ( IAnnotationModelExtension ) annotationModel ).removeAllAnnotations();
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); } } }
@Override public IAnnotationModel getAnnotationModel() { if (fVisualAnnotationModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; return extension.getAnnotationModel(MODEL_ANNOTATION_MODEL); } return null; }
DocumentLineDiffer differ= (DocumentLineDiffer)model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID); model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ);
/** * Adds the projection annotation model to the given annotation model. * * @param model the model to which the projection annotation model is added */ private void addProjectionAnnotationModel(IAnnotationModel model) { if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension extension= (IAnnotationModelExtension) model; extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel); model.addAnnotationModelListener(fAnnotationModelListener); } }
private void uninstallAnnotationModel(LinkedModeUITarget target) { ITextViewer viewer= target.getViewer(); if (viewer instanceof ISourceViewer) { ISourceViewer sv= (ISourceViewer) viewer; IAnnotationModel model= sv.getAnnotationModel(); if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ext= (IAnnotationModelExtension) model; ext.removeAnnotationModel(getUniqueKey()); } } }
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); } } }