Search in sources :

Example 1 with AbstractMarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.

the class ListBlock method findCloseOffset.

@Override
public int findCloseOffset(String line, int lineOffset) {
    if (listContinuation) {
        if (nestingBegin) {
            AbstractMarkupLanguage language = (AbstractMarkupLanguage) getParser().getMarkupLanguage();
            Block block = language.startBlock(line, lineOffset);
            nestedBlockInterruptible = isInterruptibleNestedBlock(block);
            nestingBegin = false;
        }
        if (nestedBlockInterruptible && (line.isEmpty() || isListContinuation(line))) {
            listContinuation = isListContinuation(line);
            return 0;
        }
    }
    return -1;
}
Also used : Block(org.eclipse.mylyn.wikitext.parser.markup.Block) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)

Example 2 with AbstractMarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage 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 3 with AbstractMarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.

the class MarkupTaskEditorExtension method createViewer.

@Override
public SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style, IAdaptable context) {
    if (markupLanguage == null) {
        throw new IllegalStateException();
    }
    MarkupViewer markupViewer = new MarkupViewer(parent, null, style | SWT.FLAT | SWT.WRAP);
    MarkupLanguageType markupLanguageCopy = createRepositoryMarkupLanguage(taskRepository);
    configureMarkupLanguage(taskRepository, markupLanguageCopy);
    markupViewer.setMarkupLanguage(markupLanguageCopy);
    MarkupViewerConfiguration configuration = createViewerConfiguration(taskRepository, markupViewer, context);
    configuration.setDisableHyperlinkModifiers(true);
    configuration.setEnableSelfContainedIncrementalFind(true);
    if (markupLanguageCopy instanceof AbstractMarkupLanguage && ((AbstractMarkupLanguage) markupLanguageCopy).isDetectingRawHyperlinks()) {
        // bug 264612 don't detect hyperlinks twice
        configuration.addHyperlinkDetectorDescriptorFilter(new DefaultHyperlinkDetectorDescriptorFilter(// $NON-NLS-1$
        "org.eclipse.mylyn.tasks.ui.hyperlinks.detectors.url"));
    }
    markupViewer.configure(configuration);
    markupViewer.setEditable(false);
    markupViewer.getTextWidget().setCaret(null);
    if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT)) {
        markupViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT));
    }
    if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT)) {
        markupViewer.setDefaultMonospaceFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT));
    }
    markupViewer.setStylesheet(WikiTextUiPlugin.getDefault().getPreferences().getStylesheet());
    IFocusService focusService = PlatformUI.getWorkbench().getService(IFocusService.class);
    if (focusService != null) {
        focusService.addFocusTracker(markupViewer.getTextWidget(), MARKUP_VIEWER);
    }
    markupViewer.getTextWidget().setData(ISourceViewer.class.getName(), markupViewer);
    return markupViewer;
}
Also used : MarkupViewerConfiguration(org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewerConfiguration) DefaultHyperlinkDetectorDescriptorFilter(org.eclipse.mylyn.wikitext.ui.viewer.DefaultHyperlinkDetectorDescriptorFilter) MarkupViewer(org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewer) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) IFocusService(org.eclipse.ui.swt.IFocusService) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Example 4 with AbstractMarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage 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 5 with AbstractMarkupLanguage

use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.

the class MarkupTask method createMarkupLanguage.

/**
 * Create a {@link MarkupLanguage markup language parser} for the {@link #getMarkupLanguage() specified markup
 * language}.
 *
 * @return the markup language
 * @throws BuildException
 *             if the markup language is not specified or if it is unknown.
 */
protected MarkupLanguage createMarkupLanguage() throws BuildException {
    if (markupLanguage == null) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupTask.0"));
    }
    try {
        MarkupLanguage language = ServiceLocator.getInstance(getClass().getClassLoader()).getMarkupLanguage(markupLanguage);
        if (internalLinkPattern != null) {
            // $NON-NLS-1$
            checkAbstractMarkupLanguage(language, "internalLinkPattern");
            ((AbstractMarkupLanguage) language).setInternalLinkPattern(internalLinkPattern);
        }
        if (markupLanguageConfiguration != null) {
            language.configure(markupLanguageConfiguration);
        }
        return language;
    } catch (IllegalArgumentException e) {
        throw new BuildException(e.getMessage(), e);
    }
}
Also used : BuildException(org.apache.tools.ant.BuildException) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)

Aggregations

AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)9 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)5 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)3 StringWriter (java.io.StringWriter)2 IDocument (org.eclipse.jface.text.IDocument)2 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 FastMarkupPartitioner (org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.FastMarkupPartitioner)2 PrintWriter (java.io.PrintWriter)1 StringReader (java.io.StringReader)1 BuildException (org.apache.tools.ant.BuildException)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)1 MarkupMonoReconciler (org.eclipse.mylyn.internal.wikitext.ui.editor.reconciler.MarkupMonoReconciler)1 MarkupDocumentProvider (org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.MarkupDocumentProvider)1 MarkdownLanguage (org.eclipse.mylyn.wikitext.markdown.MarkdownLanguage)1 MarkdownDocumentBuilder (org.eclipse.mylyn.wikitext.markdown.internal.MarkdownDocumentBuilder)1