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();
}
});
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations