@@ -110,6 +110,7 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
110
110
private ControlDecoration colorFontsDecorator ;
111
111
private ColorsAndFontsTheme currentColorsAndFontsTheme ;
112
112
private Map <String , String > themeAssociations ;
113
+ private boolean highContrastMode ;
113
114
114
115
private Button themingEnabled ;
115
116
private Button rescaleAtRuntime ;
@@ -125,11 +126,15 @@ protected Control createContents(Composite parent) {
125
126
126
127
Composite comp = new Composite (parent , SWT .NONE );
127
128
128
- themingEnabled = createCheckButton (comp , WorkbenchMessages .ThemingEnabled , engine != null );
129
+ highContrastMode = parent .getDisplay ().getHighContrast ();
130
+ // Deactivate theming in high contrast mode
131
+ themingEnabled = createCheckButton (comp , WorkbenchMessages .ThemingEnabled , isThemingPossible ());
132
+ themingEnabled .setEnabled (!highContrastMode );
129
133
130
- // if started with "-cssTheme none", CSS settings should be disabled
131
- // but other appearance settings should be *not* disabled
132
- if (engine == null ) {
134
+ // if started with "-cssTheme none" or if high contrast mode is active,
135
+ // CSS settings should be disabled but other appearance settings should be *not*
136
+ // disabled
137
+ if (!isThemingPossible ()) {
133
138
GridLayout layout = new GridLayout (1 , false );
134
139
layout .horizontalSpacing = 10 ;
135
140
comp .setLayout (layout );
@@ -192,6 +197,21 @@ protected Control createContents(Composite parent) {
192
197
return comp ;
193
198
}
194
199
200
+ /**
201
+ * @return <code>true</code> if there is a theme engine set (<i>i.e.</i> if the
202
+ * workbench started with the checkbox "enable theming" set to
203
+ * <code>true</code>) and the <i>high contrast mode</i> is
204
+ * <strong>disabled on the OS.
205
+ *
206
+ * @implNote Currently only Windows is able to tell if <i>high contrast mode</i>
207
+ * is active. Linux and Mac lack this functionality (they always say
208
+ * it is <b>disabled</b>).
209
+ *
210
+ */
211
+ private boolean isThemingPossible () {
212
+ return engine != null && !highContrastMode ;
213
+ }
214
+
195
215
private void createRescaleAtRuntimeCheckButton (Composite parent ) {
196
216
if (!OS .isWindows ()) {
197
217
return ;
@@ -313,7 +333,7 @@ public void init(IWorkbench workbench) {
313
333
public boolean performOk () {
314
334
IEclipsePreferences prefs = InstanceScope .INSTANCE
315
335
.getNode (PREF_QUALIFIER_ECLIPSE_E4_UI_WORKBENCH_RENDERERS_SWT );
316
- if (engine != null ) {
336
+ if (isThemingPossible () ) {
317
337
ITheme theme = getSelectedTheme ();
318
338
if (theme != null ) {
319
339
engine .setTheme (getSelectedTheme (), true );
@@ -326,9 +346,14 @@ public boolean performOk() {
326
346
apiStore .setValue (IWorkbenchPreferenceConstants .USE_COLORED_LABELS , useColoredLabels .getSelection ());
327
347
328
348
prefs .putBoolean (StackRenderer .MRU_KEY , enableMru .getSelection ());
329
- boolean themingEnabledChanged = prefs .getBoolean (PartRenderingEngine .ENABLED_THEME_KEY , true ) != themingEnabled
330
- .getSelection ();
331
- prefs .putBoolean (PartRenderingEngine .ENABLED_THEME_KEY , themingEnabled .getSelection ());
349
+ boolean themingEnabledChanged = false ;
350
+ // Only if the setting is modifiable by the user does checking for it (and
351
+ // storing it) make sense
352
+ if (themingEnabled .isEnabled ()) {
353
+ themingEnabledChanged = prefs .getBoolean (PartRenderingEngine .ENABLED_THEME_KEY , true ) != themingEnabled
354
+ .getSelection ();
355
+ prefs .putBoolean (PartRenderingEngine .ENABLED_THEME_KEY , themingEnabled .getSelection ());
356
+ }
332
357
333
358
boolean isRescaleAtRuntimeChanged = false ;
334
359
if (rescaleAtRuntime != null ) {
@@ -356,7 +381,7 @@ public boolean performOk() {
356
381
String restartDialogTitle = null ;
357
382
String restartDialogMessage = null ;
358
383
359
- if (engine != null ) {
384
+ if (isThemingPossible () ) {
360
385
ITheme theme = getSelectedTheme ();
361
386
boolean themeChanged = theme != null && !theme .equals (currentTheme );
362
387
boolean colorsAndFontsThemeChanged = !PlatformUI .getWorkbench ().getThemeManager ().getCurrentTheme ().getId ()
@@ -417,7 +442,7 @@ private void setColorsAndFontsTheme(ColorsAndFontsTheme theme) {
417
442
protected void performDefaults () {
418
443
IEclipsePreferences defaultPrefs = DefaultScope .INSTANCE
419
444
.getNode (PREF_QUALIFIER_ECLIPSE_E4_UI_WORKBENCH_RENDERERS_SWT );
420
- if (engine != null ) {
445
+ if (isThemingPossible () ) {
421
446
setColorsAndFontsTheme (currentColorsAndFontsTheme );
422
447
423
448
engine .setTheme (defaultTheme , true );
@@ -441,7 +466,7 @@ protected void performDefaults() {
441
466
442
467
@ Override
443
468
public boolean performCancel () {
444
- if (engine != null ) {
469
+ if (isThemingPossible () ) {
445
470
setColorsAndFontsTheme (currentColorsAndFontsTheme );
446
471
447
472
if (currentTheme != null && !currentTheme .equals (engine .getActiveTheme ())) {
0 commit comments