use of org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewerConfiguration in project mylyn.docs by eclipse.
the class MarkupTaskEditorExtension method createEditor.
@SuppressWarnings("unchecked")
@Override
public SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style, IAdaptable context) {
final MarkupLanguageType markupLanguageCopy = createRepositoryMarkupLanguage(taskRepository);
configureMarkupLanguage(taskRepository, markupLanguageCopy);
SourceViewer viewer = new MarkupSourceViewer(parent, null, style | SWT.WRAP, markupLanguageCopy);
// configure the viewer
MarkupSourceViewerConfiguration configuration = createSourceViewerConfiguration(taskRepository, viewer, context);
configuration.setEnableSelfContainedIncrementalFind(true);
configuration.setMarkupLanguage(markupLanguageCopy);
configuration.setShowInTarget(new ShowInTargetBridge(viewer));
viewer.configure(configuration);
// we want the viewer to show annotations
viewer.showAnnotations(true);
DefaultMarkerAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
MarkerAnnotationPreferences annotationPreferences = new MarkerAnnotationPreferences();
// configure viewer annotation/decoration support
final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(viewer, null, annotationAccess, EditorsUI.getSharedTextColors());
// hook the support up to the preference store
Iterator<AnnotationPreference> e = annotationPreferences.getAnnotationPreferences().iterator();
while (e.hasNext()) {
AnnotationPreference preference = e.next();
support.setAnnotationPreference(preference);
}
support.setCursorLinePainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
support.setMarginPainterPreferenceKeys(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
support.install(new EditorExtensionPreferenceStore(EditorsUI.getPreferenceStore(), viewer.getControl()));
viewer.getControl().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
support.dispose();
}
});
IFocusService focusService = PlatformUI.getWorkbench().getService(IFocusService.class);
if (focusService != null) {
focusService.addFocusTracker(viewer.getTextWidget(), MarkupEditor.EDITOR_SOURCE_VIEWER);
}
viewer.getTextWidget().setData(MarkupLanguage.class.getName(), markupLanguageCopy);
viewer.getTextWidget().setData(ISourceViewer.class.getName(), viewer);
return viewer;
}
Aggregations