Don't allow Qt project to be created when SDKs on different drives are selected (Win32 only)
authortimkelly
Fri, 10 Sep 2010 15:05:16 -0500
changeset 1983 da7da111790d
parent 1982 22a3de59a31b
child 1984 0dc4caef98fa
Don't allow Qt project to be created when SDKs on different drives are selected (Win32 only)
qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/Messages.java
qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/QtBuildTargetsPage.java
qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/messages.properties
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/Messages.java	Fri Sep 10 09:38:24 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/Messages.java	Fri Sep 10 15:05:16 2010 -0500
@@ -127,6 +127,8 @@
 	
 	public static String PerspectiveSwitchDialog_RememberDecisionText;
 	
+	public static String QtBuildTargetsPage_mismatchedDriveSpec;
+	
 	static {
 		// initialize resource bundle
 		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/QtBuildTargetsPage.java	Fri Sep 10 09:38:24 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/QtBuildTargetsPage.java	Fri Sep 10 15:05:16 2010 -0500
@@ -16,6 +16,10 @@
 */
 package com.nokia.carbide.cpp.internal.qt.ui.wizard;
 
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -24,7 +28,10 @@
 
 import com.nokia.carbide.cpp.internal.qt.core.QtConfigFilter;
 import com.nokia.carbide.cpp.internal.qt.core.QtSDKFilter;
+import com.nokia.carbide.cpp.project.ui.sharedui.NewProjectPage;
+import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 import com.nokia.carbide.cpp.sdk.ui.shared.BuildTargetsPage;
+import com.nokia.cpp.internal.api.utils.core.HostOS;
 
 
 public class QtBuildTargetsPage extends BuildTargetsPage {
@@ -73,6 +80,47 @@
 				setErrorMessage(Messages.QtBuildTargetsPage_noQtConfigsError);
 			return false;
 		}
+		
+		if (HostOS.IS_WIN32){
+			if ((viewer.getCheckedElements()).length > 1) {
+				Object[] checkedElements = viewer.getCheckedElements();
+				for (Object obj : checkedElements){
+					TreeNode node = (TreeNode)obj;
+					if (node.getValue() instanceof ISymbianBuildContext) {
+						String epocRoot = ((ISymbianBuildContext)node.getValue()).getSDK().getEPOCROOT();
+						IPath path = new Path(epocRoot);
+						// This supports both the Qt project wizard and .pro file import wizard
+						// So we need to check wizard page instances to figure out which wizard we are running
+						String newProjectPageName = com.nokia.carbide.cpp.internal.project.ui.Messages.getString("NewProjectPage.Name");
+						IWizardPage npwp = this.getWizard().getPage(newProjectPageName);
+						if (npwp == null){
+							newProjectPageName = com.nokia.carbide.cpp.internal.qt.ui.wizard.Messages.QtProFileSelectionPage_title;
+							npwp = this.getWizard().getPage(newProjectPageName);
+						}
+						
+						if (npwp != null){
+							IPath projectLocation = null;
+							if (npwp instanceof NewProjectPage){
+								NewProjectPage npp = (NewProjectPage)this.getWizard().getStartingPage();
+								projectLocation = npp.getLocationPath();
+							}
+							else if (npwp instanceof QtProFileSelectionPage){
+								QtProFileSelectionPage qtpfsp = (QtProFileSelectionPage)this.getWizard().getStartingPage();
+								projectLocation = new Path(qtpfsp.getProFilePath());
+							}
+							
+							if (projectLocation != null){
+								if (!projectLocation.getDevice().equalsIgnoreCase(path.getDevice())){
+									setErrorMessage(Messages.QtBuildTargetsPage_mismatchedDriveSpec);
+									return false;
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		
 		return super.validatePage();
 	}	
 }
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/messages.properties	Fri Sep 10 09:38:24 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/messages.properties	Fri Sep 10 15:05:16 2010 -0500
@@ -52,7 +52,7 @@
 QtBuildTargetsPage_filterCheckboxText=Filter build configurations that don't contain Qt support
 QtBuildTargetsPage_filterCheckboxToolTip=Filters any build configurations that don't contain the Qt libraries
 QtBuildTargetsPage_noQtConfigsError=No SDK's were found that contain Qt support
-
+QtBuildTargetsPage_mismatchedDriveSpec=Qt projects must exist on the same drive spec as the selected SDK. Please choose a different SDK or change the project location.
 PerspectiveSwitchDialog_Title=Confirm Perspective Switch
 PerspectiveSwitchDialog_Query=The type of project you are creating is associated with the Qt C++ perspective.\n\nDo you want to switch to this perspective now?
 PerspectiveSwitchDialog_RememberDecisionText=&Remember my decision