qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtSDKUtils.java
author timkelly
Fri, 12 Feb 2010 11:55:42 -0600
changeset 947 cb7b077cee27
parent 945 67437bfc7c6f
child 1293 be3d8ca5bafe
permissions -rw-r--r--
add comments for new code under bug 10681.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     1
/*
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     3
* All rights reserved.
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     4
* This component and the accompanying materials are made available
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     6
* which accompanies this distribution, and is available
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     8
*
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
     9
* Initial Contributors:
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    11
*
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    12
*/
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    13
package com.nokia.carbide.cpp.internal.qt.core;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    14
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    15
import java.io.File;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    16
import java.util.ArrayList;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    17
import java.util.List;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    18
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    19
import org.eclipse.core.resources.IProject;
945
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
    20
import org.eclipse.core.resources.ResourcesPlugin;
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    21
import org.eclipse.core.runtime.CoreException;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    22
import org.eclipse.core.runtime.IPath;
945
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
    23
import org.eclipse.core.runtime.IStatus;
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    24
import org.eclipse.core.runtime.Path;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    25
import org.eclipse.core.runtime.QualifiedName;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    26
import org.eclipse.jface.preference.IPreferenceStore;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    27
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    28
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    29
import com.nokia.cpp.internal.api.utils.core.HostOS;
945
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
    30
import com.nokia.cpp.internal.api.utils.core.Logging;
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    31
import com.trolltech.qtcppproject.QtProjectPlugin;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    32
import com.trolltech.qtcppproject.preferences.PreferenceConstants;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    33
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    34
/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    35
 * Wrapper utils for the Qt-ecilpse integration and obtaining information about internally installed Qt-sdks
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    36
 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    37
