Search in sources :

Example 1 with MarkupSourceViewer

use of org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer 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;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) MarkupSourceViewer(org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) MarkerAnnotationPreferences(org.eclipse.ui.texteditor.MarkerAnnotationPreferences) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IFocusService(org.eclipse.ui.swt.IFocusService) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) MarkupSourceViewer(org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) ShowInTargetBridge(org.eclipse.mylyn.wikitext.ui.editor.ShowInTargetBridge) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) MarkupSourceViewerConfiguration(org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewerConfiguration)

Aggregations

ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)1 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)1 MarkupSourceViewer (org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer)1 MarkupSourceViewerConfiguration (org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewerConfiguration)1 ShowInTargetBridge (org.eclipse.mylyn.wikitext.ui.editor.ShowInTargetBridge)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 IFocusService (org.eclipse.ui.swt.IFocusService)1 AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)1 DefaultMarkerAnnotationAccess (org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess)1 MarkerAnnotationPreferences (org.eclipse.ui.texteditor.MarkerAnnotationPreferences)1 SourceViewerDecorationSupport (org.eclipse.ui.texteditor.SourceViewerDecorationSupport)1