fStatusField.setLayoutData(gd2); RGB javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT).getRGB(); fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(fBackgroundColor.getRGB(), javaDefaultColor, 0.56f)); fStatusField.setForeground(fStatusTextForegroundColor);
/** * Sets the viewer's background color to the given control's background color. * The background color is <em>only</em> set if it's visibly distinct from the * default Java source text color. * * @param control the control with the default background color * @since 3.7 */ public void adaptBackgroundColor(Control control) { // workaround for dark editor background color, see https://bugs.eclipse.org/330680 Color defaultColor= control.getBackground(); float[] defaultBgHSB= defaultColor.getRGB().getHSB(); Color javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT); RGB javaDefaultRGB= javaDefaultColor != null ? javaDefaultColor.getRGB() : new RGB(255, 255, 255); float[] javaDefaultHSB= javaDefaultRGB.getHSB(); if (Math.abs(defaultBgHSB[2] - javaDefaultHSB[2]) >= 0.5f) { getTextWidget().setBackground(defaultColor); if (fBackgroundColor != null) { fBackgroundColor.dispose(); fBackgroundColor= null; } } }
fStatusField.setLayoutData(gd2); RGB javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT).getRGB(); fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(fBackgroundColor.getRGB(), javaDefaultColor, 0.56f)); fStatusField.setForeground(fStatusTextForegroundColor);
/** * Sets the viewer's background color to the given control's background color. * The background color is <em>only</em> set if it's visibly distinct from the * default Java source text color. * * @param control the control with the default background color * @since 3.7 */ public void adaptBackgroundColor(Control control) { // workaround for dark editor background color, see https://bugs.eclipse.org/330680 Color defaultColor= control.getBackground(); float[] defaultBgHSB= defaultColor.getRGB().getHSB(); Color javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT); RGB javaDefaultRGB= javaDefaultColor != null ? javaDefaultColor.getRGB() : new RGB(255, 255, 255); float[] javaDefaultHSB= javaDefaultRGB.getHSB(); if (Math.abs(defaultBgHSB[2] - javaDefaultHSB[2]) >= 0.5f) { getTextWidget().setBackground(defaultColor); if (fBackgroundColor != null) { fBackgroundColor.dispose(); fBackgroundColor= null; } } }
/** * Returns <code>null</code> if {@link SWT#COLOR_INFO_BACKGROUND} is visibly distinct from the * default Java source text color. Otherwise, returns the editor background color. * * @param display the display * @return an RGB or <code>null</code> * @since 3.6.1 */ public static RGB getVisibleBackgroundColor(Display display) { float[] infoBgHSB= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB(); Color javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT); RGB javaDefaultRGB= javaDefaultColor != null ? javaDefaultColor.getRGB() : new RGB(255, 255, 255); float[] javaDefaultHSB= javaDefaultRGB.getHSB(); if (Math.abs(infoBgHSB[2] - javaDefaultHSB[2]) < 0.5f) { // workaround for dark tooltip background color, see https://bugs.eclipse.org/309334 IPreferenceStore preferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore(); boolean useDefault= preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); if (useDefault) return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); return PreferenceConverter.getColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); } return null; }
/** * Returns <code>null</code> if {@link SWT#COLOR_INFO_BACKGROUND} is visibly distinct from the * default Java source text color. Otherwise, returns the editor background color. * * @param display the display * @return an RGB or <code>null</code> * @since 3.6.1 */ public static RGB getVisibleBackgroundColor(Display display) { float[] infoBgHSB= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB(); Color javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT); RGB javaDefaultRGB= javaDefaultColor != null ? javaDefaultColor.getRGB() : new RGB(255, 255, 255); float[] javaDefaultHSB= javaDefaultRGB.getHSB(); if (Math.abs(infoBgHSB[2] - javaDefaultHSB[2]) < 0.5f) { // workaround for dark tooltip background color, see https://bugs.eclipse.org/309334 IPreferenceStore preferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore(); boolean useDefault= preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); if (useDefault) return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); return PreferenceConverter.getColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); } return null; }