For PlatSim Stop Mode launch shortcut, skip the first selection page when only one wizard is available.
authorEd Swartz <ed.swartz@nokia.com>
Tue, 27 Apr 2010 10:40:15 -0500
changeset 1301 e1c5d5512540
parent 1296 9d0235f04d6d
child 1302 012040f34296
child 1303 a672cbed3014
For PlatSim Stop Mode launch shortcut, skip the first selection page when only one wizard is available.
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchWizardSelectionPage.java
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Tue Apr 27 11:32:39 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java	Tue Apr 27 10:40:15 2010 -0500
@@ -346,7 +346,7 @@
 				openLaunchConfigDialog = wizard.shouldOpenLaunchConfigurationDialog();
 			}
 			catch (Exception e) {
-				throw new CoreException(new Status(IStatus.ERROR, getUniqueIdentifier(), 0, e.getMessage(), null )); //$NON-NLS-1$
+				throw new CoreException(new Status(IStatus.ERROR, getUniqueIdentifier(), 0, e.getMessage(), e )); //$NON-NLS-1$
 			}
 		}
 		
--- 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;
+	}
 }
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchWizardSelectionPage.java	Tue Apr 27 11:32:39 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchWizardSelectionPage.java	Tue Apr 27 10:40:15 2010 -0500
@@ -47,7 +47,7 @@
 	private LaunchCreationWizard mainWizard;
 	private FormBrowser descriptionBrowser;
 	private TableViewer wizardSelectionTableViewer = null;
-	private ILaunchWizard selectedWizard = null;
+	private AbstractLaunchWizard selectedWizard = null;
 	private boolean inputChanged = false;
 	
 	public LaunchWizardSelectionPage(LaunchCreationWizard mainWizard, List<IPath> mmps, List<IPath> exes, IPath defaultExecutable, IProject project, String configurationName, String mode) throws Exception {
@@ -110,6 +110,8 @@
 		});
 		wizardSelectionTableViewer.addSelectionChangedListener(this);
 
+		wizardSelectionTableViewer.setInput(mainWizard.getWizardsForCategory(mainWizard.getCategoryId()));
+
 		createDescriptionIn(sashForm);
 		sashForm.setWeights(new int[] {75, 25});
 
@@ -128,12 +130,14 @@
 		setErrorMessage(null);
 		IStructuredSelection selection = (IStructuredSelection) event.getSelection();
 		Object selectedObject = null;
-		Iterator iter = selection.iterator();
+		Iterator<?> iter = selection.iterator();
 		if (iter.hasNext()) {
 			selectedObject = iter.next();
-			if (selectedObject instanceof ILaunchWizard)
-				selectedWizard = (ILaunchWizard)selectedObject;
+			if (selectedObject instanceof AbstractLaunchWizard)
+				selectedWizard = (AbstractLaunchWizard)selectedObject;
 		}
+		mainWizard.setSelectedWizard(selectedWizard);
+		
 		if (selectedWizard == null) {
 			setDescriptionText(""); //$NON-NLS-1$
 			setSelectedNode(null);
@@ -146,14 +150,16 @@
 	public void setVisible(boolean visible) {
 		super.setVisible(visible);
 		if (visible && wizardSelectionTableViewer != null) {
-			wizardSelectionTableViewer.setInput(mainWizard.getWizardsForCategory(mainWizard.getCategoryId()));
 			if (inputChanged) {
 				wizardSelectionTableViewer.setSelection(new StructuredSelection(wizardSelectionTableViewer.getElementAt(0)), true);
 			}
 			wizardSelectionTableViewer.getTable().setFocus();
 		}
 	}
+	
+	
 
+	@SuppressWarnings("unchecked")
 	public Object[] getElements(Object inputElement) {
 		List<Wizard> wizards = (List<Wizard>)inputElement;
 		return wizards.toArray();