/** * Converts the given value into an SWT RGB color value. * Returns the given default value if the * value does not represent an RGB color value. * * @param value the value to be converted * @param dflt the default value * @return the value as a RGB color value, or the default value */ public static RGB asRGB(String value, RGB dflt) { try { return asRGB(value); } catch (DataFormatException e) { return dflt; } }
/** * Converts the given value into an SWT RGB color value. * Returns the given default value if the * value does not represent an RGB color value. * * @param value the value to be converted * @param dflt the default value * @return the value as a RGB color value, or the default value */ public static RGB asRGB(String value, RGB dflt) { try { return asRGB(value); } catch (DataFormatException e) { return dflt; } }
/** * Converts the given value into an SWT RGB color value. * Returns the given default value if the * value does not represent an RGB color value. * * @param value the value to be converted * @param dflt the default value * @return the value as a RGB color value, or the default value */ public static RGB asRGB(String value, RGB dflt) { try { return asRGB(value); } catch (DataFormatException e) { return dflt; } }
/** * Helper method to construct a color from the given string. * @param value the indentifier for the color * @return RGB */ private static RGB basicGetColor(String value) { if (IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(value)) { return COLOR_DEFAULT_DEFAULT; } RGB color = StringConverter.asRGB(value, null); if (color == null) { return COLOR_DEFAULT_DEFAULT; } return color; }
/** * Helper method to construct a color from the given string. * @param value the indentifier for the color * @return RGB */ private static RGB basicGetColor(String value) { if (IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(value)) { return COLOR_DEFAULT_DEFAULT; } RGB color = StringConverter.asRGB(value, null); if (color == null) { return COLOR_DEFAULT_DEFAULT; } return color; }
/** * Helper method to construct a color from the given string. * @param value the indentifier for the color * @return RGB */ private static RGB basicGetColor(String value) { if (IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(value)) { return COLOR_DEFAULT_DEFAULT; } RGB color = StringConverter.asRGB(value, null); if (color == null) { return COLOR_DEFAULT_DEFAULT; } return color; }
/** * Get the RGB value for a given color. * * @param rawValue * the raw value, either an RGB triple or an SWT constant name * @return the RGB value * @throws DataFormatException * thrown if the value cannot be interpreted as a color */ public static RGB getColorValue(String rawValue) throws DataFormatException { if (rawValue == null) { return null; } rawValue = rawValue.trim(); if (!isDirectValue(rawValue)) { return process(rawValue); } return StringConverter.asRGB(rawValue); }
/** * Restore all color preferences to their values when the page was opened. */ @Override public boolean performCancel() { for (int i = 0; i < fAppearanceColorListModel.length; i++) { String preference = fAppearanceColorListModel[i][1]; PreferenceConverter.setValue(getPreferenceStore(), preference, StringConverter.asRGB(fAppearanceColorListModel[i][2])); } return super.performCancel(); }
@Override public void handlePropertyChangeEvent(PropertyChangeEvent event) { Object color = event.getNewValue(); if (color instanceof RGB) { putColor(event.getProperty(), (RGB) color); } else { putColor(event.getProperty(), StringConverter.asRGB(color.toString())); } } }
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 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)); } }
/** * Update the text attributes associated with the tokens of this scanner as a color preference has been changed. */ private TextAttribute adaptToColorChange(PropertyChangeEvent event, TextAttribute textAttribute) { RGB rgb = null; Object value = event.getNewValue(); if (value instanceof RGB) { rgb = (RGB) value; } else if (value instanceof String) { rgb = StringConverter.asRGB((String) value); } if (rgb != null) { textAttribute = new TextAttribute(ColorManager.getDefault().getColor(rgb), textAttribute.getBackground(), textAttribute.getStyle()); } return textAttribute; }
protected void adaptToColorChange(PropertyChangeEvent event, Token token) { RGB rgb = null; Object value = event.getNewValue(); if (value instanceof RGB) { rgb = (RGB) value; } else if (value instanceof String) { rgb = StringConverter.asRGB((String) value); } if (rgb != null) { TextAttribute attr = (TextAttribute) token.getData(); token.setData(new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle())); } }
private void adaptToTextForegroundChange(Highlighting highlighting, PropertyChangeEvent event) { RGB rgb= null; Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; else if (value instanceof String) rgb= StringConverter.asRGB((String) value); if (rgb != null) { String property= event.getProperty(); Color color= fColorManager.getColor(property); if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(property); ext.bindColor(property, rgb); color= fColorManager.getColor(property); } TextAttribute oldAttr= highlighting.getTextAttribute(); highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } }
private void adaptToTextForegroundChange(Highlighting highlighting, PropertyChangeEvent event) { RGB rgb= null; Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; else if (value instanceof String) rgb= StringConverter.asRGB((String) value); if (rgb != null) { String property= event.getProperty(); Color color= fColorManager.getColor(property); if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(property); ext.bindColor(property, rgb); color= fColorManager.getColor(property); } TextAttribute oldAttr= highlighting.getTextAttribute(); highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } }
private void adaptToTextForegroundChange(Highlighting highlighting, PropertyChangeEvent event) { RGB rgb= null; Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; else if (value instanceof String) rgb= StringConverter.asRGB((String) value); if (rgb != null) { String property= event.getProperty(); Color color= fColorManager.getColor(property); if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(property); ext.bindColor(property, rgb); color= fColorManager.getColor(property); } TextAttribute oldAttr= highlighting.getTextAttribute(); highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } }
private void adaptToColorChange(Token token, PropertyChangeEvent event) { RGB rgb= null; Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; else if (value instanceof String) rgb= StringConverter.asRGB((String) value); if (rgb != null) { String property= event.getProperty(); Color color= fColorManager.getColor(property); if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(property); ext.bindColor(property, rgb); color= fColorManager.getColor(property); } Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } } }
private void adaptToColorChange(Token token, PropertyChangeEvent event) { RGB rgb= null; Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; else if (value instanceof String) rgb= StringConverter.asRGB((String) value); if (rgb != null) { String property= event.getProperty(); Color color= fColorManager.getColor(property); if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(property); ext.bindColor(property, rgb); color= fColorManager.getColor(property); } Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } } }
private void adaptToColorChange(Token token, PropertyChangeEvent event) { RGB rgb= null; Object value= event.getNewValue(); if (value instanceof RGB) rgb= (RGB) value; else if (value instanceof String) rgb= StringConverter.asRGB((String) value); if (rgb != null) { String property= event.getProperty(); Color color= fColorManager.getColor(property); if ((color == null || !rgb.equals(color.getRGB())) && fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(property); ext.bindColor(property, rgb); color= fColorManager.getColor(property); } Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle())); } } }
? StringConverter.asRGB((String) event.getNewValue()) : (RGB) event.getNewValue();