use of org.eclipse.jface.text.source.inlined.InlinedAnnotationSupport in project eclipse.platform.text by eclipse.
the class InlinedAnnotationDemo method main.
public static void main(String[] args) throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("Inlined annotation demo");
// Create source viewer and initialize the content
ISourceViewer sourceViewer = new SourceViewer(shell, null, SWT.V_SCROLL | SWT.BORDER);
sourceViewer.setDocument(new Document("\ncolor:rgb(255, 255, 0)"), new AnnotationModel());
// Initialize inlined annotations support
InlinedAnnotationSupport support = new InlinedAnnotationSupport();
support.install(sourceViewer, createAnnotationPainter(sourceViewer));
// Refresh inlined annotation in none UI Thread with reconciler.
MonoReconciler reconciler = new MonoReconciler(new IReconcilingStrategy() {
@Override
public void setDocument(IDocument document) {
Set<AbstractInlinedAnnotation> annotations = getInlinedAnnotation(sourceViewer, support);
support.updateAnnotations(annotations);
}
@Override
public void reconcile(IRegion partition) {
Set<AbstractInlinedAnnotation> anns = getInlinedAnnotation(sourceViewer, support);
support.updateAnnotations(anns);
}
@Override
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
}
}, false);
reconciler.setDelay(1);
reconciler.install(sourceViewer);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.jface.text.source.inlined.InlinedAnnotationSupport in project eclipse.platform.text by eclipse.
the class SourceViewer method ensureCodeMiningManagerInstalled.
/**
* Ensures that the code mining manager has been
* installed if a content mining provider is available.
*
* @since 3.13
*/
private void ensureCodeMiningManagerInstalled() {
if (fCodeMiningProviders != null && fCodeMiningProviders.length > 0 && fAnnotationPainter != null) {
if (fInlinedAnnotationSupport == null) {
fInlinedAnnotationSupport = new InlinedAnnotationSupport();
fInlinedAnnotationSupport.install(this, fAnnotationPainter);
}
fCodeMiningManager = new CodeMiningManager(this, fInlinedAnnotationSupport, fCodeMiningProviders);
}
}
Aggregations