Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2019-05-03 13:49:50 +0000
committerPatrick Tasse2019-05-10 23:24:50 +0000
commitf87325e48037e9397c047548c8f80c6cbb789b47 (patch)
treea48c0d1f246eb75726693817a999a133b4244b25
parent6f96965af7bdf596d62e9aa41b20ba98576696af (diff)
downloadeclipse.pde.ui-f87325e48037e9397c047548c8f80c6cbb789b47.tar.gz
eclipse.pde.ui-f87325e48037e9397c047548c8f80c6cbb789b47.tar.xz
eclipse.pde.ui-f87325e48037e9397c047548c8f80c6cbb789b47.zip
Bug 546205 - SWTException in ColorManager.initializeDefaults()I20190512-1800I20190511-1800
Call Display.getHighContrast() from the UI thread. Change-Id: I330c69d60c462d344acf832134ae24dbf0cbfe65 Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java31
1 files changed, 21 insertions, 10 deletions
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java
index 9a07f8b0d6..b75a389226 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/text/ColorManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -25,6 +25,7 @@ import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
public class ColorManager implements IColorManager, IPDEColorConstants {
@@ -45,13 +46,7 @@ public class ColorManager implements IColorManager, IPDEColorConstants {
}
public static void initializeDefaults(IPreferenceStore store) {
- boolean highContrast = false;
- try {
- highContrast = Display.getDefault().getHighContrast();
- } catch (SWTException e) { // keep highContrast = false
- }
-
- PreferenceConverter.setDefault(store, P_DEFAULT, highContrast ? DEFAULT_HIGH_CONTRAST : DEFAULT);
+ PreferenceConverter.setDefault(store, P_DEFAULT, DEFAULT);
PreferenceConverter.setDefault(store, P_PROC_INSTR, PROC_INSTR);
PreferenceConverter.setDefault(store, P_STRING, STRING);
PreferenceConverter.setDefault(store, P_EXTERNALIZED_STRING, EXTERNALIZED_STRING);
@@ -60,10 +55,26 @@ public class ColorManager implements IColorManager, IPDEColorConstants {
PreferenceConverter.setDefault(store, P_HEADER_KEY, HEADER_KEY);
PreferenceConverter.setDefault(store, P_HEADER_OSGI, HEADER_OSGI);
store.setDefault(P_HEADER_OSGI + IPDEColorConstants.P_BOLD_SUFFIX, true);
- PreferenceConverter.setDefault(store, P_HEADER_VALUE, highContrast ? HEADER_VALUE_HIGH_CONTRAST : HEADER_VALUE);
- PreferenceConverter.setDefault(store, P_HEADER_ATTRIBUTES, highContrast ? HEADER_ASSIGNMENT_HIGH_CONTRAST : HEADER_ATTRIBUTES);
+ PreferenceConverter.setDefault(store, P_HEADER_VALUE, HEADER_VALUE);
+ PreferenceConverter.setDefault(store, P_HEADER_ATTRIBUTES, HEADER_ATTRIBUTES);
store.setDefault(P_HEADER_ATTRIBUTES + IPDEColorConstants.P_ITALIC_SUFFIX, true);
PreferenceConverter.setDefault(store, P_HEADER_ASSIGNMENT, HEADER_ASSIGNMENT);
+ try {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ Runnable runnable = () -> {
+ if (!display.isDisposed() && display.getHighContrast()) {
+ PreferenceConverter.setDefault(store, P_DEFAULT, DEFAULT_HIGH_CONTRAST);
+ PreferenceConverter.setDefault(store, P_HEADER_VALUE, HEADER_VALUE_HIGH_CONTRAST);
+ PreferenceConverter.setDefault(store, P_HEADER_ATTRIBUTES, HEADER_ASSIGNMENT_HIGH_CONTRAST);
+ }
+ };
+ if (display == Display.getCurrent()) {
+ runnable.run();
+ } else {
+ display.asyncExec(runnable);
+ }
+ } catch (SWTException e) { // keep non-high-contrast-mode defaults
+ }
}
private void initialize() {

Back to the top