use of org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewerConfiguration 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;
}
Aggregations