debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/SystemTRKLaunchWizard.java
changeset 2075 632d9ed15b20
parent 2074 26425f5ffb07
child 2077 d930aa7f4428
equal deleted inserted replaced
2074:26425f5ffb07 2075:632d9ed15b20
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 package com.nokia.cdt.internal.debug.launch.wizard;
       
    18 
       
    19 import com.nokia.cdt.debug.cw.symbian.SettingsData;
       
    20 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
       
    21 import com.nokia.cdt.internal.debug.launch.ui.RunModeMainTab;
       
    22 import com.nokia.cdt.internal.debug.launch.wizard.MainExecutableSelectionWizardPage.IPathValidator;
       
    23 
       
    24 import org.eclipse.core.resources.IProject;
       
    25 import org.eclipse.core.runtime.CoreException;
       
    26 import org.eclipse.core.runtime.IPath;
       
    27 import org.eclipse.debug.core.DebugPlugin;
       
    28 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
       
    29 
       
    30 import java.util.List;
       
    31 
       
    32 public class SystemTRKLaunchWizard extends AbstractLaunchWizard {
       
    33     private BuildOptionsSelectionPage fBuildOptionsSelectionPage;
       
    34     private TRKConnectionWizardPage fMainPage;
       
    35 	private boolean hasFinished = false;
       
    36 
       
    37 	public SystemTRKLaunchWizard(List<IPath> mmps, List<IPath> exes, IPath defaultExecutable, IProject project, String configurationName) {
       
    38 		super(project, configurationName, mmps, exes, defaultExecutable, true, true);
       
    39 		setWindowTitle(Messages.getString("SystemTRKLaunchWizard.1")); //$NON-NLS-1$
       
    40     }
       
    41 
       
    42 	@Override
       
    43 	public String getLaunchTypeID() {
       
    44 		return SettingsData.SYS_TRK_LAUNCH_TYPE_ID;
       
    45 	}
       
    46 
       
    47 	@Override
       
    48 	public boolean supportsCategory(String categoryId) {
       
    49 		return categoryId.equals(PHONE_CATEGORY_ID);
       
    50 	}
       
    51 
       
    52     public boolean performFinish() {
       
    53     	hasFinished = true;
       
    54     	return true;
       
    55     }
       
    56  
       
    57     public void addPages() {
       
    58     	super.addPages();
       
    59         fBuildOptionsSelectionPage = new BuildOptionsSelectionPage();
       
    60         fMainPage = new TRKConnectionWizardPage(this,
       
    61         		LaunchPlugin.getDebugServiceId());
       
    62         addPage(fBuildOptionsSelectionPage);
       
    63         addPage(fMainPage);
       
    64         addPage(getSummaryPage());
       
    65 	    getBinarySelectionPage().setPathValidator(new IPathValidator() {
       
    66 			public String isValidPath(IPath path) {
       
    67 				return RunModeMainTab.isRemoteTextValid(path.toOSString());
       
    68 			}
       
    69 	    });
       
    70     }
       
    71 
       
    72     public String toString() {
       
    73     	return Messages.getString("SystemTRKLaunchWizard.2"); //$NON-NLS-1$
       
    74     }
       
    75     
       
    76     public String getDescription() {
       
    77     	return Messages.getString("SystemTRKLaunchWizard.3"); //$NON-NLS-1$
       
    78     }
       
    79     
       
    80     public ILaunchConfigurationWorkingCopy createLaunchConfiguration(IPath mmpPath, IPath exePath, IPath processToLaunchTargetPath) {
       
    81     	// if we haven't finished then don't create anything
       
    82     	if (!hasFinished) {
       
    83     		return null;
       
    84     	}
       
    85 
       
    86     	ILaunchConfigurationWorkingCopy config = null;
       
    87     	try {
       
    88     		// create our config
       
    89     		config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(SettingsData.SYS_TRK_LAUNCH_TYPE_ID).newInstance(null, getConfigName());
       
    90     		
       
    91     		// set the default values
       
    92     		SettingsData.setDefaults(config, SettingsData.LaunchConfig_SysTRK, getProject(), mmpPath, exePath);
       
    93     		if (processToLaunchTargetPath != null)
       
    94     			SettingsData.setProcessToLaunch(config, processToLaunchTargetPath);
       
    95     		
       
    96     		// now let the wizard pages update values 
       
    97     		fBuildOptionsSelectionPage.updateConfiguration(config);
       
    98     		fMainPage.updateConfiguration(config);
       
    99     		
       
   100 		} catch (CoreException e) {
       
   101 			e.printStackTrace();
       
   102 		}
       
   103 		return config;
       
   104     }
       
   105 
       
   106 }