debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java
branchRCL_2_4
changeset 1299 c6abac939087
parent 953 68b6a294ab01
equal deleted inserted replaced
1289:7c4a4568b9c5 1299:c6abac939087
    28 import org.eclipse.core.runtime.IPath;
    28 import org.eclipse.core.runtime.IPath;
    29 import org.eclipse.core.runtime.IStatus;
    29 import org.eclipse.core.runtime.IStatus;
    30 import org.eclipse.core.runtime.Platform;
    30 import org.eclipse.core.runtime.Platform;
    31 import org.eclipse.debug.core.DebugPlugin;
    31 import org.eclipse.debug.core.DebugPlugin;
    32 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
    32 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
       
    33 import org.eclipse.jface.wizard.IWizardPage;
    33 import org.eclipse.jface.wizard.Wizard;
    34 import org.eclipse.jface.wizard.Wizard;
    34 import org.eclipse.jface.wizard.WizardDialog;
    35 import org.eclipse.jface.wizard.WizardDialog;
    35 import org.eclipse.swt.widgets.Shell;
    36 import org.eclipse.swt.widgets.Shell;
    36 
    37 
    37 import com.nokia.carbide.cpp.ui.CarbideUIPlugin;
    38 import com.nokia.carbide.cpp.ui.CarbideUIPlugin;
    52 	private boolean shouldOpenLaunchDialog;
    53 	private boolean shouldOpenLaunchDialog;
    53 	private IProject project;
    54 	private IProject project;
    54 	private String configurationName;
    55 	private String configurationName;
    55 	private List<AbstractLaunchWizard> wizards = new ArrayList<AbstractLaunchWizard>();
    56 	private List<AbstractLaunchWizard> wizards = new ArrayList<AbstractLaunchWizard>();
    56 	private String categoryId;
    57 	private String categoryId;
       
    58 	private AbstractLaunchWizard selectedWizard;
    57 	
    59 	
    58 	public LaunchCreationWizard(IProject project, String configurationName, 
    60 	public LaunchCreationWizard(IProject project, String configurationName, 
    59 										List<IPath> mmps, List<IPath> exes, IPath defaultExecutable,  
    61 										List<IPath> mmps, List<IPath> exes, IPath defaultExecutable,  
    60 										boolean isEmulation, boolean emulatorOnly, String mode) throws Exception {
    62 										boolean isEmulation, boolean emulatorOnly, String mode) throws Exception {
    61 		this.project = project;
    63 		this.project = project;
    92 			} catch (CoreException e) {
    94 			} catch (CoreException e) {
    93 				LaunchPlugin.log(e);
    95 				LaunchPlugin.log(e);
    94 			}
    96 			}
    95 		}
    97 		}
    96 		
    98 		
    97 		if (fWizardSelectionPage != null) {
    99 		if (selectedWizard != null) {
    98 			AbstractLaunchWizard wizard = ((AbstractLaunchWizard) fWizardSelectionPage.getSelectedWizard());
   100 			selectedWizard.performFinish();
    99 			wizard.performFinish();
   101 			Pair<IPath, IPath> exeAndMmp = selectedWizard.getSelectedExeMmpPair();
   100 			Pair<IPath, IPath> exeAndMmp = wizard.getSelectedExeMmpPair();
   102 			IPath processToLaunchTargetPath = selectedWizard.getProcessToLaunchTargetPath();
   101 			IPath processToLaunchTargetPath = wizard.getProcessToLaunchTargetPath();
       
   102 	    	launchConfig = 
   103 	    	launchConfig = 
   103 	    		fWizardSelectionPage.getSelectedWizard().createLaunchConfiguration(exeAndMmp.second, exeAndMmp.first, processToLaunchTargetPath);
   104 	    		selectedWizard.createLaunchConfiguration(exeAndMmp.second, exeAndMmp.first, processToLaunchTargetPath);
   104 	    	shouldOpenLaunchDialog = fWizardSelectionPage.getSelectedWizard().shouldOpenLaunchConfigurationDialog();
   105 	    	shouldOpenLaunchDialog = selectedWizard.shouldOpenLaunchConfigurationDialog();
   105 		}
   106 		}
   106 		
   107 		
   107 		return true;
   108 		return true;
   108     }
   109     }
   109  
   110  
   112     		addPage(fBinarySelectionPage);
   113     		addPage(fBinarySelectionPage);
   113     		addPage(fBuildOptionsSelectionPage);
   114     		addPage(fBuildOptionsSelectionPage);
   114     		addPage(fEmulationSummaryPage);
   115     		addPage(fEmulationSummaryPage);
   115     	} 
   116     	} 
   116     	else if (fWizardSelectionPage != null) {
   117     	else if (fWizardSelectionPage != null) {
   117             addPage(fWizardSelectionPage);
   118     		List<AbstractLaunchWizard> wizards = getWizardsForCategory(getCategoryId());
       
   119     		if (wizards.size() > 1) {
       
   120     			addPage(fWizardSelectionPage);
       
   121     		} else {
       
   122     			// just directly "select" the single wizard and add its pages instead of using
       
   123     			// a wizard selection node, to avoid a needless intermediate selection page
       
   124     			AbstractLaunchWizard wizard = wizards.get(0);
       
   125     			for (IWizardPage page : wizard.getPages()) {
       
   126     				page.setWizard(null);
       
   127     				addPage(page);
       
   128     			}
       
   129     			setWindowTitle(wizard.getWindowTitle());
       
   130     			fWizardSelectionPage = null;
       
   131     			selectedWizard = wizard;
       
   132     		}
   118     	}
   133     	}
   119     }
   134     }
   120     
   135     
   121     @Override
   136     @Override
   122 	public boolean needsPreviousAndNextButtons() {
   137 	public boolean needsPreviousAndNextButtons() {
   157 	
   172 	
   158 	public String getCategoryId() {
   173 	public String getCategoryId() {
   159 		return categoryId;
   174 		return categoryId;
   160 	}
   175 	}
   161 	
   176 	
   162 	public List<Wizard> getWizardsForCategory(String categoryId) {
   177 	public List<AbstractLaunchWizard> getWizardsForCategory(String categoryId) {
   163 		List<Wizard> wizardsInCatgegory = new ArrayList<Wizard>();
   178 		List<AbstractLaunchWizard> wizardsInCatgegory = new ArrayList<AbstractLaunchWizard>();
   164 		for (AbstractLaunchWizard wizard : wizards) {
   179 		for (AbstractLaunchWizard wizard : wizards) {
   165 			if (wizard.supportsCategory(categoryId)) {
   180 			if (wizard.supportsCategory(categoryId)) {
   166 				wizardsInCatgegory.add(wizard);
   181 				wizardsInCatgegory.add(wizard);
   167 			}
   182 			}
   168 		}
   183 		}
   209 						IStatus.ERROR,
   224 						IStatus.ERROR,
   210 						"Unable to load launchWizardExtension extension from " + extension.getContributor().getName()));
   225 						"Unable to load launchWizardExtension extension from " + extension.getContributor().getName()));
   211 			}
   226 			}
   212 		}
   227 		}
   213 	}
   228 	}
       
   229 
       
   230 	public void setSelectedWizard(AbstractLaunchWizard selectedWizard) {
       
   231 		this.selectedWizard = selectedWizard;
       
   232 	}
   214 }
   233 }