package com.opcoach.e4.preferences.example.pages;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.graphics.RGB;

import com.opcoach.e4.preferences.ScopedPreferenceStore;

public class DefaultValuesInitializer extends AbstractPreferenceInitializer
{

	public DefaultValuesInitializer()
	{
		// TODO Auto-generated constructor stub
	}

	@Override
	public void initializeDefaultPreferences()
	{
		IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "com.opcoach.e4.preferences.example");	
		
		System.out.println("Enter in default Preference Initializer");
	
		store.setDefault("rootPageValue", "DEFAULT ROOT PAGE VALUE");
		store.setDefault("page1", "DEFAULT PAGE 1 VALUE");
		store.setDefault("page2", "DEFAULT PAGE 2 VALUE");
		
		store.setDefault("prefCombo", "value2");
		store.setDefault("prefColor", StringConverter.asString(new RGB(0,255,0)));
		store.setDefault("prefBoolean",true);
		store.setDefault("prefString","Default string value");
				
		
		
		
	}

}

package com.opcoach.e4.preferences.example.pages;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.graphics.RGB;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.prefs.BackingStoreException;

public class DefaultValuesInitializer extends AbstractPreferenceInitializer
{

	public DefaultValuesInitializer()
	{
		// TODO Auto-generated constructor stub
	}

	@Override
	public void initializeDefaultPreferences()
	{
		IEclipsePreferences node = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(getClass()).getSymbolicName());
	
		if (node != null)
		{
			node.put("rootPageValue", "DEFAULT ROOT PAGE VALUE");
			node.put("page1", "DEFAULT PAGE 1 VALUE");
			node.put("page2", "DEFAULT PAGE 2 VALUE");
		
			node.put("prefCombo", "value2");
			node.put("prefColor", StringConverter.asString(new RGB(0,255,0)));
			node.putBoolean("prefBoolean",true);
			node.put("prefString","Default string value");
			
			try { node.flush();  }  catch (BackingStoreException e) { }
		}		
		
		
		
	}

}

Change the way to set the default preferences
Change the way to set the default preferences

Change-Id: I2d68b53b5030fbf04e2a2b190d3e3e7abacbfb1c
Signed-off-by: Olivier Prouvost <922fcad8957c9a47efb13ab034b8bf0240ed7092@opcoach.com>
