private void refreshDiffColors() { ColorRegistry reg = PlatformUI.getWorkbench().getThemeManager() .getCurrentTheme().getColorRegistry(); this.addBackgroundColor = reg.get(THEME_DiffAddBackgroundColor); this.addForegroundColor = reg.get(THEME_DiffAddForegroundColor); this.removeBackgroundColor = reg.get(THEME_DiffRemoveBackgroundColor); this.removeForegroundColor = reg.get(THEME_DiffRemoveForegroundColor); this.hunkBackgroundColor = reg.get(THEME_DiffHunkBackgroundColor); this.hunkForegroundColor = reg.get(THEME_DiffHunkForegroundColor); this.headlineBackgroundColor = reg.get(THEME_DiffHeadlineBackgroundColor); this.headlineForegroundColor = reg.get(THEME_DiffHeadlineForegroundColor); }
/** * Create a new instance of this class. * * @param parent the parent registry */ public CascadingColorRegistry(ColorRegistry parent) { super(Display.getCurrent(), false); this.parent = parent; parent.addListener(listener); }
/** * Returns the RGB for the given key in the given color registry. * * @param registry the color registry * @param key the key for the constant in the registry * @param defaultRGB the default RGB if no entry is found * @return RGB the RGB * @since 3.3 */ private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { if (registry == null) return defaultRGB; RGB rgb= registry.getRGB(key); if (rgb != null) return rgb; return defaultRGB; }
@Override public RGB getRGB(String symbolicName) { if (super.hasValueFor(symbolicName)) { return super.getRGB(symbolicName); } return parent.getRGB(symbolicName); }
public Color getColorFromRgb(RGB rgb) { if (rgb == null) { return null; } String symbolicName = String.format("#%02X%02X%02X", rgb.red, rgb.green, rgb.blue); //$NON-NLS-1$ Color color = JFaceResources.getColorRegistry().get(symbolicName); if (color == null) { JFaceResources.getColorRegistry().put(symbolicName, rgb); color = JFaceResources.getColorRegistry().get(symbolicName); } return color; }
/** * Use this method to get SWT colors. A ColorRegistry is used to manage * the RGB->Color mapping. * <p> * Note: Don't dispose the returned color. It is disposed automatically * when the plugin is stopped. * * @param rgb * the rgb color data * @return The SWT Color */ public Color getColor( RGB rgb ) { if ( !colorRegistry.hasValueFor( rgb.toString() ) ) { colorRegistry.put( rgb.toString(), rgb ); } return colorRegistry.get( rgb.toString() ); }
public void dispose () { JFaceResources.getColorRegistry ().removeListener ( this ); }
private void inititalizeColors() { if (getSite().getShell().isDisposed()) return; Display display= getSite().getShell().getDisplay(); if (display == null || display.isDisposed()) return; setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); ColorRegistry registry= JFaceResources.getColorRegistry(); registry.addListener(this); fBackgroundColorRGB= registry.getRGB(getBackgroundColorKey()); Color bgColor; if (fBackgroundColorRGB == null) { bgColor= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); fBackgroundColorRGB= bgColor.getRGB(); } else { bgColor= new Color(display, fBackgroundColorRGB); fBackgroundColor= bgColor; } setBackground(bgColor); }
/** * Adds (or replaces) a color to this color registry under the given * symbolic name. * <p> * A property change event is reported whenever the mapping from a symbolic * name to a color changes. The source of the event is this registry; the * property name is the symbolic color name. * </p> * * @param symbolicName the symbolic color name * @param colorData an <code>RGB</code> object */ public void put(String symbolicName, RGB colorData) { put(symbolicName, colorData, true); }
/** * get colors for use in the UI * * @see #COLOR_HR * @see #COLOR_HR_SHADOW */ public static ColorRegistry getColors() { ColorRegistry colorRegistry = (ColorRegistry) Display.getCurrent().getData(KEY_COLOR_REGISTRY); if (colorRegistry == null) { colorRegistry = new ColorRegistry(); colorRegistry.put(COLOR_HR, new RGB(132, 132, 132)); colorRegistry.put(COLOR_HR_SHADOW, new RGB(206, 206, 206)); Display.getCurrent().setData(KEY_COLOR_REGISTRY, colorRegistry); } return colorRegistry; } }
/** * Returns the color registry for JFace itself. * <p> * * @return the <code>ColorRegistry</code>. * @since 3.0 */ public static ColorRegistry getColorRegistry() { if (colorRegistry == null) { colorRegistry = new ColorRegistry(); } return colorRegistry; }
return; else if (getColorRegistry().hasValueFor(key)) { RGB rgb = event.getNewValue() instanceof String ? StringConverter.asRGB((String) event.getNewValue()) : (RGB) event.getNewValue(); getColorRegistry().put(key, rgb); processDefaultsTo(key, rgb); return;
public static Color colorFromString(String rgbString) { if (rgbString != null && rgbString.trim().length() > 0) { Color col = JFaceResources.getColorRegistry().get(rgbString); try { if (col == null) { RGB rgb = StringConverter.asRGB(rgbString); JFaceResources.getColorRegistry().put(rgbString, rgb); col = JFaceResources.getColorRegistry().get(rgbString); } } catch (DataFormatException e) { log.error("Corrupt color value: " + rgbString, e); } return col; } return null; }
public void dispose () { JFaceResources.getColorRegistry ().removeListener ( this ); }
/** * Use this method to get SWT colors. A ColorRegistry is used to manage * the RGB->Color mapping. * <p> * Note: Don't dispose the returned color. It is disposed automatically * when the plugin is stopped. * * @param rgb * the rgb color data * @return The SWT Color */ public Color getColor( RGB rgb ) { if ( !colorRegistry.hasValueFor( rgb.toString() ) ) { colorRegistry.put( rgb.toString(), rgb ); } return colorRegistry.get( rgb.toString() ); }
private void inititalizeColors() { if (getSite().getShell().isDisposed()) return; Display display= getSite().getShell().getDisplay(); if (display == null || display.isDisposed()) return; setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); ColorRegistry registry= JFaceResources.getColorRegistry(); registry.addListener(this); fBackgroundColorRGB= registry.getRGB(getBackgroundColorKey()); Color bgColor; if (fBackgroundColorRGB == null) { bgColor= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); fBackgroundColorRGB= bgColor.getRGB(); } else { bgColor= new Color(display, fBackgroundColorRGB); fBackgroundColor= bgColor; } setBackground(bgColor); }
/** * Adds (or replaces) a color to this color registry under the given * symbolic name. * <p> * A property change event is reported whenever the mapping from a symbolic * name to a color changes. The source of the event is this registry; the * property name is the symbolic color name. * </p> * * @param symbolicName the symbolic color name * @param colorData an <code>RGB</code> object */ public void put(String symbolicName, RGB colorData) { put(symbolicName, colorData, true); }
/** * Returns the color registry for JFace itself. * <p> * * @return the <code>ColorRegistry</code>. * @since 3.0 */ public static ColorRegistry getColorRegistry() { if (colorRegistry == null) { colorRegistry = new ColorRegistry(); } return colorRegistry; }
/** * @param display the display the color is from * @return the default color to use for displaying errors. * @see ColorRegistry#get(String) * @see JFacePreferences#ERROR_COLOR */ public static Color getErrorText(Display display) { return JFaceResources.getColorRegistry().get( JFacePreferences.ERROR_COLOR); }