From adc46fe2211a296042f112adf97bb102b62e15f7 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 22 Dec 2011 16:39:38 +0100 Subject: [PATCH] Bug 367403 - [preferences] C/C++ editor does not respect high contrast settings --- core/org.eclipse.cdt.ui/plugin.xml | 420 +++++++++++++++++- .../cdt/internal/ui/ICThemeConstants.java | 92 +++- .../ui/editor/SemanticHighlighting.java | 38 +- .../ui/editor/SemanticHighlightings.java | 312 ++++++------- .../CEditorColoringConfigurationBlock.java | 33 +- .../src/org/eclipse/cdt/ui/CUIPlugin.java | 208 +++++---- .../cdt/ui/CUIPreferenceInitializer.java | 174 +++++++- .../eclipse/cdt/ui/PreferenceConstants.java | 122 ++--- .../text/doctools/doxygen/DoxygenHelper.java | 56 ++- .../DoxygenMultilineConfiguration.java | 9 +- .../doxygen/DoxygenSingleConfiguration.java | 15 +- 11 files changed, 1100 insertions(+), 379 deletions(-) diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 9a712d3953f..1a725d0292a 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -577,6 +577,258 @@ label="%Dummy.label" value="240, 216, 168"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2946,10 +3362,6 @@ point="org.eclipse.core.runtime.preferences"> - - - true iff the semantic highlighting consumes the semantic token */ public abstract boolean consumes(SemanticToken token); + + private String getThemeColorKey() { + return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$ + } + + /** + * Returns the RGB for the given key in the given color registry. + * + * @param key the key for the constant in the registry + * @param defaultRGB the default RGB if no entry is found + * @return RGB the RGB + * @since 5.4 + */ + private static RGB findRGB(String key, RGB defaultRGB) { + if (!PlatformUI.isWorkbenchRunning()) + return defaultRGB; + + ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); + RGB rgb= registry.getRGB(key); + if (rgb != null) + return rgb; + return defaultRGB; + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index 8d872ecfa40..73f17530039 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -64,7 +64,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; /** * Semantic highlightings. * Derived from JDT. - * + * * @since 4.0 */ public class SemanticHighlightings { @@ -135,12 +135,12 @@ public class SemanticHighlightings { * A named preference part that controls the highlighting of classes. */ public static final String CLASS="class"; //$NON-NLS-1$ - + /** * A named preference part that controls the highlighting of enums. */ public static final String ENUM="enum"; //$NON-NLS-1$ - + /** * A named preference part that controls the highlighting of macro references. */ @@ -180,16 +180,16 @@ public class SemanticHighlightings { * A named preference part that controls the highlighting of external SDK. */ public static final String EXTERNAL_SDK="externalSDK"; //$NON-NLS-1$ - + /** * A named preference part that controls the highlighting of operators that have been overloaded. */ public static final String OVERLOADED_OPERATOR="overloadedOperator"; //$NON-NLS-1$ - + /** Init debugging mode */ private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.cdt.ui/debug/SemanticHighlighting")); //$NON-NLS-1$//$NON-NLS-2$ - + /** * Semantic highlightings */ @@ -209,10 +209,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } @@ -245,7 +245,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_staticField; + return CEditorMessages.SemanticHighlighting_staticField; } /* @@ -282,10 +282,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } @@ -318,7 +318,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_field; + return CEditorMessages.SemanticHighlighting_field; } /* @@ -355,10 +355,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -391,7 +391,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_methodDeclaration; + return CEditorMessages.SemanticHighlighting_methodDeclaration; } /* @@ -454,10 +454,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -490,7 +490,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_staticMethodInvocation; + return CEditorMessages.SemanticHighlighting_staticMethodInvocation; } /* @@ -530,10 +530,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -566,7 +566,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_method; + return CEditorMessages.SemanticHighlighting_method; } /* @@ -606,10 +606,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -642,7 +642,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_functionDeclaration; + return CEditorMessages.SemanticHighlighting_functionDeclaration; } /* @@ -658,7 +658,7 @@ public class SemanticHighlightings { IASTName name= (IASTName)node; if (name.isDeclaration()) { IBinding binding= token.getBinding(); - if (binding instanceof IFunction + if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) { return true; } else if (binding instanceof IProblemBinding) { @@ -700,10 +700,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -736,7 +736,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_function; + return CEditorMessages.SemanticHighlighting_function; } /* @@ -760,7 +760,7 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for local variable declarations. */ @@ -775,10 +775,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(128, 0, 0); } @@ -811,7 +811,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_localVariableDeclaration; + return CEditorMessages.SemanticHighlighting_localVariableDeclaration; } /* @@ -835,7 +835,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } + } } } } @@ -858,10 +858,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -894,7 +894,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_localVariable; + return CEditorMessages.SemanticHighlighting_localVariable; } /* @@ -918,7 +918,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } + } } } } @@ -956,10 +956,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -992,7 +992,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_globalVariable; + return CEditorMessages.SemanticHighlighting_globalVariable; } /* @@ -1019,12 +1019,12 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } + } } } return false; } - + } /** @@ -1041,10 +1041,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -1077,7 +1077,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_parameterVariable; + return CEditorMessages.SemanticHighlighting_parameterVariable; } /* @@ -1107,10 +1107,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(100, 70, 50); } @@ -1143,7 +1143,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_templateParameter; + return CEditorMessages.SemanticHighlighting_templateParameter; } /* @@ -1161,7 +1161,7 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for classes. */ @@ -1176,10 +1176,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 80, 50); } @@ -1212,7 +1212,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_classes; + return CEditorMessages.SemanticHighlighting_classes; } /* @@ -1238,7 +1238,7 @@ public class SemanticHighlightings { * Semantic highlighting for enums. */ private static final class EnumHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1246,15 +1246,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return ENUM; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(100, 70, 50); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1262,7 +1262,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1270,7 +1270,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1278,15 +1278,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_enums; + return CEditorMessages.SemanticHighlighting_enums; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1302,12 +1302,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for macro references. */ private static final class MacroReferenceHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1315,15 +1315,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return MACRO_REFERENCE; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1331,7 +1331,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1339,7 +1339,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1347,15 +1347,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_macroSubstitution; + return CEditorMessages.SemanticHighlighting_macroSubstitution; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1371,12 +1371,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for macro definitions. */ private static final class MacroDefinitionHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1384,15 +1384,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return MACRO_DEFINITION; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1400,7 +1400,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1408,7 +1408,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1416,15 +1416,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_macroDefintion; + return CEditorMessages.SemanticHighlighting_macroDefintion; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1440,12 +1440,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for typedefs. */ private static final class TypedefHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1453,15 +1453,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return TYPEDEF; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 80, 50); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1469,7 +1469,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1477,7 +1477,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1485,15 +1485,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_typeDef; + return CEditorMessages.SemanticHighlighting_typeDef; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1513,12 +1513,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for namespaces. */ private static final class NamespaceHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1526,15 +1526,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return NAMESPACE; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1542,7 +1542,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1550,7 +1550,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1558,15 +1558,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_namespace; + return CEditorMessages.SemanticHighlighting_namespace; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1579,12 +1579,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for labels. */ private static final class LabelHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1592,15 +1592,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return LABEL; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1608,7 +1608,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1616,7 +1616,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1624,15 +1624,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_label; + return CEditorMessages.SemanticHighlighting_label; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1645,12 +1645,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for enumerators. */ private static final class EnumeratorHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1658,15 +1658,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return ENUMERATOR; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1674,7 +1674,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1682,7 +1682,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1690,15 +1690,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_enumerator; + return CEditorMessages.SemanticHighlighting_enumerator; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1718,12 +1718,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for problems. */ private static final class ProblemHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1731,15 +1731,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return PROBLEM; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(224, 0, 0); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1747,7 +1747,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() */ @@ -1763,7 +1763,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1771,15 +1771,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_problem; + return CEditorMessages.SemanticHighlighting_problem; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1796,12 +1796,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for external SDK references. */ private static final class ExternalSDKHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1809,15 +1809,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return EXTERNAL_SDK; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(100, 40, 128); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1825,7 +1825,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() */ @@ -1841,7 +1841,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1849,15 +1849,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_externalSDK; + return CEditorMessages.SemanticHighlighting_externalSDK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1910,7 +1910,7 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for functions. */ @@ -1924,7 +1924,7 @@ public class SemanticHighlightings { return OVERLOADED_OPERATOR; } - + @Override public boolean requiresImplicitNames() { return true; @@ -1932,10 +1932,10 @@ public class SemanticHighlightings { /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(200, 100, 0); // orange } @@ -1968,7 +1968,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_overloadedOperators; + return CEditorMessages.SemanticHighlighting_overloadedOperators; } /* @@ -1999,7 +1999,7 @@ public class SemanticHighlightings { return false; } } - + /** * A named preference that controls the given semantic highlighting's color. * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index baa9ca350c1..f394643dff9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -66,7 +66,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.IColorManager; -import org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenHelper; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting; @@ -206,6 +205,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) */ + @Override public Color getBackground(Object element) { return null; } @@ -213,6 +213,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) */ + @Override public Color getForeground(Object element) { if (element instanceof SemanticHighlightingColorListItem) { if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) { @@ -231,6 +232,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ + @Override public Object[] getElements(Object inputElement) { return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory}; } @@ -238,15 +240,18 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ + @Override public void dispose() { } /* * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } + @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof String) { String entry= (String) parentElement; @@ -264,6 +269,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { return new Object[0]; } + @Override public Object getParent(Object element) { if (element instanceof String) return null; @@ -279,6 +285,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { return fCommentsCategory; } + @Override public boolean hasChildren(Object element) { return element instanceof String; } @@ -313,9 +320,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { { PreferencesMessages.CEditorColoringConfigurationBlock_ppHeaders, PreferenceConstants.EDITOR_PP_HEADER_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_asmLabels, PreferenceConstants.EDITOR_ASM_LABEL_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_asmDirectives, PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR }, - { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized, DoxygenHelper.DOXYGEN_TAG_RECOGNIZED }, - { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment, DoxygenHelper.DOXYGEN_SINGLE_TOKEN }, - { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment, DoxygenHelper.DOXYGEN_MULTI_TOKEN }, + { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized, PreferenceConstants.DOXYGEN_TAG_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment, PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment, PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_keywords, PreferenceConstants.EDITOR_C_KEYWORD_COLOR }, // { PreferencesMessages.CEditorColoringConfigurationBlock_returnKeyword, PreferenceConstants.EDITOR_C_KEYWORD_RETURN_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_builtInTypes, PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR }, @@ -432,6 +439,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { * @param parent the parent composite * @return the control for the preference page */ + @Override public Control createControl(Composite parent) { initializeDialogUnits(parent); return createSyntaxPage(parent); @@ -698,15 +706,18 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { previewer.setLayoutData(gd); fListViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { handleSyntaxColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); @@ -714,9 +725,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fBoldCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection()); @@ -724,18 +737,22 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fItalicCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection()); } }); fStrikethroughCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection()); @@ -743,9 +760,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fUnderlineCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection()); @@ -753,9 +772,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fEnableCheckbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); if (item instanceof SemanticHighlightingColorListItem) { @@ -775,9 +796,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fEnableSemanticHighlightingCheckbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { fListViewer.refresh(true); HighlightingColorListItem item= getHighlightingColorListItem(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index f8e2cdc9137..3915d9cbc8f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -48,6 +48,8 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.source.ISharedTextColors; import org.eclipse.jface.text.templates.ContextTypeRegistry; import org.eclipse.jface.text.templates.persistence.TemplateStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; @@ -56,6 +58,7 @@ import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry; import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; @@ -64,6 +67,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.ConfigurationElementSorter; +import org.eclipse.ui.themes.IThemeManager; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -118,11 +122,11 @@ public class CUIPlugin extends AbstractUIPlugin { public static final String C_PROBLEMMARKER = PLUGIN_CORE_ID + ".problem"; //$NON-NLS-1$ public static final String ID_COMMENT_OWNER= PLUGIN_ID+".DocCommentOwner"; //$NON-NLS-1$ - + public static final String ID_INCLUDE_BROWSER= PLUGIN_ID + ".includeBrowser"; //$NON-NLS-1$ public static final String ID_CALL_HIERARCHY= PLUGIN_ID + ".callHierarchy"; //$NON-NLS-1$ public static final String ID_TYPE_HIERARCHY = PLUGIN_ID + ".typeHierarchy"; //$NON-NLS-1$ - + public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$ public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$ @@ -130,7 +134,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** @deprecated This wizard category has been merged with the {@link #CWIZARD_CATEGORY_ID c wizard category} */ @Deprecated public final static String CCWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCCWizards"; //$NON-NLS-1$ - + public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$ public static final String BUILDER_ID = PLUGIN_CORE_ID + ".cbuilder"; //$NON-NLS-1$ @@ -142,22 +146,22 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The id of the C perspective * (value "org.eclipse.cdt.ui.CPerspective"). - */ + */ public static final String ID_CPERSPECTIVE = PLUGIN_ID + ".CPerspective"; //$NON-NLS-1$ /** * The id of the C hierarchy perspective * (value "org.eclipse.cdt.ui.CHierarchyPerspective"). - * + * * @deprecated This perspective no longer exists. - */ + */ @Deprecated public static final String ID_CHIERARCHY_PERSPECTIVE = PLUGIN_ID + ".CHierarchyPerspective"; //$NON-NLS-1$ /** * The id of the C Browsing Perspective * (value "org.eclipse.cdt.ui.CBrowsingPerspective"). - * + * * @since 2.0 * @deprecated This perspective no longer exists. */ @@ -167,7 +171,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Projects view * (value "org.eclipse.cdt.ui.ProjectsView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -178,7 +182,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Namespaces view * (value "org.eclipse.cdt.ui.NamespacesView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -189,7 +193,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Types view * (value "org.eclipse.cdt.ui.TypesView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -200,7 +204,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Members view * (value "org.eclipse.cdt.ui.MembersView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -209,7 +213,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static String ID_MEMBERS_VIEW = PLUGIN_ID + ".MembersView"; //$NON-NLS-1$ /** - * The key to store customized templates. + * The key to store customized templates. * @since 3.0 */ private static final String CUSTOM_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.templates.custom"; //$NON-NLS-1$ @@ -217,20 +221,20 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The id of the C Element Creation action set * (value "org.eclipse.cdt.ui.CElementCreationActionSet"). - * + * * @since 2.0 */ public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$ - + /** * The id of the scope used by all the CDT views * (value "org.eclipse.cdt.ui.scope"). * @since 4.0 */ public static final String CVIEWS_SCOPE = "org.eclipse.cdt.ui.cViewScope"; //$NON-NLS-1$ - + /** - * The key to store customized code templates. + * The key to store customized code templates. * @since 5.0 */ private static final String CODE_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$ @@ -253,11 +257,11 @@ public class CUIPlugin extends AbstractUIPlugin { public synchronized IBufferFactory getBufferFactory() { return ((WorkingCopyManager) getWorkingCopyManager()).getBufferFactory(); } - + public static IWorkingCopy[] getSharedWorkingCopies() { return getDefault().getWorkingCopyManager().getSharedWorkingCopies(); } - + public static String getResourceString(String key) { try { return fgResourceBundle.getString(key); @@ -271,7 +275,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } - + public static String getFormattedString(String key, String arg) { return MessageFormat.format(getResourceString(key), new Object[] {arg}); } @@ -283,7 +287,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static ResourceBundle getResourceBundle() { return fgResourceBundle; } - + public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } @@ -319,7 +323,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static void log(IStatus status) { getDefault().getLog().log(status); } - + /** * @noreference This method is not intended to be referenced by clients. */ @@ -342,7 +346,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) { if (logError) log(s); - + // if the 'message' resource string and the IStatus' message are the same, // don't show both in the dialog if (s != null && message.equals(s.getMessage())) { @@ -358,7 +362,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static void errorDialog(Shell shell, String title, String message, Throwable t, boolean logError) { if (logError) log(message, t); - + IStatus status; if (t instanceof CoreException) { status = ((CoreException) t).getStatus(); @@ -368,7 +372,7 @@ public class CUIPlugin extends AbstractUIPlugin { message = null; } } else { - status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "Internal Error: ", t); //$NON-NLS-1$ + status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "Internal Error: ", t); //$NON-NLS-1$ } ErrorDialog.openError(shell, title, message, status); } @@ -405,14 +409,14 @@ public class CUIPlugin extends AbstractUIPlugin { private ResourceAdapterFactory fResourceAdapterFactory; private CElementAdapterFactory fCElementAdapterFactory; - /** - * The template context type registry for the C editor. + /** + * The template context type registry for the C editor. * @since 3.0 */ private ContributionContextTypeRegistry fContextTypeRegistry; /** - * The template store for the C editor. + * The template store for the C editor. * @since 3.0 */ private TemplateStore fTemplateStore; @@ -423,28 +427,34 @@ public class CUIPlugin extends AbstractUIPlugin { */ private ASTProvider fASTProvider; - /** - * The code template context type registry for the C editor. + /** + * The code template context type registry for the C editor. * @since 5.0 */ private ContextTypeRegistry fCodeTemplateContextTypeRegistry; - + /** - * The code template store for the C editor. + * The code template store for the C editor. * @since 5.0 */ private TemplateStore fCodeTemplateStore; + /** + * Theme listener. + * @since 5.4 + */ + private IPropertyChangeListener fThemeListener; + public CUIPlugin() { fgCPlugin = this; fDocumentProvider = null; - fTextTools = null; + fTextTools = null; fBuildConsoleManagers = new HashMap(); } - + /** * Returns the used document provider. - * + * * @noreference This method is not intended to be referenced by clients. */ public synchronized CDocumentProvider getDocumentProvider() { @@ -453,7 +463,7 @@ public class CUIPlugin extends AbstractUIPlugin { } return fDocumentProvider; } - + /** * Returns the working copy manager * @return IWorkingCopyManager @@ -487,11 +497,11 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Obtain a console manager with the given id. If a manager has not been created yet, * it is created and its console created and activated. - * + * * @param name - console name. * @param contextId - console id matching context id in the Console view dropdown. * @return console manager. - * + * * Note that this method is rather internal and should not be referenced by clients. * To create a build console, use {@link CCorePlugin#getBuildConsole(String, String, URL)} */ @@ -502,7 +512,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Obtain a console manager with the given id. If a manager has not been created yet, * it is created and its console created and activated with the given attributes. - * + * * @param name - console name. * @param contextId - console id matching context id in the Console view dropdown. * Can't be {@code null}. @@ -510,7 +520,7 @@ public class CUIPlugin extends AbstractUIPlugin { * view. The url is expected to point to an image in eclipse OSGi bundle. * {@code iconUrl} can be null, in that case the default image is used. * @return console manager. - * + * * @noreference This method is not intended to be referenced by clients. */ public IBuildConsoleManager getConsoleManager(String name, String contextId, URL iconUrl) { @@ -531,6 +541,7 @@ public class CUIPlugin extends AbstractUIPlugin { public void startGlobalConsole() { GlobalBuildConsoleManager.startGlobalConsole(); } + /* * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ @@ -540,22 +551,34 @@ public class CUIPlugin extends AbstractUIPlugin { //Set debug tracing options configurePluginDebugOptions(); - + registerAdapters(); IWorkingCopyProvider workingCopyProvider = new IWorkingCopyProvider() { + @Override public IWorkingCopy[] getWorkingCopies() { return CUIPlugin.getSharedWorkingCopies(); } }; CCorePlugin.getDefault().getDOM().setWorkingCopyProvider(workingCopyProvider); - - // init ast provider - getASTProvider(); + + if (PlatformUI.isWorkbenchRunning()) { + // Initialize AST provider + getASTProvider(); + + fThemeListener= new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty())) + CUIPreferenceInitializer.setThemeBasedPreferences(PreferenceConstants.getPreferenceStore(), true); + } + }; + PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener); + } CDTContextActivator.getInstance().install(); - + DocCommentOwnerManager.getInstance().addListener(new EditorReopener()); ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory()); - + // A workaround for black console bug 320723. BuildConsolePreferencePage.initDefaults(getPreferenceStore()); //initialize ContentAssistMatcherPreference @@ -612,7 +635,7 @@ public class CUIPlugin extends AbstractUIPlugin { } fBuildConsoleManagers.clear(); } - + GlobalBuildConsoleManager.stop(); unregisterAdapters(); @@ -621,14 +644,19 @@ public class CUIPlugin extends AbstractUIPlugin { fWorkingCopyManager.shutdown(); fWorkingCopyManager= null; } - + if (fDocumentProvider != null) { fDocumentProvider.shutdown(); fDocumentProvider= null; } - + ContentAssistPreference.shutdown(); + if (fThemeListener != null) { + PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener); + fThemeListener= null; + } + // Do this last. super.stop(context); } @@ -656,7 +684,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the problem marker manager. - * + * * @noreference This method is not intended to be referenced by clients. */ public ProblemMarkerManager getProblemMarkerManager() { @@ -673,14 +701,14 @@ public class CUIPlugin extends AbstractUIPlugin { manager.registerAdapters(fResourceAdapterFactory, IResource.class); manager.registerAdapters(fCElementAdapterFactory, ICElement.class); } - + private void unregisterAdapters() { IAdapterManager manager = Platform.getAdapterManager(); manager.unregisterAdapters(fResourceAdapterFactory); manager.unregisterAdapters(fCElementAdapterFactory); } - /** + /** * @deprecated Use {@link EditorsUI#getSharedTextColors()} instead. * @noreference This method is not intended to be referenced by clients. */ @@ -688,7 +716,7 @@ public class CUIPlugin extends AbstractUIPlugin { public ISharedTextColors getSharedTextColors() { return EditorsUI.getSharedTextColors(); } - + public void configurePluginDebugOptions() { if (isDebugging()) { String option = Platform.getDebugOption(CONTENTASSIST); @@ -699,17 +727,17 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns a combined preference store, this store is read-only. - * + * * @return the combined preference store - * + * * @since 3.0 */ public IPreferenceStore getCombinedPreferenceStore() { if (fCombinedPreferenceStore == null) { - fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { - getPreferenceStore(), - getCorePreferenceStore(), - EditorsUI.getPreferenceStore() + fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { + getPreferenceStore(), + getCorePreferenceStore(), + EditorsUI.getPreferenceStore() }); } return fCombinedPreferenceStore; @@ -744,11 +772,11 @@ public class CUIPlugin extends AbstractUIPlugin { } /** - * Returns an array of all editors that have an unsaved content. If the identical content is + * Returns an array of all editors that have an unsaved content. If the identical content is * presented in more than one editor, only one of those editor parts is part of the result. - * + * * @return an array of all dirty editor parts. - */ + */ public static IEditorPart[] getDirtyEditors() { Set inputs= new HashSet(); List result= new ArrayList(0); @@ -770,7 +798,7 @@ public class CUIPlugin extends AbstractUIPlugin { return result.toArray(new IEditorPart[result.size()]); } /** - * Returns an array of all instanciated editors. + * Returns an array of all instanciated editors. */ public static IEditorPart[] getInstanciatedEditors() { List result= new ArrayList(0); @@ -800,8 +828,8 @@ public class CUIPlugin extends AbstractUIPlugin { if (display == null) { display= Display.getDefault(); } - return display; - } + return display; + } /** * Creates the CUIplugin standard groups in a context menu. @@ -826,9 +854,9 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns all C editor text hovers contributed to the workbench. - * + * * @return an array of CEditorTextHoverDescriptor - * + * * @noreference This method is not intended to be referenced by clients. */ public CEditorTextHoverDescriptor[] getCEditorTextHoverDescriptors() { @@ -844,7 +872,7 @@ public class CUIPlugin extends AbstractUIPlugin { } }; sorter.sort(fCEditorTextHoverDescriptors); - + // The Problem hover has to be the first and the Annotation hover has to be the last one in the CDT UI's hover list int length= fCEditorTextHoverDescriptors.length; int first= -1; @@ -861,7 +889,7 @@ public class CUIPlugin extends AbstractUIPlugin { } if (first == -1) first= i; - + if (fCEditorTextHoverDescriptors[i].getId().equals("org.eclipse.cdt.ui.AnnotationHover")) { //$NON-NLS-1$ annotationHoverIndex= i; continue; @@ -871,9 +899,9 @@ public class CUIPlugin extends AbstractUIPlugin { continue; } } - + CEditorTextHoverDescriptor hoverDescriptor= null; - + if (first > -1 && problemHoverIndex > -1 && problemHoverIndex > first) { // move problem hover to beginning hoverDescriptor= fCEditorTextHoverDescriptors[problemHoverIndex]; @@ -884,7 +912,7 @@ public class CUIPlugin extends AbstractUIPlugin { if (annotationHoverIndex >= first && annotationHoverIndex < problemHoverIndex) annotationHoverIndex++; } - + if (annotationHoverIndex > -1 && annotationHoverIndex < last) { // move annotation hover to end hoverDescriptor= fCEditorTextHoverDescriptors[annotationHoverIndex]; @@ -903,11 +931,11 @@ public class CUIPlugin extends AbstractUIPlugin { } break; } - + } } return fCEditorTextHoverDescriptors; - } + } /** * Resets the C editor text hovers contributed to the workbench. @@ -915,7 +943,7 @@ public class CUIPlugin extends AbstractUIPlugin { * This will force a rebuild of the descriptors the next time * a client asks for them. *

- * + * */ public void resetCEditorTextHoverDescriptors() { fCEditorTextHoverDescriptors= null; @@ -924,9 +952,9 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the registry of the extensions to the org.eclipse.cdt.ui.foldingStructureProviders * extension point. - * + * * @return the registry of contributed ICFoldingStructureProvider - * + * * @noreference This method is not intended to be referenced by clients. * @since 3.0 */ @@ -938,7 +966,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the template context type registry for the C plugin. - * + * * @return the template context type registry for the C plugin * @since 3.0 */ @@ -954,7 +982,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the template store for the C editor templates. - * + * * @return the template store for the C editor templates * @since 3.0 */ @@ -973,7 +1001,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the template context type registry for the code generation * templates. - * + * * @return the template context type registry for the code generation * templates * @since 5.0 @@ -981,17 +1009,17 @@ public class CUIPlugin extends AbstractUIPlugin { public ContextTypeRegistry getCodeTemplateContextRegistry() { if (fCodeTemplateContextTypeRegistry == null) { fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry("org.eclipse.cdt.ui.codeTemplates"); //$NON-NLS-1$ - + CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry); FileTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry); } return fCodeTemplateContextTypeRegistry; } - + /** * Returns the template store for the code generation templates. - * + * * @return the template store for the code generation templates * @since 5.0 */ @@ -1005,30 +1033,30 @@ public class CUIPlugin extends AbstractUIPlugin { } catch (IOException e) { log(e); } - + fCodeTemplateStore.startListeningForPreferenceChanges(); } - + return fCodeTemplateStore; } - + /** * Returns the AST provider. - * + * * @return the AST provider - * + * * @noreference This method is not intended to be referenced by clients. * @since 4.0 */ public synchronized ASTProvider getASTProvider() { if (fASTProvider == null) fASTProvider= new ASTProvider(); - + return fASTProvider; } - + /** - * Answers the Shell associated with the active workbench, or + * Answers the Shell associated with the active workbench, or * one of the windows associated with the workbench. */ public Shell getShell() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java index 60d6458e5d8..4188e1b9407 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java @@ -1,15 +1,26 @@ /******************************************************************************* - * Copyright (c) 2003, 2009 IBM Corporation and others. + * Copyright (c) 2003, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * QNX Software Systems - Initial implementation *******************************************************************************/ package org.eclipse.cdt.ui; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.resource.ColorRegistry; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; +import org.eclipse.ui.texteditor.AbstractTextEditor; + +import org.eclipse.cdt.internal.ui.ICThemeConstants; import org.eclipse.cdt.internal.ui.cview.CView; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage; @@ -18,19 +29,13 @@ import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; import org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage; import org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage; -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; -import org.eclipse.ui.texteditor.AbstractTextEditor; - /** * This class implements the setting of the CUI initial preference store settings. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { - + /* (non-Javadoc) * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ @@ -46,7 +51,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { CodeAssistPreferencePage.initDefaults(store); SemanticHighlightings.initDefaults(store); WorkInProgressPreferencePage.initDefaults(store); - + // We need to do this remove any keys that might have been // in the CUIPlugin store prior to the move of the CEditor setting // All of those settings are now in the workbench "All TextEditor" preference Page. @@ -63,7 +68,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR); - store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); + store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER); @@ -72,10 +77,10 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN); - + store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET); - + store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR); @@ -88,4 +93,145 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END); } + + static void setThemeBasedPreferences(IPreferenceStore store, boolean fireEvent) { + ColorRegistry registry= null; + if (PlatformUI.isWorkbenchRunning()) + registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); + + setDefault( + store, + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_TASK_TAG_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_KEYWORD_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_STRING_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_STRING_COLOR, new RGB(42, 0, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_DEFAULT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_OPERATOR_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_BRACES_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_NUMBER_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_PP_DIRECTIVE_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_PP_HEADER_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_PP_HEADER_COLOR, new RGB(42, 0, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_PP_DEFAULT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_PP_DEFAULT_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_ASM_LABEL_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_ASM_LABEL_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_ASM_DIRECTIVE_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(255, 255, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR, + findRGB(registry, ICThemeConstants.DOXYGEN_MULTI_LINE_COLOR, new RGB(63, 95, 191)), fireEvent); + setDefault( + store, + PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR, + findRGB(registry, ICThemeConstants.DOXYGEN_SINGLE_LINE_COLOR, new RGB(63, 95, 191)), fireEvent); + setDefault( + store, + PreferenceConstants.DOXYGEN_TAG_COLOR, + findRGB(registry, ICThemeConstants.DOXYGEN_TAG_COLOR, new RGB(127, 159, 191)), fireEvent); + } + + /** + * Sets the default value and fires a property + * change event if necessary. + * + * @param store the preference store + * @param key the preference key + * @param newValue the new value + * @param fireEvent false if no event should be fired + * @since 5.4 + */ + private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) { + if (!fireEvent) { + PreferenceConverter.setDefault(store, key, newValue); + return; + } + + RGB oldValue= null; + if (store.isDefault(key)) + oldValue= PreferenceConverter.getDefaultColor(store, key); + + PreferenceConverter.setDefault(store, key, newValue); + + if (oldValue != null && !oldValue.equals(newValue)) + store.firePropertyChangeEvent(key, oldValue, newValue); + } + + /** + * Returns the RGB for the given key in the given color registry. + * + * @param registry the color registry + * @param key the key for the constant in the registry + * @param defaultRGB the default RGB if no entry is found + * @return RGB the RGB + * @since 5.4 + */ + private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { + if (registry == null) + return defaultRGB; + + RGB rgb= registry.getRGB(key); + if (rgb != null) + return rgb; + + return defaultRGB; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index 724fb2f7d36..a979aa5cb8e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -23,17 +23,12 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.text.ICColorConstants; -import org.eclipse.cdt.internal.ui.ICThemeConstants; import org.eclipse.cdt.internal.ui.preferences.formatter.FormatterProfileManager; import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine; @@ -554,6 +549,45 @@ public class PreferenceConstants { */ public final static String EDITOR_ASM_DIRECTIVE_ITALIC= ICColorConstants.ASM_DIRECTIVE + EDITOR_ITALIC_SUFFIX; + /** + * A named preference that holds the color used to render doxygen tags. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 5.4 + */ + public static final String DOXYGEN_TAG_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$ + + /** + * A named preference that holds the color used to render doxygen single line comments. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 5.4 + */ + public static final String DOXYGEN_SINGLE_LINE_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$ + + /** + * A named preference that holds the color used to render doxygen multi-line comments. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 5.4 + */ + public static final String DOXYGEN_MULTI_LINE_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$ + /** * The symbolic font name for the C/C++ editor text font * (value "org.eclipse.cdt.ui.editors.textfont"). @@ -1859,8 +1893,6 @@ public class PreferenceConstants { * @param store the preference store to be initialized */ public static void initializeDefaultValues(IPreferenceStore store) { - ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); - store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, false); store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); store.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true); @@ -1875,64 +1907,49 @@ public class PreferenceConstants { store.setDefault(EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT, true); - // Coloring - PreferenceConverter.setDefault(store, EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); + // Syntax highlighting store.setDefault(EDITOR_MULTI_LINE_COMMENT_BOLD, false); store.setDefault(EDITOR_MULTI_LINE_COMMENT_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); store.setDefault(EDITOR_SINGLE_LINE_COMMENT_BOLD, false); store.setDefault(EDITOR_SINGLE_LINE_COMMENT_ITALIC, false); - PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)); - store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true); - store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_ITALIC, false); + store.setDefault(EDITOR_TASK_TAG_BOLD, true); + store.setDefault(EDITOR_TASK_TAG_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_C_KEYWORD_BOLD, true); store.setDefault(EDITOR_C_KEYWORD_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_C_BUILTIN_TYPE_BOLD, true); store.setDefault(EDITOR_C_BUILTIN_TYPE_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_STRING_COLOR, new RGB(42, 0, 255)); store.setDefault(EDITOR_C_STRING_BOLD, false); store.setDefault(EDITOR_C_STRING_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_DEFAULT_BOLD, false); store.setDefault(EDITOR_C_DEFAULT_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_OPERATOR_BOLD, false); store.setDefault(EDITOR_C_OPERATOR_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_BRACES_BOLD, false); store.setDefault(EDITOR_C_BRACES_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_NUMBER_BOLD, false); store.setDefault(EDITOR_C_NUMBER_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_PP_DIRECTIVE_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_PP_DIRECTIVE_BOLD, true); store.setDefault(EDITOR_PP_DIRECTIVE_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_PP_HEADER_COLOR, new RGB(42, 0, 255)); store.setDefault(EDITOR_PP_HEADER_BOLD, false); store.setDefault(EDITOR_PP_HEADER_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_PP_DEFAULT_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_PP_DEFAULT_BOLD, false); store.setDefault(EDITOR_PP_DEFAULT_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_ASM_LABEL_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_ASM_LABEL_BOLD, true); store.setDefault(EDITOR_ASM_LABEL_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_ASM_DIRECTIVE_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_ASM_DIRECTIVE_BOLD, true); store.setDefault(EDITOR_ASM_DIRECTIVE_ITALIC, false); @@ -1972,23 +1989,6 @@ public class PreferenceConstants { store.setDefault(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT, 5000); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(255, 255, 255))); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0))); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255))); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0))); - // Refactoring. store.setDefault(PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS, false); store.setDefault(PreferenceConstants.REFACTOR_LIGHTWEIGHT, true); @@ -2081,6 +2081,9 @@ public class PreferenceConstants { store.setDefault(NAME_STYLE_CPP_TEST_PREFIX, ""); //$NON-NLS-1$ store.setDefault(NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp"); //$NON-NLS-1$ store.setDefault(NAME_STYLE_CPP_TEST_WORD_DELIMITER, ""); //$NON-NLS-1$ + + // Colors that are set by the current theme + CUIPreferenceInitializer.setThemeBasedPreferences(store, false); } /** @@ -2149,39 +2152,4 @@ public class PreferenceConstants { return getPreferenceNode(key, project).getBoolean(key, defaultValue); } - /** - * Sets the default value and fires a property - * change event if necessary. - * - * @param store the preference store - * @param key the preference key - * @param newValue the new value - * @since 5.0 - */ - private static void setDefaultAndFireEvent(IPreferenceStore store, String key, RGB newValue) { - RGB oldValue= null; - if (store.isDefault(key)) - oldValue= PreferenceConverter.getDefaultColor(store, key); - - PreferenceConverter.setDefault(store, key, newValue); - - if (oldValue != null && !oldValue.equals(newValue)) - store.firePropertyChangeEvent(key, oldValue, newValue); - } - - /** - * Returns the RGB for the given key in the given color registry. - * - * @param registry the color registry - * @param key the key for the constant in the registry - * @param defaultRGB the default RGB if no entry is found - * @return RGB the RGB - * @since 5.0 - */ - private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { - RGB rgb= registry.getRGB(key); - if (rgb != null) - return rgb; - return defaultRGB; - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java index 1ae0336cb9b..dd089fa34ed 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Symbian Software Systems and others. + * Copyright (c) 2008, 2011 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.ui.text.doctools.doxygen; import java.io.BufferedReader; @@ -20,42 +20,53 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.swt.graphics.RGB; - import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.doctools.generic.GenericDocTag; /** * Makes available information for Doxygen support. - * + * * @since 5.0 * @noextend This class is not intended to be subclassed by clients. */ public class DoxygenHelper extends AbstractPreferenceInitializer { private static final IPath TAGS_CSV= new Path("doxygenTags.csv"); //$NON-NLS-1$ private static GenericDocTag[] fTags; - - public static final String DOXYGEN_TAG_RECOGNIZED= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$ - public static final String DOXYGEN_SINGLE_TOKEN= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$ - public static final String DOXYGEN_MULTI_TOKEN= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$ - + + /** + * @deprecated Use {@link PreferenceConstants#DOXYGEN_TAG_COLOR} instead. + */ + @Deprecated + public static final String DOXYGEN_TAG_RECOGNIZED= PreferenceConstants.DOXYGEN_TAG_COLOR; + /** + * @deprecated Use {@link PreferenceConstants#DOXYGEN_SINGLE_LINE_COLOR} instead. + */ + @Deprecated + public static final String DOXYGEN_SINGLE_TOKEN= PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR; + /** + * @deprecated Use {@link PreferenceConstants#DOXYGEN_MULTI_LINE_COLOR} instead. + */ + @Deprecated + public static final String DOXYGEN_MULTI_TOKEN= PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR; + /** * @return The tags which are understood by default by the doxygen tool. */ public static GenericDocTag[] getDoxygenTags() { if(fTags==null) { + InputStream is = null; try { List temp= new ArrayList(); - InputStream is= FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false); + is= FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false); BufferedReader br= new BufferedReader(new InputStreamReader(is)); - StringBuffer content= new StringBuffer(); + StringBuilder content= new StringBuilder(2000); for(String line= br.readLine(); line!=null; line= br.readLine()) { - content.append(line+"\n"); //$NON-NLS-1$ + content.append(line).append('\n'); } - String[] values= (content.toString()+"dummy-for-split").split("(\\s)*,(\\s)*"); //$NON-NLS-1$ //$NON-NLS-2$ - + content.append("dummy-for-split"); //$NON-NLS-1$ + String[] values= content.toString().split("(\\s)*,(\\s)*"); //$NON-NLS-1$ + for(int i=0; i+1