Example usage for org.eclipse.jface.resource ColorRegistry hasValueFor

List of usage examples for org.eclipse.jface.resource ColorRegistry hasValueFor

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ColorRegistry hasValueFor.

Prototype

@Override
    public boolean hasValueFor(String colorKey) 

Source Link

Usage

From source file:asia.sejong.freedrawing.draw2d.figures.SquareButton.java

License:Apache License

protected Color getSavedColor(int r, int g, int b) {
    String colorString = "SB_DEFAULT:" + r + "-" + g + "-" + b;
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    if (!colorRegistry.hasValueFor(colorString)) {
        colorRegistry.put(colorString, new RGB(r, g, b));
    }/*  www  .j  a v a 2  s .co m*/
    return colorRegistry.get(colorString);
}

From source file:ccw.CCWPlugin.java

License:Open Source License

/** 
 * Not thread safe, but should only be called from the UI Thread, so it's
 * not really a problem.//from   w  w  w .j av  a  2 s. c o  m
 * @param rgb
 * @return The <code>Color</code> instance cached for this rgb value, creating
 *         it along the way if required.
 */
public static Color getColor(RGB rgb) {
    ColorRegistry r = getDefault().getColorCache();
    String rgbString = StringConverter.asString(rgb);
    if (!r.hasValueFor(rgbString)) {
        r.put(rgbString, rgb);
    }
    return r.get(rgbString);
}

From source file:com.archimatetool.editor.ui.ColorFactory.java

License:Open Source License

public static Color get(String rgbValue) {
    if (rgbValue == null) {
        return null;
    }// ww w.  j  av a  2s . c o  m

    if (!ColorRegistry.hasValueFor(rgbValue)) {
        RGB rgb = convertStringToRGB(rgbValue);
        if (rgb != null) {
            ColorRegistry.put(rgbValue, rgb);
        }
    }

    return ColorRegistry.get(rgbValue);
}

From source file:customButton.CustomButton.java

License:Open Source License

private Color getSavedColor(int r, int g, int b) {
    String colorString = "COLOR:" + r + "-" + g + "-" + b;
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    if (!colorRegistry.hasValueFor(colorString)) {
        colorRegistry.put(colorString, new RGB(r, g, b));
    }//from   w w  w  .j a va 2  s  .  com
    return colorRegistry.get(colorString);
}

From source file:gov.redhawk.internal.ui.preferences.OverridableDoubleFieldEditor.java

License:Open Source License

private void initColors(Text retVal) {
    defaultForeground = retVal.getForeground();
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    disabledForeground = colorRegistry.get("DarkGray");
    if (disabledForeground == null) {
        if (!colorRegistry.hasValueFor("DarkGray")) {
            colorRegistry.put("DarkGray", new RGB(0x69, 0x69, 0x69));
        }//from  w ww  . j  a v a  2  s. c  o m
        disabledForeground = colorRegistry.get("DarkGray");
    }
}

From source file:gov.redhawk.internal.ui.preferences.ReadOnlyStringFieldEditor.java

License:Open Source License

private void initColors() {
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    textColor = colorRegistry.get("DarkGray");
    if (textColor == null) {
        if (!colorRegistry.hasValueFor("DarkGray")) {
            colorRegistry.put("DarkGray", new RGB(0x69, 0x69, 0x69));
        }/*from  www .j  ava2s .c o m*/
        textColor = colorRegistry.get("DarkGray");
    }
    getTextControl().setForeground(textColor);
}

From source file:org.eclipse.birt.report.designer.internal.ui.util.ColorHelper.java

License:Open Source License

/**
 * Attempts to lookup the RGB value for <code>key</code> from the color
 * registry. If one is not found, the <code>defaultRGB</code> is used.
 * /*from   w ww.  j a v  a2s .co m*/
 * @param registry
 *            The ColorRegistry to search for the RGB value
 * @param key
 *            The key that the RGB value is stored under in the registry
 * @param defaultRGB
 *            The default RGB value to return in the absence of one from the
 *            color registry
 * 
 * @return The RGB value from the color registry for a given key, if it
 *         exists. Otherwise, return the default RGB value.
 */
public static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) {
    if (registry.hasValueFor(key))
        return registry.getRGB(key);
    return defaultRGB;
}

From source file:org.eclipse.birt.report.designer.internal.ui.util.ColorHelper.java

License:Open Source License

/**
 * Attempts to find the RGB string for <code>key</code> from the color
 * registry. If one is not found, an RGB string is generated from the
 * parameters <code>r,g,b</code>.
 * //from www. ja va 2s .c o  m
 * @param registry
 *            The ColorRegistry to search for the RGB value
 * @param key
 *            The key that the RGB value is stored under in the registry
 * @param r
 *            The default red value
 * @param g
 *            The default green value
 * @param b
 *            The default blue value
 * 
 * @return The String RGB value from the color registry for a given key, if
 *         it exists. Otherwise, return the string RGB value created from
 *         the default r,g,b parameters.
 * 
 */
public static String findRGBString(ColorRegistry registry, String key, int r, int g, int b) {
    if (registry.hasValueFor(key))
        return toRGBString(registry.getRGB(key));
    return getColorString(r, g, b);
}

From source file:org.eclipse.cdt.visualizer.ui.util.UIResourceManager.java

License:Open Source License

/** Gets cached color with specified ID */
protected Color getCachedColor(String colorID) {
    Color result = null;//  w  ww  .j  ava  2  s. c o  m
    ColorRegistry colors = getColorRegistry();
    if (colors.hasValueFor(colorID)) {
        result = colors.get(colorID);
    } else {
        // if we don't find it, see if parent manager has it
        UIResourceManager parent = getParentManager();
        if (parent != null) {
            result = parent.getCachedColor(colorID);
        }
    }
    return result;
}

From source file:org.eclipse.ease.discovery.ui.viewer.DiscoveryViewer.java

License:Open Source License

private void initializeColors() {
    IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
    if (colorWhite == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_WHITE)) {
            colorRegistry.put(COLOR_WHITE, new RGB(255, 255, 255));
        }//from  w w  w  .  j  av  a 2 s . co  m
        colorWhite = colorRegistry.get(COLOR_WHITE);
    }
    if (colorDisabled == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_DARK_GRAY)) {
            colorRegistry.put(COLOR_DARK_GRAY, new RGB(0x69, 0x69, 0x69));
        }
        colorDisabled = colorRegistry.get(COLOR_DARK_GRAY);
    }
    if (colorCategoryGradientStart == null) {
        colorCategoryGradientStart = themeManager.getCurrentTheme().getColorRegistry()
                .get(CommonThemes.COLOR_CATEGORY_GRADIENT_START);
        colorCategoryGradientEnd = themeManager.getCurrentTheme().getColorRegistry()
                .get(CommonThemes.COLOR_CATEGORY_GRADIENT_END);
    }
}