use of org.eclipse.ui.texteditor.SourceViewerDecorationSupport 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.SourceViewerDecorationSupport 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;
}
use of org.eclipse.ui.texteditor.SourceViewerDecorationSupport 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;
}
use of org.eclipse.ui.texteditor.SourceViewerDecorationSupport in project xtext-xtend by eclipse.
the class DerivedSourceView method createSourceViewer.
@Override
protected SourceViewer createSourceViewer(Composite parent) {
IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
IOverviewRuler overviewRuler = new OverviewRuler(defaultMarkerAnnotationAccess, OVERVIEW_RULER_WIDTH, getSharedTextColors());
AnnotationRulerColumn annotationRulerColumn = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, defaultMarkerAnnotationAccess);
List<AnnotationPreference> annotationPreferences = markerAnnotationPreferences.getAnnotationPreferences();
for (AnnotationPreference annotationPreference : annotationPreferences) {
String key = annotationPreference.getVerticalRulerPreferenceKey();
boolean showAnnotation = true;
if (key != null && store.contains(key)) {
showAnnotation = store.getBoolean(key);
}
if (showAnnotation) {
annotationRulerColumn.addAnnotationType(annotationPreference.getAnnotationType());
}
}
annotationRulerColumn.addAnnotationType(Annotation.TYPE_UNKNOWN);
lineNumberRulerColumn = new LineNumberRulerColumn();
CompositeRuler compositeRuler = new CompositeRuler();
compositeRuler.addDecorator(0, annotationRulerColumn);
compositeRuler.addDecorator(1, lineNumberRulerColumn);
javaSourceViewer = new JavaSourceViewer(parent, compositeRuler, overviewRuler, true, SWT.V_SCROLL | SWT.H_SCROLL, store);
javaSourceViewerConfiguration = new SimpleJavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true) {
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(final Shell parent) {
return new DefaultInformationControl(parent, true);
}
};
}
@Override
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
return new DefaultAnnotationHover();
}
};
javaSourceViewer.configure(javaSourceViewerConfiguration);
javaSourceViewer.setEditable(false);
javaSourceViewer.showAnnotations(true);
sourceViewerDecorationSupport = new SourceViewerDecorationSupport(javaSourceViewer, overviewRuler, defaultMarkerAnnotationAccess, getSharedTextColors());
for (AnnotationPreference annotationPreference : annotationPreferences) {
sourceViewerDecorationSupport.setAnnotationPreference(annotationPreference);
}
sourceViewerDecorationSupport.install(preferenceStoreAccess.getPreferenceStore());
return javaSourceViewer;
}
use of org.eclipse.ui.texteditor.SourceViewerDecorationSupport in project tdi-studio-se by Talend.
the class ReconcilerViewer method getSourceViewerDecorationSupport.
protected SourceViewerDecorationSupport getSourceViewerDecorationSupport() {
if (fSourceViewerDecorationSupport == null) {
fSourceViewerDecorationSupport = new SourceViewerDecorationSupport(this, fOverviewRuler, annotationAccess, sharedColors);
configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
}
return fSourceViewerDecorationSupport;
}
Aggregations