Search in sources :

Example 1 with FastMarkupPartitioner

use of org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner in project mylyn.docs by eclipse.

the class MarkupEditor method setMarkupLanguage.

public void setMarkupLanguage(MarkupLanguage markupLanguage, boolean persistSetting) {
    if (markupLanguage instanceof AbstractMarkupLanguage) {
        ((AbstractMarkupLanguage) markupLanguage).setEnableMacros(false);
    }
    ((MarkupDocumentProvider) getDocumentProvider()).setMarkupLanguage(markupLanguage);
    IDocument document = getDocumentProvider().getDocument(getEditorInput());
    IDocumentPartitioner partitioner = document.getDocumentPartitioner();
    if (partitioner instanceof FastMarkupPartitioner) {
        final FastMarkupPartitioner fastMarkupPartitioner = (FastMarkupPartitioner) partitioner;
        fastMarkupPartitioner.setMarkupLanguage(markupLanguage);
    }
    sourceViewerConfiguration.setMarkupLanguage(markupLanguage);
    if (getSourceViewer() != null) {
        getSourceViewer().invalidateTextPresentation();
    }
    outlineDirty = true;
    scheduleOutlineUpdate();
    updateSourceTabLabel();
    if (viewer != null) {
        viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
    }
    if (persistSetting && markupLanguage != null) {
        storeMarkupLanguagePreference(markupLanguage);
    }
    if (persistSetting) {
        ISourceViewer sourceViewer = getSourceViewer();
        if (sourceViewer instanceof MarkupProjectionViewer) {
            IReconciler reconciler = ((MarkupProjectionViewer) sourceViewer).getReconciler();
            if (reconciler instanceof MarkupMonoReconciler) {
                ((MarkupMonoReconciler) reconciler).forceReconciling();
            }
        }
    }
}
Also used : FastMarkupPartitioner(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner) IReconciler(org.eclipse.jface.text.reconciler.IReconciler) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) MarkupMonoReconciler(org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) MarkupDocumentProvider(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.MarkupDocumentProvider) IDocument(org.eclipse.jface.text.IDocument)

Example 2 with FastMarkupPartitioner

use of org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner in project mylyn.docs by eclipse.

the class WikiTextSourcePartitioning method configurePartitioning.

/**
 * Configure partitioning on a document using the specified markup language.
 *
 * @param document
 *            the document that should have its partitioning configured
 * @param markupLanguage
 *            the markup language to use, or null
 * @since 3.0
 */
public static void configurePartitioning(IDocument document, MarkupLanguage markupLanguage) {
    FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
    partitioner.setMarkupLanguage(markupLanguage == null ? null : markupLanguage.clone());
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : FastMarkupPartitioner(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner)

Example 3 with FastMarkupPartitioner

use of org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner in project mylyn.docs by eclipse.

the class WikiTextSourceEditor method setMarkupLanguage.

/**
 * set the markup language. If unspecified, it's assumed to be Textile.
 *
 * @since 3.0
 */
public void setMarkupLanguage(MarkupLanguage markupLanguage) {
    this.markupLanguage = markupLanguage;
    if (this.markupLanguage instanceof AbstractMarkupLanguage) {
        ((AbstractMarkupLanguage) this.markupLanguage).setEnableMacros(false);
    }
    sourceViewerConfiguration.setMarkupLanguage(markupLanguage);
    IDocumentProvider documentProvider = getDocumentProvider();
    if (documentProvider instanceof WikiTextDocumentProvider) {
        ((WikiTextDocumentProvider) documentProvider).setMarkupLanguage(markupLanguage);
    }
    if (getEditorInput() != null) {
        IDocument document = documentProvider.getDocument(getEditorInput());
        IDocumentPartitioner partitioner = document.getDocumentPartitioner();
        if (partitioner instanceof FastMarkupPartitioner) {
            final FastMarkupPartitioner fastMarkupPartitioner = (FastMarkupPartitioner) partitioner;
            fastMarkupPartitioner.setMarkupLanguage(markupLanguage);
        }
    }
    if (viewer != null) {
        viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
    }
    if (getSourceViewer() != null) {
        getSourceViewer().invalidateTextPresentation();
    }
}
Also used : FastMarkupPartitioner(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) IDocument(org.eclipse.jface.text.IDocument)

Example 4 with FastMarkupPartitioner

use of org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner in project mylyn.docs by eclipse.

the class MarkupEditor method getMarkupLanguage.

public MarkupLanguage getMarkupLanguage() {
    IDocument document = getDocumentProvider().getDocument(getEditorInput());
    IDocumentPartitioner partitioner = document.getDocumentPartitioner();
    MarkupLanguage markupLanguage = null;
    if (partitioner instanceof FastMarkupPartitioner) {
        markupLanguage = ((FastMarkupPartitioner) partitioner).getMarkupLanguage();
    }
    return markupLanguage;
}
Also used : FastMarkupPartitioner(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) IDocument(org.eclipse.jface.text.IDocument)

Example 5 with FastMarkupPartitioner

use of org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner in project mylyn.docs by eclipse.

the class MarkupSourceViewer method configurePartitioning.

private void configurePartitioning(IDocument document) {
    FastMarkupPartitioner partitioner = new FastMarkupPartitioner();
    partitioner.setMarkupLanguage(markupLanguage.clone());
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
}
Also used : FastMarkupPartitioner(org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner)

Aggregations

FastMarkupPartitioner (org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner)5 IDocument (org.eclipse.jface.text.IDocument)3 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)3 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)3 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)3 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 MarkupMonoReconciler (org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler)1 MarkupDocumentProvider (org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.MarkupDocumentProvider)1 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)1