Example usage for org.eclipse.jface.preference PreferenceConverter COLOR_DEFAULT_DEFAULT

List of usage examples for org.eclipse.jface.preference PreferenceConverter COLOR_DEFAULT_DEFAULT

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceConverter COLOR_DEFAULT_DEFAULT.

Prototype

RGB COLOR_DEFAULT_DEFAULT

To view the source code for org.eclipse.jface.preference PreferenceConverter COLOR_DEFAULT_DEFAULT.

Click Source Link

Document

The default-default value for color preferences (black, RGB(0,0,0)).

Usage

From source file:com.google.dart.tools.ui.internal.text.editor.SemanticHighlightingManager_NEW.java

License:Open Source License

@Override
public void applyTextPresentation(TextPresentation textPresentation) {
    synchronized (positionsLock) {
        if (positions == null) {
            return;
        }/*w w  w .  j  a v  a2s . c om*/
        // prepare damaged region
        IRegion damagedRegion = textPresentation.getExtent();
        int daOffset = damagedRegion.getOffset();
        int daEnd = daOffset + damagedRegion.getLength();
        // prepare theme access
        IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore();
        IColorManager colorManager = DartUI.getColorManager();
        // add style ranges
        for (HighlightPosition position : positions) {
            // skip if outside of the damaged region
            int hiOffset = position.getOffset();
            int hiLength = position.getLength();
            int hiEnd = hiOffset + hiLength;
            if (hiEnd < daOffset || hiOffset >= daEnd) {
                continue;
            }
            if (hiEnd > daEnd) {
                continue;
            }
            // prepare highlight key
            String highlightType = position.highlight.getType();
            String themeKey = getThemeKey(highlightType);
            if (themeKey == null) {
                continue;
            }
            themeKey = "semanticHighlighting." + themeKey;
            // prepare color
            RGB foregroundRGB = PreferenceConverter.getColor(store, themeKey + ".color");
            if (foregroundRGB == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
                continue;
            }
            Color foregroundColor = colorManager.getColor(foregroundRGB);
            // prepare font style
            boolean fontBold = store.getBoolean(themeKey + ".bold");
            boolean fontItalic = store.getBoolean(themeKey + ".italic");
            int fontStyle = 0;
            if (fontBold) {
                fontStyle |= SWT.BOLD;
            }
            if (fontItalic) {
                fontStyle |= SWT.ITALIC;
            }
            // merge style range
            textPresentation
                    .replaceStyleRange(new StyleRange(hiOffset, hiLength, foregroundColor, null, fontStyle));
        }
    }
}

From source file:com.mobilesorcery.sdk.ui.editors.resources.SyntaxColoringPreference.java

License:Open Source License

public RGB getBackground() {
    return background == null ? PreferenceConverter.COLOR_DEFAULT_DEFAULT : background;
}

From source file:com.mobilesorcery.sdk.ui.editors.resources.SyntaxColoringPreference.java

License:Open Source License

public RGB getForeground() {
    return foreground == null ? PreferenceConverter.COLOR_DEFAULT_DEFAULT : foreground;
}

From source file:com.mobilesorcery.sdk.ui.editors.resources.SyntaxColoringPreferenceComposite.java

License:Open Source License

protected void setCurrentElement(Object firstElement) {
    if (firstElement instanceof SyntaxColoringPreference) {
        SyntaxColoringPreference pref = (SyntaxColoringPreference) firstElement;
        currentPref = pref;//  w w w .j  av a 2  s  . co m
        RGB prefForeground = pref.getForeground();
        foreground.setColorValue(
                prefForeground == null ? PreferenceConverter.COLOR_DEFAULT_DEFAULT : prefForeground);
        foreground.setEnabled(true);
        if (background != null) {
            RGB prefBackground = pref.getBackground();
            background.setColorValue(
                    prefBackground == null ? PreferenceConverter.COLOR_DEFAULT_DEFAULT : prefBackground);
            background.setEnabled(true);
        }

        bold.setSelection(pref.isBold());
        bold.setEnabled(true);
        italic.setSelection(pref.isItalic());
        italic.setEnabled(true);
        //underline.setSelection(pref.isUnderline());
        //underline.setEnabled(true);
    } else {
        // Null or category.
        currentPref = null;
        foreground.setEnabled(false);
        if (background != null) {
            background.setEnabled(false);
        }

        bold.setSelection(false);
        bold.setEnabled(false);
        italic.setSelection(false);
        italic.setEnabled(false);
        //underline.setSelection(false);
        //underline.setEnabled(false);
    }
}