@SuppressWarnings({ "restriction" })
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    38
public class QtSDKUtils {
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    39
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    40
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    41
	 * Represents one Qt-SDK from the Qt global preferences
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    42
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    43
	private static class QtSDK {
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    44
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    45
		QtSDK(String name, String incPath, String binPath){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    46
			this.binPath = binPath;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    47
			this.incPath = incPath;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    48
			this.name = name;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    49
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    50
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    51
		public String name;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    52
		public String binPath;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    53
		public String incPath;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    54
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    55
	
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    56
	/** Qt bin folder for internal SDK installs - epocroot relative */
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    57
	private static final String QT_SDK_BIN_PATH = "epoc32/tools/qt";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    58
	/** Qt include folder for internal SDK installs - epocroot relative */
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    59
	private static final String QT_SDK_INC_PATH = "epoc32/include/mw";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    60
	
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    61
	/** qt subfolder under QT_INC_FOLDER */
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    62
	private static final String QT_FOLDER = "qt";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    63
	private static final String QT_MKSPECS = "mkspecs";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    64
	private static final String QT_QMAKE_WIN32 = "qmake.exe";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    65
	private static final String QT_QMAKE_UNIX = "qmake";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    66
	
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    67
	public static final String QT_DEFAULT_SDK_NAME = "<Default>";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    68
	
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    69
	private static List<QtSDK> qtSDKList = new ArrayList<QtSDK>();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    70
	
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    71
	// private data from QtProject.java
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    72
	private static final String QTVERSION = "com.trolltech.qtcppproject.properties.qtversion";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    73
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    74
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    75
	 * For the given Symbian SDK, test whether or not it qualifies for have Qt internally built.
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    76
	 * @param sdk - The Symbian SDK or source base to test
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    77
	 * @return - true if Qt is internally installed
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    78
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    79
	static private boolean isQtInternallyInstalled(ISymbianSDK sdk){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    80
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    81
		String epocRoot = sdk.getEPOCROOT();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    82
		if (new File(epocRoot + QT_SDK_BIN_PATH).exists() && 
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    83
			new File(epocRoot + QT_SDK_INC_PATH).exists() &&
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    84
			new File(epocRoot + QT_SDK_INC_PATH + File.separator + QT_FOLDER).exists() &&
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    85
			new File(epocRoot + QT_SDK_BIN_PATH + File.separator + QT_MKSPECS).exists() ) 
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    86
		{
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    87
			if (HostOS.IS_WIN32 && new File(epocRoot + QT_SDK_BIN_PATH + File.separator + QT_QMAKE_WIN32).exists()){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    88
				return true;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    89
			} else if (HostOS.IS_UNIX && new File(epocRoot + QT_SDK_BIN_PATH + File.separator + QT_QMAKE_UNIX).exists()){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    90
				return true;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    91
			}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    92
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    93
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    94
		return false;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    95
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
    96
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    97
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    98
	 * For the given Symbian SDK, get the Qt SDK name from the Qt global preferences.
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
    99
	 * @param sdk
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   100
	 * @return The Qt SDK display name in the preferences, null if not found
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   101
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   102
	static public String getQtSDKNameForSymbianSDK(ISymbianSDK sdk){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   103
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   104
		String epocRoot = sdk.getEPOCROOT();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   105
		File qtBinPath = new File (epocRoot + QT_SDK_BIN_PATH);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   106
		File qtIncPath = new File (epocRoot + QT_SDK_INC_PATH);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   107
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   108
		refreshQtStoredSDKs();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   109
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   110
		if (qtSDKList.size() == 0){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   111
			return null;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   112
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   113
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   114
		for (QtSDK qtSDK : qtSDKList){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   115
			File currBinPath = new File(qtSDK.binPath);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   116
			File currIncPath = new File(qtSDK.incPath);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   117
			
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   118
			if (currBinPath.equals(qtBinPath) && currIncPath.equals(qtIncPath)){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   119
				return qtSDK.name;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   120
			}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   121
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   122
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   123
		return null;
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   124
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   125
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   126
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   127
	 * Add a single Qt-SDK BIN and INLCUDE path to the Qt global preferences iff it is an internally built
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   128
	 * Qt-SDK and the BIN and INC path do not already exist.
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   129
	 * @param sdk
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   130
	 * @param makeDefault - Set the default name in the global Qt prefs
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   131
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   132
	static public void addQtSDKForSymbianSDK(ISymbianSDK sdk, boolean makeDefault){
945
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
   133
	
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   134
		refreshQtStoredSDKs();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   135
		if ((getQtSDKNameForSymbianSDK(sdk) == null) && isQtInternallyInstalled(sdk)){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   136
			IPath binPath = new Path(sdk.getEPOCROOT() + QT_SDK_BIN_PATH);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   137
			IPath incPath = new Path(sdk.getEPOCROOT() + QT_SDK_INC_PATH);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   138
			addQtSDK(sdk.getUniqueId(), binPath, incPath, makeDefault);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   139
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   140
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   141
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   142
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   143
	 * Add a Qt-SDK to the Qt global preferences
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   144
	 * @param name
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   145
	 * @param binPath
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   146
	 * @param incPath
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   147
	 * @param makeDefault
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   148
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   149
	static private void addQtSDK(String name, IPath binPath, IPath incPath, boolean makeDefault){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   150
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   151
		IPreferenceStore store = QtProjectPlugin.getDefault().getPreferenceStore();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   152
		int count = store.getInt(PreferenceConstants.QTVERSION_COUNT);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   153
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   154
		// Store settings using zero-index base
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   155
		store.setValue(PreferenceConstants.QTVERSION_NAME + "."
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   156
				+ Integer.toString(count), name);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   157
		store.setValue(PreferenceConstants.QTVERSION_BINPATH + "."
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   158
				+ Integer.toString(count), binPath.toOSString());
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   159
		store.setValue(PreferenceConstants.QTVERSION_INCLUDEPATH + "."
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   160
				+ Integer.toString(count), incPath.toOSString());
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   161
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   162
		if (makeDefault || count == 0){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   163
			store.setValue(PreferenceConstants.QTVERSION_DEFAULT, count);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   164
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   165
		
945
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
   166
		ResourcesPlugin.getPlugin().getLog().log(Logging.newStatus(QtCorePlugin.getDefault(), 
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
   167
						IStatus.INFO,
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
   168
						"New Qt-Symbian SDK added to Qt global preferences: " + name, //$NON-NLS-1$
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
   169
						null));
67437bfc7c6f Add ISymbianManagerLoadedHook - currently used to notify com.nokia.qt plugins that need to ensure that Qt SDKs have been scanned and added to the Qt preferences and that ICarbideBuildConfiguration listeners are added so the proper Qt-SDK can be set with build config changes. Scanned Qt SDKs are wrapped in a Job and added SDKs are reported to the Error log as Info.
timkelly
parents: 934
diff changeset
   170
		
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   171
		store.setValue(PreferenceConstants.QTVERSION_COUNT, count + 1); // # of table items, base is 1 (i.e. not zero)
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   172
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   173
		refreshQtStoredSDKs();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   174
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   175
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   176
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   177
	 * Update the internal list of Qt-SDKs found in the Qt global preferences
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   178
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   179
	static void refreshQtStoredSDKs(){
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   180
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   181
		qtSDKList.clear();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   182
		
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   183
		IPreferenceStore store = QtProjectPlugin.getDefault().getPreferenceStore();
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   184
		int count = store.getInt(PreferenceConstants.QTVERSION_COUNT);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   185
		for (int i = 0; i < count; i++) {
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   186
			String nameKey = PreferenceConstants.QTVERSION_NAME + "."
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   187
					+ Integer.toString(i);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   188
			String binpathKey = PreferenceConstants.QTVERSION_BINPATH + "."
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   189
					+ Integer.toString(i);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   190
			String includepathKey = PreferenceConstants.QTVERSION_INCLUDEPATH
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   191
					+ "." + Integer.toString(i);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   192
			String name = "";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   193
			String binPath = "";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   194
			String incPath = "";
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   195
			if (store.contains(nameKey)) {
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   196
				name = store.getString(nameKey);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   197
			}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   198
			if (store.contains(binpathKey)) {
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   199
				binPath = store.getString(binpathKey);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   200
			}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   201
			if (store.contains(includepathKey)) {
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   202
				incPath = store.getString(includepathKey);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   203
			}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   204
			
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   205
			QtSDK qtSDK = new QtSDK(name, incPath, binPath);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   206
			qtSDKList.add(qtSDK);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   207
		}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   208
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   209
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   210
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   211
	 * This method assumes the IProject has a Qt nature and sets the QTVERSION in the Qt project settings panel
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   212
	 * @param project
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   213
	 * @param qtSDKName
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   214
	 * @throws CoreException
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   215
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   216
	public static void setDefaultQtSDKForProject(IProject project, String qtSDKName) throws CoreException{
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   217
		project.setPersistentProperty(new QualifiedName("", QTVERSION), qtSDKName);
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   218
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   219
	
947
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   220
	/**
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   221
	 * Assuming a Qt project, this retrieves the Qt project setting for the currently set Qt-SDK
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   222
	 * @param project
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   223
	 * @return
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   224
	 * @throws CoreException
cb7b077cee27 add comments for new code under bug 10681.
timkelly
parents: 945
diff changeset
   225
	 */
934
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   226
	public static String getDefaultQtSDKForProject(IProject project) throws CoreException{
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   227
		return project.getPersistentProperty(new QualifiedName("", QTVERSION));
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   228
	}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   229
	
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   230
}
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   231
967f619cd59f add QtSDKUtils. Use to read/write pref values from Qt global and project preferences.
timkelly
parents:
diff changeset
   232