Search in sources :

Example 6 with IAnnotationModelExtension

use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.

the class LineNumberColumn method getAnnotationModelWithDiffer.

/**
 * Returns the annotation model that contains the quick diff annotation model.
 * <p>
 * Extracts the line differ from the displayed document's annotation model. If none can be found,
 * a new differ is created and attached to the annotation model.</p>
 *
 * @return the annotation model that contains the line differ, or <code>null</code> if none could be found or created
 * @see IChangeRulerColumn#QUICK_DIFF_MODEL_ID
 */
private IAnnotationModel getAnnotationModelWithDiffer() {
    ISourceViewer viewer = fViewer;
    if (viewer == null)
        return null;
    IAnnotationModel m = viewer.getAnnotationModel();
    IAnnotationModelExtension model = null;
    if (m instanceof IAnnotationModelExtension)
        model = (IAnnotationModelExtension) m;
    IAnnotationModel differ = getDiffer();
    // create diff model if it doesn't
    if (differ == null) {
        IPreferenceStore store = getPreferenceStore();
        if (store != null) {
            String defaultId = store.getString(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
            differ = new QuickDiff().createQuickDiffAnnotationModel(getEditor(), defaultId);
            if (differ != null) {
                if (model == null)
                    model = new AnnotationModel();
                model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ);
            }
        }
    } else if (differ instanceof ILineDifferExtension2) {
        if (((ILineDifferExtension2) differ).isSuspended())
            ((ILineDifferExtension) differ).resume();
    } else if (differ instanceof ILineDifferExtension) {
        ((ILineDifferExtension) differ).resume();
    }
    return (IAnnotationModel) model;
}
Also used : QuickDiff(org.eclipse.ui.texteditor.quickdiff.QuickDiff) ILineDifferExtension2(org.eclipse.jface.text.source.ILineDifferExtension2) ILineDifferExtension(org.eclipse.jface.text.source.ILineDifferExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) IAnnotationModelExtension(org.eclipse.jface.text.source.IAnnotationModelExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 7 with IAnnotationModelExtension

use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.

the class LineNumberColumn method getDiffer.

/**
 * Extracts the line differ from the displayed document's annotation model. If none can be found,
 * <code>null</code> is returned.
 *
 * @return the line differ, or <code>null</code> if none could be found
 */
private IAnnotationModel getDiffer() {
    // get annotation model extension
    ISourceViewer viewer = fViewer;
    if (viewer == null)
        return null;
    IAnnotationModel m = viewer.getAnnotationModel();
    if (m == null && fDelegate instanceof IChangeRulerColumn)
        m = ((IChangeRulerColumn) fDelegate).getModel();
    if (!(m instanceof IAnnotationModelExtension))
        return null;
    IAnnotationModelExtension model = (IAnnotationModelExtension) m;
    // get diff model if it exists already
    return model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
}
Also used : IChangeRulerColumn(org.eclipse.jface.text.source.IChangeRulerColumn) IAnnotationModelExtension(org.eclipse.jface.text.source.IAnnotationModelExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Example 8 with IAnnotationModelExtension

use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.

the class RevisionPainter method setModel.

/**
 * Sets the annotation model.
 *
 * @param model the annotation model, possibly <code>null</code>
 * @see IVerticalRulerColumn#setModel(IAnnotationModel)
 */
public void setModel(IAnnotationModel model) {
    IAnnotationModel diffModel;
    if (model instanceof IAnnotationModelExtension)
        diffModel = ((IAnnotationModelExtension) model).getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
    else
        diffModel = model;
    setDiffer(diffModel);
    setAnnotationModel(model);
}
Also used : IAnnotationModelExtension(org.eclipse.jface.text.source.IAnnotationModelExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel)

Example 9 with IAnnotationModelExtension

use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.

the class LinkedModeUI method uninstallAnnotationModel.

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());
        }
    }
}
Also used : IAnnotationModelExtension(org.eclipse.jface.text.source.IAnnotationModelExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ITextViewer(org.eclipse.jface.text.ITextViewer)

Example 10 with IAnnotationModelExtension

use of org.eclipse.jface.text.source.IAnnotationModelExtension in project eclipse.platform.text by eclipse.

the class LinkedModeUI method ensureAnnotationModelInstalled.

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);
                }
            }
        }
    }
}
Also used : IAnnotationModelExtension(org.eclipse.jface.text.source.IAnnotationModelExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ITextViewer(org.eclipse.jface.text.ITextViewer)

Aggregations

IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)30 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)20 Annotation (org.eclipse.jface.text.source.Annotation)14 Position (org.eclipse.jface.text.Position)12 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)6 HashMap (java.util.HashMap)5 IDocument (org.eclipse.jface.text.IDocument)5 Entry (java.util.Map.Entry)4 BadLocationException (org.eclipse.jface.text.BadLocationException)4 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)4 IEditorInput (org.eclipse.ui.IEditorInput)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Matcher (java.util.regex.Matcher)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 IRegion (org.eclipse.jface.text.IRegion)2 ITextViewer (org.eclipse.jface.text.ITextViewer)2 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)2 IChangeRulerColumn (org.eclipse.jface.text.source.IChangeRulerColumn)2 ILineDifferExtension (org.eclipse.jface.text.source.ILineDifferExtension)2