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