crashanalysis/crashanalyser/com.nokia.s60tools.crashanalyser/src/com/nokia/s60tools/crashanalyser/model/SourceSdkManager.java
changeset 0 5ad7ad99af01
equal deleted inserted replaced
-1:000000000000 0:5ad7ad99af01
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 package com.nokia.s60tools.crashanalyser.model;
       
    19 
       
    20 import com.nokia.s60tools.sdk.SdkUtils;
       
    21 import java.util.*;
       
    22 
       
    23 /**
       
    24  * Manages SDKs for 'Open Source File' functionality. 
       
    25  *
       
    26  */
       
    27 public final class SourceSdkManager {
       
    28 	private SourceSdkManager() {
       
    29 		// no implementation needed
       
    30 	}
       
    31 	
       
    32 	/**
       
    33 	 * Returns a list of all SDKs and their location
       
    34 	 * @return all SDKS.
       
    35 	 */
       
    36 	public static Map<String, String> getAllSdks() {
       
    37 		try {
       
    38 			return SdkUtils.getSdkMapFileFolders(true, true);
       
    39 		} catch (Exception e) {
       
    40 			e.printStackTrace();
       
    41 			return null;
       
    42 		}
       
    43 	}
       
    44 	
       
    45 	/**
       
    46 	 * Set given SDK as the SDK which is to be used in 'Open Source File' functionality
       
    47 	 * @param sdk default sdk to be used
       
    48 	 */
       
    49 	public static void setSdk(String sdk) {
       
    50 		UserEnteredData data = new UserEnteredData();
       
    51 		data.savePreviousSdk(sdk);
       
    52 	}
       
    53 	
       
    54 	/**
       
    55 	 * Gets the name of the SDK which is currently the one being used 
       
    56 	 * by 'Open Source File' functionality
       
    57 	 * @return name of the currently default SDK
       
    58 	 */
       
    59 	public static String getCurrentSkdName() {
       
    60 		UserEnteredData data = new UserEnteredData();
       
    61 		return data.getPreviousSdk();
       
    62 	}
       
    63 
       
    64 	/**
       
    65 	 * Returns the epocroot folder of given sdk.
       
    66 	 * @param sdkName sdk
       
    67 	 * @return epocroot folder or null
       
    68 	 */
       
    69 	public static String getEpocroot(String sdkName) {
       
    70 		try {
       
    71 			Map<String, String> sdks = SdkUtils.getSdkMapFileFolders(true, true);
       
    72 			if (sdks.containsKey(sdkName))
       
    73 				return sdks.get(sdkName);
       
    74 		} catch (Exception e) {
       
    75 			e.printStackTrace();
       
    76 		}
       
    77 		return null;
       
    78 	}
       
    79 }