/** * 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); }
/** * 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); }
/** * 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); }
public CssConfiguration(ColorRegistry colorRegistry) { this.colorRegistry = colorRegistry; for (Map.Entry<String, RGB> colorEnt : Colors.keyToRgb.entrySet()) { colorRegistry.put(colorEnt.getKey(), colorEnt.getValue()); } }
private void initializeDefaultColors() { // TODO This is temporary. // These should be initialized by the workbench theme, but not yet. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133731 Display display = Display.getCurrent(); colorRegistry.put(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()); colorRegistry.put(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR, display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB()); } }
@Override public void start(BundleContext context) throws Exception { super.start(context); if (PlatformUI.isWorkbenchRunning()) { m_colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); m_colorRegistry.put(COLOR_NLS_ROW_INACTIVE_FOREGROUND, new RGB(178, 178, 178)); m_colorRegistry.put(COLOR_TABLE_CURSOR_INACTIVE_BACKGROUND, new RGB(255, 255, 255)); m_colorRegistry.put(COLOR_TABLE_CURSOR_BACKGROUND, new RGB(13, 58, 161)); m_colorRegistry.put(COLOR_TABLE_CURSOR_FOREGROUND, new RGB(255, 255, 255)); m_colorRegistry.put(COLOR_TABLE_CURSOR_INACTIVE_FOREGROUND, new RGB(0, 0, 0)); } m_nlsWorkspace = new NlsWorkspace(); plugin = this; }
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; }
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; }
/** * 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; } }
private void addColorDefinition(ColorDefinition definition, ThemeRegistry themeRegistry, ColorRegistry colorRegistry) { if (themeRegistry.findColor(definition.getId()) == null) { themeRegistry.add(definition); colorRegistry.put(definition.getId(), definition.getValue()); } }
public static void populateDefinition(org.eclipse.e4.ui.css.swt.theme.ITheme cssTheme, ITheme theme, ColorRegistry registry, ColorDefinition definition, IPreferenceStore store) { String key = createPreferenceKey(cssTheme, theme, definition.getId()); String value = store.getString(key); if (!IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(value)) { definition.appendState(ThemeElementDefinition.State.OVERRIDDEN); definition.appendState(ThemeElementDefinition.State.MODIFIED_BY_USER); registry.put(definition.getId(), StringConverter.asRGB(value)); } }
/** * 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() ); }
/** * 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() ); }
/** * Process all colors that default to the given ID. * * @param key the color ID * @param rgb the new RGB value for defaulted colors */ private void processDefaultsTo(String key, RGB rgb) { ColorDefinition[] defs = WorkbenchPlugin.getDefault().getThemeRegistry().getColorsFor(getId()); for (ColorDefinition colorDefinition : defs) { String defaultsTo = colorDefinition.getDefaultsTo(); if (defaultsTo != null && defaultsTo.equals(key)) { IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); if (store.isDefault( ThemeElementHelper.createPreferenceKey(Theme.this, colorDefinition.getId()))) { getColorRegistry().put(colorDefinition.getId(), rgb); processDefaultsTo(colorDefinition.getId(), rgb); } } } } };
public ResultLabelProvider(ResultContentProvider contentProvider) { Color searchColor = JFaceResources.getColorRegistry().get(ECLIPSE_SEARCH_UI_MATCH_HIGHLIGHT); JFaceResources.getColorRegistry().put(HIGHLIGHT_COLOR_NAME, (searchColor!=null?searchColor.getRGB():new RGB(206, 204, 247))); this.labelProvider = new WorkbenchLabelProvider(); this.highlightStyle = StyledString.createColorRegistryStyler(null, HIGHLIGHT_COLOR_NAME); this.contentProvider = contentProvider; this.matchImage = InstaSearchUI.getSharedImage(IMG_OBJ_TEXT_SEARCH_LINE); imageRegistry.put(DOWN_ARROW_IMG_KEY, InstaSearchPlugin.getImageDescriptor(DOWN_ARROW_IMG_KEY)); this.showMatchCount = InstaSearchPlugin.getBoolPref(PreferenceConstants.P_SHOW_MATCH_COUNT); this.showFullPath = InstaSearchPlugin.getBoolPref(PreferenceConstants.P_SHOW_FULL_PATH); InstaSearchPlugin.addPreferenceChangeListener(this); }
protected void resetThemeRegistries(ThemeRegistry themeRegistry, FontRegistry fontRegistry, ColorRegistry colorRegistry) { for (FontDefinition def : themeRegistry.getFonts()) { if (def.isOverridden()) { def.resetToDefaultValue(); fontRegistry.put(def.getId(), def.getValue() != null ? def.getValue() : PreferenceConverter.getFontDataArrayDefaultDefault()); } } for (ColorDefinition def : themeRegistry.getColors()) { if (def.isOverridden()) { def.resetToDefaultValue(); colorRegistry.put(def.getId(), def.getValue() != null ? def.getValue() : EMPTY_COLOR_VALUE); } } }
: (RGB) event.getNewValue(); getColorRegistry().put(key, rgb); processDefaultsTo(key, rgb); return;
protected void overrideAlreadyExistingDefinitions(org.osgi.service.event.Event event, IStylingEngine engine, ThemeRegistry themeRegistry, FontRegistry fontRegistry, ColorRegistry colorRegistry) { IPreferenceStore store = PrefUtil.getInternalPreferenceStore(); org.eclipse.e4.ui.css.swt.theme.ITheme cssTheme = getTheme(event); ITheme theme = getColorsAndFontsTheme(); for (FontDefinition fontDefinition : themeRegistry.getFonts()) { engine.style(fontDefinition); if (fontDefinition.isOverridden()) { populateDefinition(cssTheme, theme, fontRegistry, fontDefinition, store); if (!fontDefinition.isModifiedByUser()) { fontRegistry.put(fontDefinition.getId(), fontDefinition.getValue()); } } } for (ColorDefinition colorDefinition : themeRegistry.getColors()) { engine.style(colorDefinition); if (colorDefinition.isOverridden()) { populateDefinition(cssTheme, theme, colorRegistry, colorDefinition, store); if (!colorDefinition.isModifiedByUser()) { colorRegistry.put(colorDefinition.getId(), colorDefinition.getValue()); } } } }
for (Object themeColorKey : themeColors.getKeySet()) { String key = (String) themeColorKey; jfaceColors.put(key, themeColors.getRGB(key));
registry.put(id, prefColor);