From 4a17586a41b6e0d45e916d1775f8afc57d60a3a7 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 19 Sep 2010 03:36:46 +0000 Subject: [PATCH] bug 270326: console window displays black --- .../org/eclipse/cdt/make/ui/TargetBuild.java | 3 -- .../ui/buildconsole/BuildConsoleManager.java | 36 +++++++++++++------ .../src/org/eclipse/cdt/ui/CUIPlugin.java | 4 +++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java index f4a43a3f371..e53aa256d64 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java @@ -17,7 +17,6 @@ import java.util.List; import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRunnable; @@ -118,8 +117,6 @@ public class TargetBuild { return ResourcesPlugin.FAMILY_MANUAL_BUILD == family; } }; - // workaround for bug 270326, initialize CUIPlugin preference store to avoid race condition - CUIPlugin.getDefault().getPreferenceStore().getString("dummy"); //$NON-NLS-1$ targetJob.schedule(); if (!MakePreferencePage.isBuildTargetInBackground()) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java index b8301511df6..98e1790f039 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java @@ -28,6 +28,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.Status; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentPartitioner; @@ -251,12 +252,12 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang errorStream.setConsole(fConsole); errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR); errorStream.setColor(errorColor); - backgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR); + backgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR); fConsole.setBackground(backgroundColor); problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR); - problemErrorBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); - problemWarningBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); - problemInfoBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); + problemErrorBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); + problemWarningBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); + problemInfoBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); } }); CUIPlugin.getWorkspace().addResourceChangeListener(this); @@ -287,7 +288,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang errorColor.dispose(); errorColor = newColor; } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR)) { - Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR); + Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR); fConsole.setBackground(newColor); backgroundColor.dispose(); backgroundColor = newColor; @@ -297,17 +298,17 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang problemHighlightedColor = newColor; redrawTextViewer(); } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) { - Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); + Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); problemErrorBackgroundColor.dispose(); problemErrorBackgroundColor = newColor; redrawTextViewer(); } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) { - Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); + Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); problemWarningBackgroundColor.dispose(); problemWarningBackgroundColor = newColor; redrawTextViewer(); } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) { - Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); + Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); problemInfoBackgroundColor.dispose(); problemInfoBackgroundColor = newColor; redrawTextViewer(); @@ -342,14 +343,29 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang /** * Returns a color instance based on data from a preference field. */ - Color createColor(Display display, String preference) { + private Color createColor(Display display, String preference) { RGB rgb = PreferenceConverter.getColor(CUIPlugin.getDefault().getPreferenceStore(), preference); return new Color(display, rgb); } + + /** + * Returns a background color instance based on data from a preference field. + * This is a workaround for black console bug 320723. + */ + private Color createBackgroundColor(Display display, String preference) { + IPreferenceStore preferenceStore = CUIPlugin.getDefault().getPreferenceStore(); + RGB rgb; + if (preferenceStore.contains(preference)) { + rgb = PreferenceConverter.getColor(preferenceStore, preference); + } else { + rgb = new RGB(255, 255, 255); // white background + } + return new Color(display, rgb); + } + /** * Returns the console for the project, or null if none. */ - public IConsole getConsole(IProject project) { Assert.isNotNull(project); fLastProject = project; 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 4c73dc26182..1f07b60ee98 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 @@ -90,6 +90,7 @@ import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager; import org.eclipse.cdt.internal.ui.editor.ASTProvider; import org.eclipse.cdt.internal.ui.editor.CDocumentProvider; import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager; +import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage; import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory; import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; @@ -509,6 +510,9 @@ public class CUIPlugin extends AbstractUIPlugin { DocCommentOwnerManager.getInstance().addListener(new EditorReopener()); ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory()); + // A workaround for black console bug 320723. + BuildConsolePreferencePage.initDefaults(getPreferenceStore()); + // start make-ui plugin, such that it can check for project conversions. Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) { @Override