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.
authortimkelly
Fri, 12 Feb 2010 09:56:50 -0600
changeset 945 67437bfc7c6f
parent 934 967f619cd59f
child 946 18229ce040aa
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.
core/com.nokia.carbide.cpp.sdk.core/plugin.xml
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISDKManagerLoadedHook.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java
qt/com.nokia.carbide.cpp.qt.core/plugin.xml
qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtCorePlugin.java
qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtSDKUtils.java
qt/com.nokia.carbide.cpp.qt.ui/plugin.xml
qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/QtUIPlugin.java
--- a/core/com.nokia.carbide.cpp.sdk.core/plugin.xml	Thu Feb 11 11:47:58 2010 -0600
+++ b/core/com.nokia.carbide.cpp.sdk.core/plugin.xml	Fri Feb 12 09:56:50 2010 -0600
@@ -30,5 +30,7 @@
       </scriptableClass>
    </extension>
 
+  <extension-point id="sdkManagerLoadedHook" name="SDKManager Available Notification"/>
+
 </plugin>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/ISDKManagerLoadedHook.java	Fri Feb 12 09:56:50 2010 -0600
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2010 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.
+*
+*/
+package com.nokia.carbide.cpp.internal.api.sdk;
+
+/**
+ * Convenience interface for extension-point clients to know when the Carbide Symbian SDK plug-in has loaded.
+ */
+public interface ISDKManagerLoadedHook {
+	
+	/**
+	 * Feature to notify that SDKs are loade
+	 */
+	public void symbianSDKManagerLoaded();
+	
+	
+}
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java	Thu Feb 11 11:47:58 2010 -0600
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/AbstractSDKManager.java	Fri Feb 12 09:56:50 2010 -0600
@@ -36,6 +36,10 @@
 
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
@@ -51,6 +55,7 @@
 import com.nokia.carbide.cpp.internal.api.sdk.BuildPlat;
 import com.nokia.carbide.cpp.internal.api.sdk.ICarbideDevicesXMLChangeListener;
 import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerInternal;
+import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerLoadedHook;
 import com.nokia.carbide.cpp.internal.api.sdk.SBSv2Utils;
 import com.nokia.carbide.cpp.internal.api.sdk.SDKManagerInternalAPI;
 import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContextDataCache;
@@ -91,6 +96,11 @@
 	protected static final String[] knownRVCTVersions = {"3.1", "3.0", "2.2", "2.1"};
 	protected Version sbsV2Version;
 	
+	static boolean sdkHookExtenstionsNotified;
+	public static final String SDK_MANAGER_LOADED_HOOK = SDKCorePlugin.PLUGIN_ID
+	+ ".sdkManagerLoadedHook"; //$NON-NLS-1$
+	
+	
 	/**
 	 * Minimum SBSv2 version supported with Carbide
 	 */
@@ -170,6 +180,13 @@
 		// tell others about it
 		fireInstalledSdkChanged(SDKChangeEventType.eSDKScanned);
 		scanCarbideSDKCache();
+		
+		// Notify any plugins that want to know if the SDKManager has scanned plugins.
+		if (!sdkHookExtenstionsNotified) {
+			notifySDKManagerLoaded();
+			sdkHookExtenstionsNotified = true;
+		}
+		
 	}
 
 	/**
@@ -713,5 +730,41 @@
 		return MINIMUM_RAPTOR_VERSION;
 	}
 	
+	/**
+	 * Find clients of the 'sdkManagerLoadedHook' extension point so their plug-ins can be loaded
+	 */
+	private void notifySDKManagerLoaded() {
+
+		ISDKManagerLoadedHook sdkHook = null;
+		IExtensionRegistry er = Platform.getExtensionRegistry();
+		IExtensionPoint ep = er.getExtensionPoint(SDK_MANAGER_LOADED_HOOK);
+		IExtension[] extensions = ep.getExtensions();
+
+		for (int i = 0; i < extensions.length; i++) {
+			IExtension extension = extensions[i];
+			IConfigurationElement[] ces = extension.getConfigurationElements();
+			if (ces != null && ces.length >= 1) {
+				IConfigurationElement providerElement = ces[0];
+				String name = providerElement.getAttribute("name"); //$NON-NLS-1$
+				if (name != null) {
+					if (providerElement.getAttribute("class") != null) { //$NON-NLS-1$
+
+						try {
+							sdkHook = (ISDKManagerLoadedHook) providerElement
+									.createExecutableExtension("class"); //$NON-NLS-1$
+							sdkHook.symbianSDKManagerLoaded();
+						} catch (CoreException e) {
+							// ignore
+							// e.printStackTrace();
+						}
+					}
+				}
+
+			}
+		}
+		return;
+
+	}
+	
 	
 }