From source file:melnorme.lang.ide.ui.text.coloring.TextStylingPreference.java

License:Open Source License

public static RGB getRgb(IPreferencesAccess prefsHelper, String key) {
    return StringConverter.asRGB(prefsHelper.getString(key), PreferenceConverter.COLOR_DEFAULT_DEFAULT);
}

From source file:org.apache.ivyde.internal.eclipse.ui.console.IvyConsole.java

License:Apache License

/**
 * Returns a color instance based on data from a preference field.
 *//*w w w  .  j  av a 2 s.co  m*/
private Color createColor(Display display, String preference) {
    RGB rgb = PreferenceConverter.getColor(IvyPlugin.getDefault().getPreferenceStore(), preference);
    if (rgb == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
        // CheckStyle:MagicNumber| OFF
        if (PREF_CONSOLE_DEBUG_COLOR.equals(preference)) {
            rgb = new RGB(180, 180, 255);
        } else if (PREF_CONSOLE_VERBOSE_COLOR.equals(preference)) {
            rgb = new RGB(50, 150, 50);
        } else if (PREF_CONSOLE_WARN_COLOR.equals(preference)) {
            rgb = new RGB(255, 80, 20);
        } else if (PREF_CONSOLE_ERROR_COLOR.equals(preference)) {
            rgb = new RGB(255, 0, 0);
        }
        // CheckStyle:MagicNumber| ON
    }
    return new Color(display, rgb);
}

From source file:org.eclipse.epf.diagram.core.util.DiagramCoreUtil.java

License:Open Source License

/**
 * Set the default font for this preference store.
 * @param store IPreferenceStore/* w  w  w.ja  v a2  s .com*/
 */
public static void setDefaultLineStyle(IPreferenceStore store) {
    PreferenceConverter.setDefault(store, IPreferenceConstants.PREF_LINE_COLOR,
            PreferenceConverter.COLOR_DEFAULT_DEFAULT);
}

From source file:org.eclipse.ui.internal.themes.ThemeElementHelper.java

License:Open Source License

/**
 * Installs the given color in the preference store and optionally the color 
 * registry./*from   w ww  .j a va  2s  .  com*/
 * 
 * @param definition
 *            the color definition
 * @param theme
 *            the theme defining the color
 * @param store
 *            the preference store from which to set and obtain color data
 * @param setInRegistry
 *            whether the color should be put into the registry
 */

private static void installColor(ColorDefinition definition, ITheme theme, IPreferenceStore store,
        boolean setInRegistry) {

    //TODO: store shouldn't be null, should assert instead of checking null all over

    ColorRegistry registry = theme.getColorRegistry();

    String id = definition.getId();
    String key = createPreferenceKey(theme, id);
    RGB prefColor = store != null ? PreferenceConverter.getColor(store, key) : null;
    RGB defaultColor = (definition.getValue() != null) ? definition.getValue()
            : registry.getRGB(definition.getDefaultsTo());

    if (defaultColor == null) {
        // default is null, likely because we have a bad definition - the
        // defaultsTo color doesn't exist. We still need a sensible default,
        // however.
        defaultColor = PreferenceConverter.COLOR_DEFAULT_DEFAULT;
    }

    if (prefColor == null || prefColor == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
        prefColor = defaultColor;
    }

    //if the preference value isn't the default then retain that pref value
    RGB colorToUse = !store.isDefault(key) ? prefColor : defaultColor;

    if (setInRegistry) {
        registry.put(id, colorToUse);
    }

    if (store != null) {
        PreferenceConverter.setDefault(store, key, defaultColor);
    }
}