use of org.eclipse.jface.text.source.IAnnotationModel 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;
}
use of org.eclipse.jface.text.source.IAnnotationModel in project eclipse.platform.text by eclipse.
the class LineNumberColumn method installChangeRulerModel.
/**
* Installs the differ annotation model with the current quick diff display.
*
* @param column the column to install the model on
*/
private void installChangeRulerModel(IVerticalRulerColumn column) {
if (column instanceof IChangeRulerColumn) {
IAnnotationModel model = getAnnotationModelWithDiffer();
((IChangeRulerColumn) column).setModel(model);
if (model != null) {
ISourceViewer viewer = fViewer;
if (viewer != null && viewer.getAnnotationModel() == null && column.getControl() != null)
viewer.showAnnotations(true);
}
}
}
use of org.eclipse.jface.text.source.IAnnotationModel 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);
}
use of org.eclipse.jface.text.source.IAnnotationModel in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method findSelectedOverviewRulerAnnotationLabel.
private String findSelectedOverviewRulerAnnotationLabel() {
IAnnotationModel model = getSourceViewer().getAnnotationModel();
if (model == null) {
return null;
}
Point selection = getSourceViewer().getSelectedRange();
Annotation annotation = null;
Iterator<Annotation> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
annotation = iter.next();
Position p = model.getPosition(annotation);
if (p.getOffset() == selection.x && p.getLength() == selection.y)
break;
}
if (annotation != null) {
AnnotationPreference ap = getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
if (ap != null)
return ap.getPreferenceLabel();
}
return null;
}
use of org.eclipse.jface.text.source.IAnnotationModel 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);
}
Aggregations