--- a/qt/com.nokia.carbide.cpp.qt.core/plugin.xml	Thu Feb 11 11:47:58 2010 -0600
+++ b/qt/com.nokia.carbide.cpp.qt.core/plugin.xml	Fri Feb 12 09:56:50 2010 -0600
@@ -3,7 +3,12 @@
 <plugin>
 
    <extension
-         point="org.eclipse.ui.startup">
+         id="com.nokia.carbide.cpp.qt.core.symbianSDKMgrHook"
+         name="Symbian SDK Manager Hook"
+         point="com.nokia.carbide.cpp.sdk.core.sdkManagerLoadedHook">
+          <provider
+            class="com.nokia.carbide.cpp.internal.qt.core.QtCorePlugin"
+            name="com.nokia.carbide.cpp.internal.qt.core.SDK-HookClient"/>
    </extension>
 
 </plugin>
\ No newline at end of file
--- a/qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtCorePlugin.java	Thu Feb 11 11:47:58 2010 -0600
+++ b/qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtCorePlugin.java	Fri Feb 12 09:56:50 2010 -0600
@@ -23,14 +23,19 @@
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.osgi.framework.BundleContext;
 
+import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerLoadedHook;
+import com.nokia.carbide.cpp.sdk.core.ICarbideInstalledSDKChangeListener;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
 import com.trolltech.qtcppproject.QtNature;
 
-public class QtCorePlugin extends Plugin {
+public class QtCorePlugin extends Plugin implements ISDKManagerLoadedHook, ICarbideInstalledSDKChangeListener {
 
 	// The plug-in ID
 	public static final String PLUGIN_ID = "com.nokia.carbide.cpp.qt.core"; //$NON-NLS-1$
@@ -53,7 +58,7 @@
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
 		plugin = this;
-		scanForQtSDKs();
+		SDKCorePlugin.getSDKManager().addInstalledSdkChangeListener(this);
 	}
 
 	/*
@@ -61,6 +66,7 @@
 	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
 	 */
 	public void stop(BundleContext context) throws Exception {
+		SDKCorePlugin.getSDKManager().removeInstalledSdkChangeListener(this);
 		plugin = null;
 		super.stop(context);
 	}
@@ -101,10 +107,30 @@
 	}
 	
 	private void scanForQtSDKs(){
-		List<ISymbianSDK> sdkList = SDKCorePlugin.getSDKManager().getSDKList();
-		for (ISymbianSDK sdk : sdkList){
-			QtSDKUtils.addQtSDKForSymbianSDK(sdk, false);
-		}
+		
+		final String jobBaseText = "Checking for Qt installed in Symbian SDKs";
+		Job job = new Job(jobBaseText) {
+
+			@Override
+			protected IStatus run(IProgressMonitor monitor) {
+				List<ISymbianSDK> sdkList = SDKCorePlugin.getSDKManager().getSDKList();
+				for (ISymbianSDK sdk : sdkList){
+					QtSDKUtils.addQtSDKForSymbianSDK(sdk, false);
+				}
+				
+				return Status.OK_STATUS;
+			} 
+		
+		};
+		job.schedule();
+	}
+
+	public void symbianSDKManagerLoaded() {
+		scanForQtSDKs();
+	}
+
+	public void installedSdkChanged(SDKChangeEventType eventType) {
+		scanForQtSDKs();
 	}
 
 }
--- a/qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtSDKUtils.java	Thu Feb 11 11:47:58 2010 -0600
+++ b/qt/com.nokia.carbide.cpp.qt.core/src/com/nokia/carbide/cpp/internal/qt/core/QtSDKUtils.java	Fri Feb 12 09:56:50 2010 -0600
@@ -15,16 +15,22 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Logger;
 
