Search in sources :

Example 1 with MarkerAnnotationPreferences

use of org.eclipse.ui.texteditor.MarkerAnnotationPreferences 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)

Example 2 with MarkerAnnotationPreferences

use of org.eclipse.ui.texteditor.MarkerAnnotationPreferences in project egit by eclipse.

the class SpellcheckableMessageArea method configureAnnotationPreferences.

private SourceViewerDecorationSupport configureAnnotationPreferences() {
    ISharedTextColors textColors = EditorsUI.getSharedTextColors();
    IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
    final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(sourceViewer, null, annotationAccess, textColors);
    List annotationPreferences = new MarkerAnnotationPreferences().getAnnotationPreferences();
    Iterator e = annotationPreferences.iterator();
    while (e.hasNext()) support.setAnnotationPreference((AnnotationPreference) e.next());
    support.install(EditorsUI.getPreferenceStore());
    return support;
}
Also used : ISharedTextColors(org.eclipse.jface.text.source.ISharedTextColors) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) Iterator(java.util.Iterator) IntList(org.eclipse.jgit.util.IntList) List(java.util.List) ArrayList(java.util.ArrayList) MarkerAnnotationPreferences(org.eclipse.ui.texteditor.MarkerAnnotationPreferences) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport)

Example 3 with MarkerAnnotationPreferences

use of org.eclipse.ui.texteditor.MarkerAnnotationPreferences in project eclipse-integration-commons by spring-projects.

the class EditorToolkit method createTextEditor.

public TextViewer createTextEditor(Composite composite, String text, boolean spellCheck, int style) {
    AnnotationModel annotationModel = new AnnotationModel();
    final SourceViewer textViewer = new SourceViewer(composite, null, null, true, style);
    textViewer.showAnnotations(false);
    textViewer.showAnnotationsOverview(false);
    IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
    final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(textViewer, null, annotationAccess, EditorsUI.getSharedTextColors());
    @SuppressWarnings("unchecked") Iterator e = new MarkerAnnotationPreferences().getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        support.setAnnotationPreference((AnnotationPreference) e.next());
    }
    support.install(EditorsUI.getPreferenceStore());
    textViewer.getTextWidget().setIndent(2);
    textViewer.getTextWidget().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            support.uninstall();
        }
    });
    IThemeManager themeManager = editorSite.getWorkbenchWindow().getWorkbench().getThemeManager();
    textViewer.getTextWidget().setFont(themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT));
    final ActionContributorProxy actionContributor = getContributor();
    if (actionContributor.getSelectionChangedListener() != null) {
        textViewer.addSelectionChangedListener(actionContributor.getSelectionChangedListener());
    }
    textViewer.getTextWidget().addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            actionContributor.updateSelectableActions(textViewer.getSelection());
        }

        public void focusLost(FocusEvent e) {
            StyledText st = (StyledText) e.widget;
            st.setSelectionRange(st.getCaretOffset(), 0);
            actionContributor.forceActionsEnabled();
        }
    });
    textViewer.addTextListener(new ITextListener() {

        public void textChanged(TextEvent event) {
            actionContributor.updateSelectableActions(textViewer.getSelection());
        }
    });
    Document document = new Document(text);
    StsTextViewerConfiguration viewerConfig = new StsTextViewerConfiguration(spellCheck, false);
    textViewer.configure(viewerConfig);
    textViewer.setDocument(document, annotationModel);
    EditorUtil.setTextViewer(textViewer.getControl(), textViewer);
    configureContextMenuManager(textViewer.getControl());
    return textViewer;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) TextEvent(org.eclipse.jface.text.TextEvent) ITextListener(org.eclipse.jface.text.ITextListener) SourceViewer(org.eclipse.jface.text.source.SourceViewer) StyledText(org.eclipse.swt.custom.StyledText) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) IThemeManager(org.eclipse.ui.themes.IThemeManager) MarkerAnnotationPreferences(org.eclipse.ui.texteditor.MarkerAnnotationPreferences) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Document(org.eclipse.jface.text.Document) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) FocusEvent(org.eclipse.swt.events.FocusEvent) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) Iterator(java.util.Iterator) FocusListener(org.eclipse.swt.events.FocusListener)

Example 4 with MarkerAnnotationPreferences

use of org.eclipse.ui.texteditor.MarkerAnnotationPreferences in project tmdm-studio-se by Talend.

the class XMLSourceViewer method getAnnotationPreferences.

private MarkerAnnotationPreferences getAnnotationPreferences() {
    if (fAnnotationPreferences == null) {
        fAnnotationPreferences = new MarkerAnnotationPreferences();
        // force init
        fAnnotationPreferences.getAnnotationPreferences();
    }
    return fAnnotationPreferences;
}
Also used : MarkerAnnotationPreferences(org.eclipse.ui.texteditor.MarkerAnnotationPreferences)

Example 5 with MarkerAnnotationPreferences

use of org.eclipse.ui.texteditor.MarkerAnnotationPreferences in project eclipse.platform.text by eclipse.

the class NextPreviousPulldownActionDelegate method getActionsFromDescriptors.

/**
 * Creates actions using marker
 * annotation preferences.
 *
 * @return the navigation enablement actions
 */
private IAction[] getActionsFromDescriptors() {
    MarkerAnnotationPreferences fMarkerAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    SortedSet<NavigationEnablementAction> containers = new TreeSet<>();
    Iterator<AnnotationPreference> iter = fMarkerAnnotationPreferences.getAnnotationPreferences().iterator();
    while (iter.hasNext()) {
        AnnotationPreference preference = iter.next();
        String key = preference.getShowInNextPrevDropdownToolbarActionKey();
        if (key != null && fStore.getBoolean(key)) {
            String preferenceKey = getPreferenceKey(preference);
            /*
				 * Fixes bug 41689
				 * This code can be simplified if we decide that
				 * we don't allow to use different settings for go to
				 * previous and go to next annotation.
				 */
            preferenceKey = preference.getIsGoToNextNavigationTargetKey();
            if (preferenceKey != null)
                containers.add(new NavigationEnablementAction(preference.getPreferenceLabel(), fStore, preferenceKey));
        }
    }
    return containers.toArray(new Action[containers.size()]);
}
Also used : TreeSet(java.util.TreeSet) MarkerAnnotationPreferences(org.eclipse.ui.texteditor.MarkerAnnotationPreferences) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Aggregations

MarkerAnnotationPreferences (org.eclipse.ui.texteditor.MarkerAnnotationPreferences)9 AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)4 DefaultMarkerAnnotationAccess (org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess)3 SourceViewerDecorationSupport (org.eclipse.ui.texteditor.SourceViewerDecorationSupport)3 Iterator (java.util.Iterator)2 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)2 SourceViewer (org.eclipse.jface.text.source.SourceViewer)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 Document (org.eclipse.jface.text.Document)1 ITextListener (org.eclipse.jface.text.ITextListener)1 TextEvent (org.eclipse.jface.text.TextEvent)1 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)1 ISharedTextColors (org.eclipse.jface.text.source.ISharedTextColors)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 IntList (org.eclipse.jgit.util.IntList)1 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)1