/** * {@inheritDoc} After the error is handled by its underlying {@link IEditErrorHandler}, the * configured error style will be applied to the editor control. */ @Override public void displayError(ICellEditor cellEditor, Exception e) { super.displayError(cellEditor, e); if (!this.errorStylingActive) { Control editorControl = cellEditor.getEditorControl(); // store the current rendering information to be able to reset again originalBgColor = editorControl.getBackground(); originalFgColor = editorControl.getForeground(); originalFont = editorControl.getFont(); // set the rendering information out of the error style editorControl.setBackground( this.errorStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR)); editorControl.setForeground( this.errorStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR)); editorControl.setFont(this.errorStyle.getAttributeValue(CellStyleAttributes.FONT)); if (decorationProvider != null) { decorationProvider.showDecoration(); } this.errorStylingActive = true; } }
SelectableMouseTrackListener(Control root) { this.root = root; initialBg = root.getBackground(); root.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { SelectableMouseTrackListener.this.root = null; border = null; painter = null; initialBg = null; } }); }
/** * 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; } } }
public static Image getImage(String url, Control widget) { Image img = getImage(url); if (img != null && widget != null) img.setBackground(widget.getBackground()); return img; }