diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java index 230eba927e8..27d85d1ea12 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java @@ -444,6 +444,12 @@ private static class Decoration { */ private ReusableRegion fReusableRegion= new ReusableRegion(); + /** + * Color used to draw inline annotations. + * @since 3.26 + */ + private Color fInlineAnnotationColor; + /** * Creates a new annotation painter for the given source viewer and with the * given annotation access. The painter is not initialized, i.e. no @@ -1647,4 +1653,18 @@ public void paint(int reason) { @Override public void setPositionManager(IPaintPositionManager manager) { } + + /** + * @since 3.26 + */ + public void setInlineAnnotationColor(Color color) { + fInlineAnnotationColor= color; + } + + /** + * @since 3.26 + */ + public Color getInlineAnnotationColor() { + return fInlineAnnotationColor; + } } diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java index 79e301468f6..2674b836fe8 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java @@ -366,7 +366,11 @@ public void install(ISourceViewer viewer, AnnotationPainter painter) { visibleLines= new VisibleLines(); text.addMouseListener(fMouseTracker); text.addMouseMoveListener(fMouseTracker); - setColor(text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); + Color c= painter.getInlineAnnotationColor(); + if (c == null) { + c= text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); + } + setColor(c); GC gc= new GC(viewer.getTextWidget()); gc.setFont(viewer.getTextWidget().getFont()); fFontMetrics= gc.getFontMetrics(); diff --git a/bundles/org.eclipse.ui.editors/build.properties b/bundles/org.eclipse.ui.editors/build.properties index 0ef8172705b..c9f92ace430 100644 --- a/bundles/org.eclipse.ui.editors/build.properties +++ b/bundles/org.eclipse.ui.editors/build.properties @@ -16,7 +16,8 @@ bin.includes = .,\ plugin.properties,\ about.html,\ icons/,\ - META-INF/ + META-INF/,\ + css/ src.includes = about.html,\ schema/ diff --git a/bundles/org.eclipse.ui.editors/css/e4-dark_preferencestyle.css b/bundles/org.eclipse.ui.editors/css/e4-dark_preferencestyle.css new file mode 100644 index 00000000000..cd132d91109 --- /dev/null +++ b/bundles/org.eclipse.ui.editors/css/e4-dark_preferencestyle.css @@ -0,0 +1,5 @@ + +IEclipsePreferences#org-eclipse-ui-workbench:org-eclipse-ui-editors { + preferences: + 'org.eclipse.ui.editors.inlineAnnotationColor=155,155,155' +} diff --git a/bundles/org.eclipse.ui.editors/plugin.properties b/bundles/org.eclipse.ui.editors/plugin.properties index 5a246191f2b..777af9dbb87 100644 --- a/bundles/org.eclipse.ui.editors/plugin.properties +++ b/bundles/org.eclipse.ui.editors/plugin.properties @@ -151,3 +151,7 @@ HyperlinkDetectorsPreferencePage= Hyperlinking #--- Unused label --- dummy= + +#--- color definition for code mining annotations +TEXT_EDITOR_CODE_MINING_COLOR= Text editor code mining color +TEXT_EDITOR_CODE_MINING_COLOR_DESCRIPTION= The default color used for text editor code mining annotations. diff --git a/bundles/org.eclipse.ui.editors/plugin.xml b/bundles/org.eclipse.ui.editors/plugin.xml index e69aca3a288..ce60714504a 100644 --- a/bundles/org.eclipse.ui.editors/plugin.xml +++ b/bundles/org.eclipse.ui.editors/plugin.xml @@ -1119,6 +1119,16 @@ label="test" value="232,232,232"> + + + %TEXT_EDITOR_CODE_MINING_COLOR_DESCRIPTION + + @@ -1161,4 +1171,13 @@ id="org.eclipse.ui.internal.editors.annotationCodeMiningProvider"> + + + + + + diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java index 60999aab116..e0b8c449331 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java @@ -196,6 +196,10 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor { * Preference key for highlight color of current line. */ private final static String CURRENT_LINE_COLOR= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR; + /** + * Preference key for inline annotation color + */ + private final static String INLINE_ANNOTATION_COLOR= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_INLINE_ANNOTATION_COLOR; /** * Preference key for showing print margin ruler. */ @@ -456,6 +460,7 @@ protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupp support.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR); support.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN); + support.setInlineAnnotationColorPreferenceKey(INLINE_ANNOTATION_COLOR); } /* diff --git a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java index ebae43ed79c..aa9904f0b20 100644 --- a/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java +++ b/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java @@ -71,11 +71,18 @@ private AbstractDecoratedTextEditorPreferenceConstants() { */ public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$ + /** + * A named preference that holds the color used to render the text editor inline annotation + * + * @since 3.18 + */ + public final static String EDITOR_INLINE_ANNOTATION_COLOR= "org.eclipse.ui.editors.inlineAnnotationColor"; //$NON-NLS-1$ + /** * A named preference that holds the number of spaces used per tab in the text editor. *

