Search in sources :

Example 1 with InlinedAnnotationSupport

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();
}
Also used : ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) HashSet(java.util.HashSet) Set(java.util.Set) InlinedAnnotationSupport(org.eclipse.jface.text.source.inlined.InlinedAnnotationSupport) FillLayout(org.eclipse.swt.layout.FillLayout) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) IRegion(org.eclipse.jface.text.IRegion) Shell(org.eclipse.swt.widgets.Shell) IReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) DirtyRegion(org.eclipse.jface.text.reconciler.DirtyRegion) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IDocument(org.eclipse.jface.text.IDocument) Display(org.eclipse.swt.widgets.Display)

Example 2 with InlinedAnnotationSupport

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);
    }
}
Also used : InlinedAnnotationSupport(org.eclipse.jface.text.source.inlined.InlinedAnnotationSupport) CodeMiningManager(org.eclipse.jface.internal.text.codemining.CodeMiningManager)

Aggregations

InlinedAnnotationSupport (org.eclipse.jface.text.source.inlined.InlinedAnnotationSupport)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 CodeMiningManager (org.eclipse.jface.internal.text.codemining.CodeMiningManager)1 Document (org.eclipse.jface.text.Document)1 IDocument (org.eclipse.jface.text.IDocument)1 IRegion (org.eclipse.jface.text.IRegion)1 DirtyRegion (org.eclipse.jface.text.reconciler.DirtyRegion)1 IReconcilingStrategy (org.eclipse.jface.text.reconciler.IReconcilingStrategy)1 MonoReconciler (org.eclipse.jface.text.reconciler.MonoReconciler)1 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1