debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java
changeset 1301 e1c5d5512540
parent 956 d1e221a2875f
child 1384 10b788ab16fe
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java	Tue Apr 27 11:32:39 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java	Tue Apr 27 10:40:15 2010 -0500
@@ -30,6 +30,7 @@
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Shell;
@@ -54,6 +55,7 @@
 	private String configurationName;
 	private List<AbstractLaunchWizard> wizards = new ArrayList<AbstractLaunchWizard>();
 	private String categoryId;
+	private AbstractLaunchWizard selectedWizard;
 	
 	public LaunchCreationWizard(IProject project, String configurationName, 
 										List<IPath> mmps, List<IPath> exes, IPath defaultExecutable,  
@@ -94,14 +96,13 @@
 			}
 		}
 		
-		if (fWizardSelectionPage != null) {
-			AbstractLaunchWizard wizard = ((AbstractLaunchWizard) fWizardSelectionPage.getSelectedWizard());
-			wizard.performFinish();
-			Pair<IPath, IPath> exeAndMmp = wizard.getSelectedExeMmpPair();
-			IPath processToLaunchTargetPath = wizard.getProcessToLaunchTargetPath();
+		if (selectedWizard != null) {
+			selectedWizard.performFinish();
+			Pair<IPath, IPath> exeAndMmp = selectedWizard.getSelectedExeMmpPair();
+			IPath processToLaunchTargetPath = selectedWizard.getProcessToLaunchTargetPath();
 	    	launchConfig = 
-	    		fWizardSelectionPage.getSelectedWizard().createLaunchConfiguration(exeAndMmp.second, exeAndMmp.first, processToLaunchTargetPath);
-	    	shouldOpenLaunchDialog = fWizardSelectionPage.getSelectedWizard().shouldOpenLaunchConfigurationDialog();
+	    		selectedWizard.createLaunchConfiguration(exeAndMmp.second, exeAndMmp.first, processToLaunchTargetPath);
+	    	shouldOpenLaunchDialog = selectedWizard.shouldOpenLaunchConfigurationDialog();
 		}
 		
 		return true;
@@ -114,7 +115,21 @@
     		addPage(fEmulationSummaryPage);
     	} 
     	else if (fWizardSelectionPage != null) {
-            addPage(fWizardSelectionPage);
+    		List<AbstractLaunchWizard> wizards = getWizardsForCategory(getCategoryId());
+    		if (wizards.size() > 1) {
+    			addPage(fWizardSelectionPage);
+    		} else {
+    			// just directly "select" the single wizard and add its pages instead of using
+    			// a wizard selection node, to avoid a needless intermediate selection page
+    			AbstractLaunchWizard wizard = wizards.get(0);
+    			for (IWizardPage page : wizard.getPages()) {
+    				page.setWizard(null);
+    				addPage(page);
+    			}
+    			setWindowTitle(wizard.getWindowTitle());
+    			fWizardSelectionPage = null;
+    			selectedWizard = wizard;
+    		}
     	}
     }
     
@@ -159,8 +174,8 @@
 		return categoryId;
 	}
 	
-	public List<Wizard> getWizardsForCategory(String categoryId) {
-		List<Wizard> wizardsInCatgegory = new ArrayList<Wizard>();
+	public List<AbstractLaunchWizard> getWizardsForCategory(String categoryId) {
+		List<AbstractLaunchWizard> wizardsInCatgegory = new ArrayList<AbstractLaunchWizard>();
 		for (AbstractLaunchWizard wizard : wizards) {
 			if (wizard.supportsCategory(categoryId)) {
 				wizardsInCatgegory.add(wizard);
@@ -211,4 +226,8 @@
 			}
 		}
 	}
+
+	public void setSelectedWizard(AbstractLaunchWizard selectedWizard) {
+		this.selectedWizard = selectedWizard;
+	}
 }