- * Value is of type int: positive int value specifying the number of - * spaces per tab. + * Value is of type int: positive int value specifying the number of spaces per + * tab. *

*/ public final static String EDITOR_TAB_WIDTH= "tabWidth"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java index 53888f2c335..d55b8998127 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java @@ -26,6 +26,8 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.resource.ColorRegistry; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -45,6 +47,7 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewerExtension5; import org.eclipse.jface.text.source.MatchingCharacterPainter; +import org.eclipse.jface.text.source.inlined.AbstractInlinedAnnotation; @@ -210,6 +213,8 @@ public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset private MatchingCharacterPainter fMatchingCharacterPainter; /** The character painter's pair matcher */ private ICharacterPairMatcher fCharacterPairMatcher; + /** The inline annotation color key */ + private String fInlineAnnotationColorKey; /** Map with annotation type preference per annotation type */ private Map fAnnotationTypeKeyMap= new LinkedHashMap<>(); @@ -357,6 +362,10 @@ public void uninstall() { if (fPreferenceStore != null) { fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener); + ColorRegistry registry = JFaceResources.getColorRegistry(); + if (registry != null) { + registry.removeListener(fPropertyChangeListener); + } fPropertyChangeListener= null; fPreferenceStore= null; } @@ -438,6 +447,15 @@ public void setMarginPainterPreferenceKeys(String enableKey, String colorKey, St fMarginPainterColumnKey= columnKey; } + /** + * Set inline annotation color key. + * + * @since 3.18 + */ + public void setInlineAnnotationColorPreferenceKey(String inlineAnnotationColor) { + fInlineAnnotationColorKey = inlineAnnotationColor; + } + /** * Sets the preference keys for the matching character painter. * @@ -610,7 +628,15 @@ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { return; } } - + if (fInlineAnnotationColorKey!=null && fInlineAnnotationColorKey.equals(p) && fAnnotationPainter!=null) { + ColorRegistry registry = JFaceResources.getColorRegistry(); + if (registry != null) { + Color color = registry.get(fInlineAnnotationColorKey); + fAnnotationPainter.setInlineAnnotationColor(color); + fAnnotationPainter.setAnnotationTypeColor(AbstractInlinedAnnotation.TYPE, color); + fAnnotationPainter.paint(IPainter.CONFIGURATION); + } + } } /** @@ -863,6 +889,14 @@ protected AnnotationPainter createAnnotationPainter() { painter.addTextStyleStrategy(AnnotationPreference.STYLE_DASHED_BOX, fgDashedBoxStrategy); painter.addTextStyleStrategy(AnnotationPreference.STYLE_UNDERLINE, fgUnderlineStrategy); + ColorRegistry registry = JFaceResources.getColorRegistry(); + if (registry != null) { + Color color = registry.get(fInlineAnnotationColorKey); + painter.setInlineAnnotationColor(color); + if (fPropertyChangeListener != null) { + registry.addListener(fPropertyChangeListener); + } + } return painter; }