Search in sources :

Example 1 with DefaultHyperlinkDetectorDescriptorFilter

use of org.eclipse.mylyn.wikitext.ui.viewer.DefaultHyperlinkDetectorDescriptorFilter 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)

Aggregations

ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)1 DefaultHyperlinkDetectorDescriptorFilter (org.eclipse.mylyn.wikitext.ui.viewer.DefaultHyperlinkDetectorDescriptorFilter)1 MarkupViewer (org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewer)1 MarkupViewerConfiguration (org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewerConfiguration)1 IFocusService (org.eclipse.ui.swt.IFocusService)1