diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java index 5d4a81c8d76..55bad139fc7 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java @@ -35,6 +35,8 @@ import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.preference.JFacePreferences; import org.eclipse.jface.resource.ColorRegistry; +import org.eclipse.jface.resource.JFaceColors; +import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.AbstractInformationControl; import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; @@ -52,13 +54,13 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.themes.ITheme; /** * Creates an information control to display an expression in a hover control. @@ -128,6 +130,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC */ private Object fVariable; + private IPresentationContext fContext; private TreeModelViewer fViewer; private SashForm fSashForm; private Composite fDetailPaneComposite; @@ -191,8 +194,8 @@ public class ExpressionInformationControlCreator implements IInformationControlC @Override public void paneChanged(String newPaneID) { if (DefaultDetailPane.ID.equals(newPaneID)) { - fDetailPane.getCurrentControl() - .setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + fDetailPane.getCurrentControl().setForeground(getSystemForegroundColor()); + fDetailPane.getCurrentControl().setBackground(getSystemBackgroundColor()); } } @@ -268,7 +271,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC private IDialogSettings getDialogSettings(boolean create) { IDialogSettings settings = DsfUIPlugin.getDefault().getDialogSettings(); IDialogSettings section = settings.getSection(this.getClass().getName()); - if (section == null & create) { + if (section == null && create) { section = settings.addNewSection(this.getClass().getName()); } return section; @@ -292,6 +295,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC @Override public void dispose() { persistSettings(getShell()); + fContext.dispose(); super.dispose(); } @@ -342,8 +346,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC // update presentation context AbstractDebugView view = getViewToEmulate(); - IPresentationContext context = new ExpressionHoverPresentationContext( - IDsfDebugUIConstants.ID_EXPRESSION_HOVER); + fContext = new ExpressionHoverPresentationContext(IDsfDebugUIConstants.ID_EXPRESSION_HOVER); if (view != null) { // copy over properties IPresentationContext copy = ((TreeModelViewer) view.getViewer()).getPresentationContext(); @@ -351,14 +354,14 @@ public class ExpressionInformationControlCreator implements IInformationControlC String[] properties = copy.getProperties(); for (int i = 0; i < properties.length; i++) { String key = properties[i]; - context.setProperty(key, copy.getProperty(key)); + fContext.setProperty(key, copy.getProperty(key)); } } catch (NoSuchMethodError e) { // ignore } } - fViewer = new TreeModelViewer(fSashForm, SWT.MULTI | SWT.VIRTUAL | SWT.FULL_SELECTION, context); + fViewer = new TreeModelViewer(fSashForm, SWT.MULTI | SWT.VIRTUAL | SWT.FULL_SELECTION, fContext); fViewer.setAutoExpandLevel(fExpansionLevel); if (view != null) { @@ -433,21 +436,8 @@ public class ExpressionInformationControlCreator implements IInformationControlC fViewer.addViewerUpdateListener(fViewerUpdateListener); - ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); - ColorRegistry colorRegistry = currentTheme.getColorRegistry(); - - Color fg = colorRegistry.get(JFacePreferences.INFORMATION_FOREGROUND_COLOR); - if (fg == null) { - fg = getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND); - } - - Color bg = colorRegistry.get(JFacePreferences.INFORMATION_BACKGROUND_COLOR); - if (bg == null) { - bg = getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); - } - - setForegroundColor(fg); - setBackgroundColor(bg); + setForegroundColor(getSystemForegroundColor()); + setBackgroundColor(getSystemBackgroundColor()); } /** @@ -553,7 +543,6 @@ public class ExpressionInformationControlCreator implements IInformationControlC public void viewerInputComplete(IViewerInputUpdate update) { fViewer.setInput(fVariable = update.getInputElement()); } - } protected final boolean fShowDetailPane; @@ -588,4 +577,26 @@ public class ExpressionInformationControlCreator implements IInformationControlC return new ExpressionInformationControl(parent, false); } + private static Color getSystemForegroundColor() { + ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); + Color foreground = colorRegistry.get(JFacePreferences.INFORMATION_FOREGROUND_COLOR); + + if (foreground == null) { + return JFaceColors.getInformationViewerForegroundColor(Display.getDefault()); + } + + return foreground; + } + + public static Color getSystemBackgroundColor() { + ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); + Color background = colorRegistry.get(JFacePreferences.INFORMATION_BACKGROUND_COLOR); + + if (background == null) { + return JFaceColors.getInformationViewerBackgroundColor(Display.getDefault()); + } + + return background; + } + }