Java Code Examples for org.eclipse.jface.preference.PreferenceConverter#getDefaultColor()

The following examples show how to use org.eclipse.jface.preference.PreferenceConverter#getDefaultColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaSourceViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference store.
 * Returns <code>null</code> if there is no such information available.
 *
 * @param store the store to read from
 * @param key the key used for the lookup in the preference store
 * @param display the display used create the color
 * @return the created color according to the specification in the preference store
 * @since 3.0
 */
private Color createColor(IPreferenceStore store, String key, Display display) {

    RGB rgb= null;

    if (store.contains(key)) {

        if (store.isDefault(key))
            rgb= PreferenceConverter.getDefaultColor(store, key);
        else
            rgb= PreferenceConverter.getColor(store, key);

        if (rgb != null)
            return new Color(display, rgb);
    }

    return null;
}
 
Example 2
Source File: JavaUIPreferenceInitializer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the default value and fires a property
 * change event if necessary.
 *
 * @param store	the preference store
 * @param key the preference key
 * @param newValue the new value
 * @param fireEvent <code>false</code> if no event should be fired
 * @since 3.4
 */
private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) {
	if (!fireEvent) {
		PreferenceConverter.setDefault(store, key, newValue);
		return;
	}

	RGB oldValue= null;
	if (store.isDefault(key))
		oldValue= PreferenceConverter.getDefaultColor(store, key);

	PreferenceConverter.setDefault(store, key, newValue);

	if (oldValue != null && !oldValue.equals(newValue))
		store.firePropertyChangeEvent(key, oldValue, newValue);
}
 
Example 3
Source File: EditorConfigUIPreferenceInitializer.java    From editorconfig-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the default value and fires a property change event if necessary.
 *
 * @param store
 *            the preference store
 * @param key
 *            the preference key
 * @param newValue
 *            the new value
 * @param fireEvent
 *            <code>false</code> if no event should be fired
 */
private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) {
	if (!fireEvent) {
		PreferenceConverter.setDefault(store, key, newValue);
		return;
	}

	RGB oldValue = null;
	if (store.isDefault(key)) {
		oldValue = PreferenceConverter.getDefaultColor(store, key);
	}
	PreferenceConverter.setDefault(store, key, newValue);

	if (oldValue != null && !oldValue.equals(newValue)) {
		store.firePropertyChangeEvent(key, oldValue, newValue);
	}
}
 
Example 4
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference
 * store. Returns <code>null</code> if there is no such information
 * available.
 */
private Color createColor( IPreferenceStore store, String key,
		Display display )
{
	RGB rgb = null;
	if ( store.contains( key ) )
	{
		if ( store.isDefault( key ) )
		{
			rgb = PreferenceConverter.getDefaultColor( store, key );
		}
		else
		{
			rgb = PreferenceConverter.getColor( store, key );
		}
		if ( rgb != null )
		{
			return new Color( display, rgb );
		}
	}
	return null;
}
 
Example 5
Source File: UIUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static Color createColor( IPreferenceStore store, String key,
		Display display )
{
	RGB rgb = null;
	if ( store.contains( key ) )
	{
		if ( store.isDefault( key ) )
		{
			rgb = PreferenceConverter.getDefaultColor( store, key );
		}
		else
		{
			rgb = PreferenceConverter.getColor( store, key );
		}
		if ( rgb != null )
		{
			return new Color( display, rgb );
		}
	}
	return null;
}
 
Example 6
Source File: AbstractSyntaxColoringPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference
 * store. Returns <code>null</code> if there is no such information
 * available.
 * 
 * @param store
 *            the store to read from
 * @param key
 *            the key used for the lookup in the preference store
 * @param display
 *            the display used create the color
 * @return the created color according to the specification in the
 *         preference store
 * @since 2.0
 */
private Color createColor(IPreferenceStore store, String key, Display display) {

	RGB rgb = null;

	if (store.contains(key)) {

		if (store.isDefault(key))
			rgb = PreferenceConverter.getDefaultColor(store, key);
		else
			rgb = PreferenceConverter.getColor(store, key);

		if (rgb != null)
			return new Color(display, rgb);
	}

	return null;
}
 
Example 7
Source File: ViewerColorUpdater.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected Color createColor(IPreferenceStore store, String key, Display display) {
	
	RGB rgb = null;
	
	if(store.contains(key)) {
		
		if(store.isDefault(key)) {
			rgb = PreferenceConverter.getDefaultColor(store, key);
		} else {
			rgb = PreferenceConverter.getColor(store, key);
		}
		
		if(rgb != null)
			return new Color(display, rgb);
	}
	
	return null;
}
 
Example 8
Source File: SemanticHighlightings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the default value and fires a property
 * change event if necessary.
 *
 * @param store	the preference store
 * @param key the preference key
 * @param newValue the new value
 * @since 3.3
 */
private static void setDefaultAndFireEvent(IPreferenceStore store, String key, RGB newValue) {
	RGB oldValue= null;
	if (store.isDefault(key))
		oldValue= PreferenceConverter.getDefaultColor(store, key);

	PreferenceConverter.setDefault(store, key, newValue);

	if (oldValue != null && !oldValue.equals(newValue))
		store.firePropertyChangeEvent(key, oldValue, newValue);
}
 
Example 9
Source File: PythonSourceViewer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a color from the information stored in the given preference store. Returns <code>null</code> if there is no such information available.
 */
private Color createColor(IPreferenceStore store, String key, Display display) {
    RGB rgb = null;
    if (store.contains(key)) {
        if (store.isDefault(key)) {
            rgb = PreferenceConverter.getDefaultColor(store, key);
        } else {
            rgb = PreferenceConverter.getColor(store, key);
        }
        if (rgb != null) {
            return new Color(display, rgb);
        }
    }
    return null;
}
 
Example 10
Source File: PreferenceConstants.java    From typescript.java with MIT License 3 votes vote down vote up
/**
 * Sets the default value and fires a property change event if necessary.
 * 
 * @param store
 *            the preference store
 * @param key
 *            the preference key
 * @param newValue
 *            the new value
 * 
 */
private static void setDefaultAndFireEvent(IPreferenceStore store, String key, RGB newValue) {
	RGB oldValue = null;
	if (store.isDefault(key))
		oldValue = PreferenceConverter.getDefaultColor(store, key);

	PreferenceConverter.setDefault(store, key, newValue);

	if (oldValue != null && !oldValue.equals(newValue))
		store.firePropertyChangeEvent(key, oldValue, newValue);
}