plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/tmw/debug/internal/PreferenceInitializer.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 02 Sep 2010 10:50:38 -0700
changeset 483 109da596fa9d
parent 472 bd9f2d7c64a6
child 484 f5df819c1852
permissions -rw-r--r--
Fixed relevant FindBug messages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/*******************************************************************************
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 *******************************************************************************/
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.tmw.debug.internal;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import java.io.File;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.jface.preference.IPreferenceStore;
472
bd9f2d7c64a6 Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 471
diff changeset
    25
import org.symbian.tools.tmw.core.utilities.CoreUtil;
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
public class PreferenceInitializer extends AbstractPreferenceInitializer {
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    28
    private static final String DEFAULT_CHROME_PATH_WINXP = "C:/Program Files/Google/Chrome/Application/";
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    29
    private static final String DEFAULT_CHROME_PATH_LINUX = "/opt/google/chrome";
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    30
    private static final String DEFAULT_CHROME_PATH_MAC = "/Applications";
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    31
    private final static String DEFAULT_CHROME_PATH_VISTA = "Local Settings/Application Data/Google/Chrome/Application";
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    33
    @Override
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    34
    public void initializeDefaultPreferences() {
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    35
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    36
        File folder = getDefaultFolder();
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    37
        if (ChromeDebugUtils.getExecutablePath(folder.getAbsolutePath()) != null) {
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    38
            store.setDefault(IConstants.PREF_NAME_CHROME_LOCATION, folder.getAbsolutePath());
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    39
        }
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    40
    }
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    42
    private File getDefaultFolder() {
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    43
        if (CoreUtil.isMac()) {
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    44
            return new File(DEFAULT_CHROME_PATH_MAC);
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    45
        } else if (CoreUtil.isLinux()) {
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    46
            return new File(DEFAULT_CHROME_PATH_LINUX);
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    47
        }
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    48
        String property = System.getProperty("user.home");
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    49
        File folder = new File(property, DEFAULT_CHROME_PATH_VISTA);
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
        if (!folder.exists()) {
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    51
            folder = new File(DEFAULT_CHROME_PATH_WINXP);
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
        }
483
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    53
        return folder;
109da596fa9d Fixed relevant FindBug messages
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 472
diff changeset
    54
    }
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
}