plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java
changeset 471 06589bf52fa7
parent 470 d4809db37847
child 472 bd9f2d7c64a6
equal deleted inserted replaced
470:d4809db37847 471:06589bf52fa7
     1 /*******************************************************************************
       
     2  * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Symbian Foundation - initial contribution.
       
    11  * Contributors:
       
    12  * Description:
       
    13  * Overview:
       
    14  * Details:
       
    15  * Platforms/Drives/Compatibility:
       
    16  * Assumptions/Requirement/Pre-requisites:
       
    17  * Failures and causes:
       
    18  *******************************************************************************/
       
    19 package org.symbian.tools.wrttools.debug.internal;
       
    20 
       
    21 import java.io.File;
       
    22 
       
    23 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
       
    24 import org.eclipse.jface.preference.IPreferenceStore;
       
    25 import org.symbian.tools.wrttools.util.CoreUtil;
       
    26 
       
    27 public class PreferenceInitializer extends AbstractPreferenceInitializer {
       
    28 	private final static String DEFAULT_CHROME_LOCATION = "Local Settings/Application Data/Google/Chrome/Application";
       
    29 
       
    30 	@Override
       
    31 	public void initializeDefaultPreferences() {
       
    32 		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
       
    33 		File folder = getDefaultFolder();
       
    34 		if (ChromeDebugUtils.getExecutablePath(folder.getAbsolutePath()) != null) {
       
    35 			store.setDefault(IConstants.PREF_NAME_CHROME_LOCATION, folder
       
    36 					.getAbsolutePath());
       
    37 		}
       
    38 	}
       
    39 
       
    40 	private File getDefaultFolder() {
       
    41 		if (CoreUtil.isMac()) {
       
    42 			return new File("/Applications");
       
    43 		} else if (CoreUtil.isLinux()) {
       
    44 			return new File("/opt/google/chrome");
       
    45 		}
       
    46 		String property = System.getProperty("user.home");
       
    47 		File folder = new File(property, DEFAULT_CHROME_LOCATION);
       
    48         if (!folder.exists()) {
       
    49             folder = new File("C:/Program Files/Google/Chrome/Application/");
       
    50         }
       
    51 		return folder;
       
    52 	}
       
    53 
       
    54 }