1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 03:45:35 +02:00

bug 270326: console window displays black

This commit is contained in:
Andrew Gvozdev 2010-09-19 03:36:46 +00:00
parent 60d1761727
commit 4a17586a41
3 changed files with 30 additions and 13 deletions

View file

@ -17,7 +17,6 @@ import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage; 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.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.IWorkspaceRunnable;
@ -118,8 +117,6 @@ public class TargetBuild {
return ResourcesPlugin.FAMILY_MANUAL_BUILD == family; 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(); targetJob.schedule();
if (!MakePreferencePage.isBuildTargetInBackground()) { if (!MakePreferencePage.isBuildTargetInBackground()) {

View file

@ -28,6 +28,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner; import org.eclipse.jface.text.IDocumentPartitioner;
@ -251,12 +252,12 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
errorStream.setConsole(fConsole); errorStream.setConsole(fConsole);
errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR); errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
errorStream.setColor(errorColor); errorStream.setColor(errorColor);
backgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR); backgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
fConsole.setBackground(backgroundColor); fConsole.setBackground(backgroundColor);
problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR); problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
problemErrorBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); problemErrorBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
problemWarningBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); problemWarningBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
problemInfoBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); problemInfoBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
} }
}); });
CUIPlugin.getWorkspace().addResourceChangeListener(this); CUIPlugin.getWorkspace().addResourceChangeListener(this);
@ -287,7 +288,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
errorColor.dispose(); errorColor.dispose();
errorColor = newColor; errorColor = newColor;
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR)) { } 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); fConsole.setBackground(newColor);
backgroundColor.dispose(); backgroundColor.dispose();
backgroundColor = newColor; backgroundColor = newColor;
@ -297,17 +298,17 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
problemHighlightedColor = newColor; problemHighlightedColor = newColor;
redrawTextViewer(); redrawTextViewer();
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) { } 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.dispose();
problemErrorBackgroundColor = newColor; problemErrorBackgroundColor = newColor;
redrawTextViewer(); redrawTextViewer();
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) { } 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.dispose();
problemWarningBackgroundColor = newColor; problemWarningBackgroundColor = newColor;
redrawTextViewer(); redrawTextViewer();
} else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) { } 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.dispose();
problemInfoBackgroundColor = newColor; problemInfoBackgroundColor = newColor;
redrawTextViewer(); redrawTextViewer();
@ -342,14 +343,29 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
/** /**
* Returns a color instance based on data from a preference field. * 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); RGB rgb = PreferenceConverter.getColor(CUIPlugin.getDefault().getPreferenceStore(), preference);
return new Color(display, rgb); 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 <code>null</code> if none. * Returns the console for the project, or <code>null</code> if none.
*/ */
public IConsole getConsole(IProject project) { public IConsole getConsole(IProject project) {
Assert.isNotNull(project); Assert.isNotNull(project);
fLastProject = project; fLastProject = project;

View file

@ -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.ASTProvider;
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider; import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager; 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.refactoring.CTextFileChangeFactory;
import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
@ -509,6 +510,9 @@ public class CUIPlugin extends AbstractUIPlugin {
DocCommentOwnerManager.getInstance().addListener(new EditorReopener()); DocCommentOwnerManager.getInstance().addListener(new EditorReopener());
ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory()); 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. // start make-ui plugin, such that it can check for project conversions.
Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) { Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) {
@Override @Override