+import org.eclipse.core.internal.runtime.Log;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.jface.preference.IPreferenceStore;
 
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
 import com.nokia.cpp.internal.api.utils.core.HostOS;
+import com.nokia.cpp.internal.api.utils.core.Logging;
 import com.trolltech.qtcppproject.QtProjectPlugin;
 import com.trolltech.qtcppproject.preferences.PreferenceConstants;
 
@@ -105,7 +111,7 @@
 	}
 	
 	static public void addQtSDKForSymbianSDK(ISymbianSDK sdk, boolean makeDefault){
-		
+	
 		refreshQtStoredSDKs();
 		if ((getQtSDKNameForSymbianSDK(sdk) == null) && isQtInternallyInstalled(sdk)){
 			IPath binPath = new Path(sdk.getEPOCROOT() + QT_SDK_BIN_PATH);
@@ -131,6 +137,11 @@
 			store.setValue(PreferenceConstants.QTVERSION_DEFAULT, count);
 		}
 		
+		ResourcesPlugin.getPlugin().getLog().log(Logging.newStatus(QtCorePlugin.getDefault(), 
+						IStatus.INFO,
+						"New Qt-Symbian SDK added to Qt global preferences: " + name, //$NON-NLS-1$
+						null));
+		
 		store.setValue(PreferenceConstants.QTVERSION_COUNT, count + 1); // # of table items, base is 1 (i.e. not zero)
 		
 		refreshQtStoredSDKs();
--- a/qt/com.nokia.carbide.cpp.qt.ui/plugin.xml	Thu Feb 11 11:47:58 2010 -0600
+++ b/qt/com.nokia.carbide.cpp.qt.ui/plugin.xml	Fri Feb 12 09:56:50 2010 -0600
@@ -88,8 +88,14 @@
       </modifier>
    </extension>
    
-   <extension
-         point="org.eclipse.ui.startup">
+      <extension
+         id="com.nokia.carbide.cpp.qt.ui.symbianSDKMgrHook"
+         name="Symbian SDK Manager Hook"
+         point="com.nokia.carbide.cpp.sdk.core.sdkManagerLoadedHook">
+          <provider
+            class="com.nokia.carbide.cpp.internal.qt.ui.QtUIPlugin"
+            name="com.nokia.carbide.cpp.internal.qt.core.SDK-HookClient"/>
    </extension>
+   
 
 </plugin>
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/QtUIPlugin.java	Thu Feb 11 11:47:58 2010 -0600
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/QtUIPlugin.java	Fri Feb 12 09:56:50 2010 -0600
@@ -37,11 +37,12 @@
 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
 import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
 import com.nokia.carbide.cdt.internal.api.builder.SISBuilderInfo2;
+import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerLoadedHook;
 import com.nokia.carbide.cpp.internal.qt.core.QtCorePlugin;
 import com.nokia.carbide.cpp.internal.qt.core.QtSDKUtils;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 
-public class QtUIPlugin extends AbstractUIPlugin implements ICarbideConfigurationChangedListener {
+public class QtUIPlugin extends AbstractUIPlugin implements ICarbideConfigurationChangedListener, ISDKManagerLoadedHook {
 
 	// The plug-in ID
 	public static final String PLUGIN_ID = "com.nokia.carbide.cpp.qt.ui"; //$NON-NLS-1$
@@ -62,7 +63,6 @@
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
 		plugin = this;
-		CarbideBuilderPlugin.addBuildConfigChangedListener(this);
 	}
 
 	/*
@@ -158,7 +158,8 @@
 			try {
 				String qtSDKName = QtSDKUtils.getQtSDKNameForSymbianSDK(currentConfig.getSDK());
 				// If qtSDK is not internally installed or <Default> is set, don't change anything
-				if (qtSDKName == null || QtSDKUtils.getDefaultQtSDKForProject(project) == null) {
+				String currQtSDK = QtSDKUtils.getDefaultQtSDKForProject(project);
+				if (qtSDKName == null || currQtSDK == null || currQtSDK.equals(QtSDKUtils.QT_DEFAULT_SDK_NAME)) {
 					return;
 				}
 				
@@ -170,4 +171,8 @@
 		}
 		
 	}
+
+	public void symbianSDKManagerLoaded() {
+		CarbideBuilderPlugin.addBuildConfigChangedListener(this);
+	}
 }