/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/
package com.nokia.carbide.cpp.internal.project.ui.preferences;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;

import com.nokia.carbide.cpp.internal.project.ui.ProjectUIPlugin;

/**
 * Class used to initialize default preference values.
 */
public class PreferenceInitializer extends AbstractPreferenceInitializer {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
	 */
	public void initializeDefaultPreferences() {
		IPreferenceStore store = ProjectUIPlugin.getDefault().getPreferenceStore();
		store.setDefault(PreferenceConstants.PREF_KEEP_PROJECTS_IN_SYNC, true);
		store.setDefault(PreferenceConstants.PREF_INDEX_ALL, false);
		
		if (cmdLineArgsSupportsLinkedResources()){
			store.setDefault(PreferenceConstants.PREF_SUPPORT_LINKED_RESOURCES, true);
		} else {
			store.setDefault(PreferenceConstants.PREF_SUPPORT_LINKED_RESOURCES, false);
		}
	}
	
	private boolean cmdLineArgsSupportsLinkedResources(){
		String[] args = Platform.getCommandLineArgs();
		for (String arg : args){
			if (arg.equals("supportsLinkedRsrcs=true"))
				return true;
		}
		return false;
	}

}
