Search in sources :

Example 11 with AnnotationPreference

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

the class LineNumberColumn method initialize.

/**
 * Initializes the given line number ruler column from the preference store.
 */
private void initialize() {
    final IPreferenceStore store = getPreferenceStore();
    if (store == null)
        return;
    // initial set up
    updateForegroundColor(store, fDelegate);
    updateBackgroundColor(store, fDelegate);
    updateLineNumbersVisibility(fDelegate);
    updateQuickDiffVisibility(fDelegate);
    updateCharacterMode(store, fDelegate);
    updateRevisionRenderingMode(store, fDelegate);
    updateRevisionAuthorVisibility(store, fDelegate);
    updateRevisionIdVisibility(store, fDelegate);
    Map<Object, AnnotationPreference> annotationPrefs = getAnnotationPreferenceMap();
    // $NON-NLS-1$
    final AnnotationPreference changedPref = annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffChange");
    // $NON-NLS-1$
    final AnnotationPreference addedPref = annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffAddition");
    // $NON-NLS-1$
    final AnnotationPreference deletedPref = annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffDeletion");
    updateChangedColor(changedPref, store, fDelegate);
    updateAddedColor(addedPref, store, fDelegate);
    updateDeletedColor(deletedPref, store, fDelegate);
    fDelegate.redraw();
    // listen to changes
    fDispatcher = new PropertyEventDispatcher(store);
    fDispatcher.addPropertyChangeListener(FG_COLOR_KEY, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateForegroundColor(store, fDelegate);
            fDelegate.redraw();
        }
    });
    IPropertyChangeListener backgroundHandler = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateBackgroundColor(store, fDelegate);
            fDelegate.redraw();
        }
    };
    fDispatcher.addPropertyChangeListener(BG_COLOR_KEY, backgroundHandler);
    fDispatcher.addPropertyChangeListener(USE_DEFAULT_BG_KEY, backgroundHandler);
    fDispatcher.addPropertyChangeListener(LINE_NUMBER_KEY, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            // only handle quick diff on/off information, but not ruler visibility (handled by AbstractDecoratedTextEditor)
            updateLineNumbersVisibility(fDelegate);
        }
    });
    fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateCharacterMode(store, fDelegate);
        }
    });
    fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateRevisionRenderingMode(store, fDelegate);
        }
    });
    fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_AUTHOR, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateRevisionAuthorVisibility(store, fDelegate);
        }
    });
    fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_REVISION, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateRevisionIdVisibility(store, fDelegate);
        }
    });
    fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            updateQuickDiffVisibility(fDelegate);
        }
    });
    if (changedPref != null) {
        fDispatcher.addPropertyChangeListener(changedPref.getColorPreferenceKey(), new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                updateChangedColor(changedPref, store, fDelegate);
                fDelegate.redraw();
            }
        });
    }
    if (addedPref != null) {
        fDispatcher.addPropertyChangeListener(addedPref.getColorPreferenceKey(), new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                updateAddedColor(addedPref, store, fDelegate);
                fDelegate.redraw();
            }
        });
    }
    if (deletedPref != null) {
        fDispatcher.addPropertyChangeListener(deletedPref.getColorPreferenceKey(), new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                updateDeletedColor(deletedPref, store, fDelegate);
                fDelegate.redraw();
            }
        });
    }
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 12 with AnnotationPreference

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

the class ElementFKInfoFormatHelper method createOverviewRuler.

public static IOverviewRuler createOverviewRuler() {
    IOverviewRuler ruler = new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, getSharedColors());
    Iterator<?> e = getAnnotationPreferences().getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        AnnotationPreference preference = (AnnotationPreference) e.next();
        if (preference.contributesToHeader()) {
            ruler.addHeaderAnnotationType(preference.getAnnotationType());
        }
    }
    return ruler;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 13 with AnnotationPreference

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

the class XMLSourceViewerHelper method createOverviewRuler.

public IOverviewRuler createOverviewRuler() {
    IOverviewRuler ruler = new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, getSharedColors());
    Iterator e = getAnnotationPreferences().getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        AnnotationPreference preference = (AnnotationPreference) e.next();
        if (preference.contributesToHeader()) {
            ruler.addHeaderAnnotationType(preference.getAnnotationType());
        }
    }
    return ruler;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) Iterator(java.util.Iterator) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 14 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference 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 15 with AnnotationPreference

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

Aggregations

AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)32 ArrayList (java.util.ArrayList)6 SourceViewerDecorationSupport (org.eclipse.ui.texteditor.SourceViewerDecorationSupport)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IOverviewRuler (org.eclipse.jface.text.source.IOverviewRuler)4 OverviewRuler (org.eclipse.jface.text.source.OverviewRuler)4 DefaultMarkerAnnotationAccess (org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess)4 MarkerAnnotationPreferences (org.eclipse.ui.texteditor.MarkerAnnotationPreferences)4 Iterator (java.util.Iterator)3 Annotation (org.eclipse.jface.text.source.Annotation)2 AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)2 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)2 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)2 ISharedTextColors (org.eclipse.jface.text.source.ISharedTextColors)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)2 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)2 Image (org.eclipse.swt.graphics.Image)2 OverlayKey (org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey)2 MarkerAnnotation (org.eclipse.ui.texteditor.MarkerAnnotation)2