Search in sources :

Example 1 with ILineDifferExtension2

use of org.eclipse.jface.text.source.ILineDifferExtension2 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)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)1 ILineDifferExtension (org.eclipse.jface.text.source.ILineDifferExtension)1 ILineDifferExtension2 (org.eclipse.jface.text.source.ILineDifferExtension2)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 QuickDiff (org.eclipse.ui.texteditor.quickdiff.QuickDiff)1