debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java
author dadubrow
Wed, 10 Mar 2010 15:28:22 -0600
branchRCL_2_4
changeset 1091 9ce8893d737f
parent 1068 21b582a02214
child 1191 0523013ddf00
permissions -rw-r--r--
Fix 10861
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     1
/*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     3
* All rights reserved.
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     4
* This component and the accompanying materials are made available
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     6
* which accompanies this distribution, and is available
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     8
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     9
* Initial Contributors:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    11
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    12
* Contributors:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    13
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    14
* Description: 
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    15
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    16
*/
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    17
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    18
package com.nokia.cdt.internal.debug.launch.newwizard;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    19
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
    20
import java.util.ArrayList;
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    21
import java.util.Collection;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    22
import java.util.List;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    23
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    24
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    25
import org.eclipse.core.resources.IProject;
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    26
import org.eclipse.core.runtime.CoreException;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    27
import org.eclipse.core.runtime.IPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    28
import org.eclipse.core.runtime.IStatus;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    29
import org.eclipse.core.runtime.Path;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    30
import org.eclipse.core.runtime.Platform;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    31
import org.eclipse.core.runtime.Status;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    32
import org.eclipse.core.runtime.preferences.InstanceScope;
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    33
import org.eclipse.debug.core.DebugPlugin;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    34
import org.eclipse.debug.core.ILaunchConfigurationType;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    35
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    36
import org.eclipse.debug.core.ILaunchManager;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    37
import org.eclipse.debug.ui.IDebugUIConstants;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    38
import org.osgi.service.prefs.Preferences;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    39
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    40
import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    41
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    42
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    43
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    44
import com.nokia.carbide.remoteconnections.interfaces.IService;
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    45
import com.nokia.carbide.remoteconnections.internal.api.IConnectedService2;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    46
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    47
import com.nokia.cdt.debug.cw.symbian.SettingsData;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    48
import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    49
import com.nokia.cpp.internal.api.utils.core.TextUtils;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    50
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    51
import cwdbg.PreferenceConstants;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    52
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    53
/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    54
 * Data manipulated by the launch wizard and its dialogs.
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    55
 */
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    56
@SuppressWarnings("restriction")
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    57
public class LaunchWizardData extends LaunchOptions {
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    58
	public interface IPathValidator {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    59
		/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    60
		 * @param path IPath
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    61
		 * @return Error string or <code>null</code> if is valid
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    62
		 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    63
		String isValidPath(IPath path);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    64
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    65
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    66
	private final IService service;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    67
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    68
	// overall target
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    69
	public static class LaunchType {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    70
		private final String launchId;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    71
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    72
		public LaunchType(String launchId) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    73
			this.launchId = launchId;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    74
		}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    75
		
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
    76
		public boolean isApplicable(LaunchWizardData data) {
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    77
			return true;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    78
		}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    79
		
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    80
		public String getLaunchId() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    81
			return launchId;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    82
		}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    83
	};
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    84
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    85
	public final static LaunchType APP_TRK = new LaunchType(null);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    86
	public final static LaunchType SYS_TRK = new LaunchType(null);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    87
	public final static LaunchType ATTACH_TO_PROCESS_LAUNCH = new LaunchType(null);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    88
	public final static LaunchType PLATSIM_RUN_MODE = new LaunchType(null);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    89
	public final static LaunchType PLATSIM_STOP_MODE = new LaunchType(null);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    90
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    91
	// settings made in Debug/Run Process section
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    92
	enum EExeSelection {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    93
		USE_PROJECT_EXECUTABLE,
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    94
		USE_REMOTE_EXECUTABLE,
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    95
		ATTACH_TO_PROCESS,
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    96
	};
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    97
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    98
	private EExeSelection exeSelection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    99
	private IPath exeSelectionPath = Path.EMPTY;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   100
	private EBuildBeforeLaunchOption buildBeforeLaunch;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   101
	private boolean installPackage;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   102
	private String sisPath;
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   103
	private IConnection connection;
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   104
	private List<IPath> launchableExes;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   105
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   106
	// settings made in the Other Settings section
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   107
	enum EBuildBeforeLaunchOption {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   108
		ALWAYS,
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   109
		NEVER,
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   110
		USE_WORKSPACE_SETTING,
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   111
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   112
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   113
	public LaunchWizardData(LaunchOptions launchOptions, IService trkService) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   114
		this.mmps = launchOptions.mmps;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   115
		this.exes = launchOptions.exes;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   116
		this.defaultExecutable = launchOptions.defaultExecutable;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   117
		this.project = launchOptions.project;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   118
		this.configurationName = launchOptions.configurationName;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   119
		this.isEmulation = launchOptions.isEmulation;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   120
		this.emulatorOnly = launchOptions.emulatorOnly;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   121
		this.mode = launchOptions.mode;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   122
		this.service = trkService;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   123
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   124
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   125
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   126
	 * @return the service
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   127
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   128
	public IService getService() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   129
		return service;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   130
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   131
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   132
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   133
	 * @return
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   134
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   135
	public boolean isDebug() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   136
		return mode.equals(ILaunchManager.DEBUG_MODE);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   137
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   138
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   139
	public String getModeLabel() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   140
		if (mode.equals(ILaunchManager.RUN_MODE))
966
15c9cbbf6707 externalize strings
dadubrow
parents: 953
diff changeset
   141
			return Messages.getString("LaunchWizardData.RunModeLabel"); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   142
		else if (mode.equals(ILaunchManager.DEBUG_MODE))
966
15c9cbbf6707 externalize strings
dadubrow
parents: 953
diff changeset
   143
			return Messages.getString("LaunchWizardData.DebugModeLabel"); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   144
		else
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   145
			return TextUtils.titleCase(mode);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   146
			
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   147
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   148
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   149
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   150
	 * Validate the detected and/or configured data
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   151
	 * @return IStatus, never <code>null</code>
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   152
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   153
	public IStatus validate() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   154
		return Status.OK_STATUS;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   155
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   156
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   157
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   158
	 * @return 
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   159
	 * @return
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   160
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   161
	public List<IPath> getExes() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   162
		return exes;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   163
	}
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   164
	
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   165
	public List<IPath> getLaunchableExes() {
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   166
		if (launchableExes == null) {
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   167
			launchableExes = new ArrayList<IPath>();
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   168
			for (IPath path : exes) {
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   169
				if ("exe".equalsIgnoreCase(path.getFileExtension()))
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   170
					launchableExes.add(path);
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   171
			}
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   172
		}
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   173
		return launchableExes;
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   174
	}
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   175
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   176
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   177
	 * @return the defaultExecutable
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   178
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   179
	public IPath getDefaultExecutable() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   180
		return defaultExecutable;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   181
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   182
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   183
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   184
	 * Set the executable selection mode
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   185
	 * @param selection
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   186
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   187
	public void setExeSelection(EExeSelection selection) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   188
		this.exeSelection = selection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   189
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   190
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   191
	 * Set the path for the exe
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   192
	 * @param path or <code>null</code>
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   193
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   194
	public void setExeSelectionPath(IPath path) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   195
		this.exeSelectionPath = path != null ? path : Path.EMPTY;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   196
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   197
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   198
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   199
	 * @return
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   200
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   201
	public EExeSelection getExeSelection() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   202
		return exeSelection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   203
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   204
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   205
	public IPath getExeSelectionPath() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   206
		return exeSelectionPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   207
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   208
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   209
	public String getConnectionName() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   210
		IConnection connection = getConnection();
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   211
		if (connection == null)
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   212
			return null;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   213
		return connection.getDisplayName();
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   214
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   215
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   216
	public void setBuildBeforeLaunchOption(
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   217
			EBuildBeforeLaunchOption setting) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   218
		this.buildBeforeLaunch = setting;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   219
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   220
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   221
	public EBuildBeforeLaunchOption getBuildBeforeLaunch() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   222
		return buildBeforeLaunch;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   223
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   224
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   225
	/** Get current workspace setting */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   226
	public boolean isWorkspaceBuildBeforeLaunch() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   227
		// here's how to get the prefs from a plugin's #getPreferenceStore() without violating access
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   228
		String prefId = IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   229
		int idx = prefId.lastIndexOf('.');
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   230
		String plugin = prefId.substring(0, idx);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   231
		Preferences node = Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(plugin);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   232
		return node.getBoolean(prefId, true);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   233
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   234
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   235
	/** Get actual launch-time setting */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   236
	public boolean isCurrentBuildBeforeLaunch() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   237
		if (buildBeforeLaunch != EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING)
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   238
			return buildBeforeLaunch == EBuildBeforeLaunchOption.ALWAYS;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   239
		return isWorkspaceBuildBeforeLaunch();
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   240
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   241
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   242
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   243
	 * @param selection
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   244
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   245
	public void setInstallPackage(boolean selection) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   246
		this.installPackage = selection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   247
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   248
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   249
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   250
	 * @return the installPackage
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   251
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   252
	public boolean isInstallPackage() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   253
		return installPackage;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   254
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   255
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   256
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   257
	 * @return
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   258
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   259
	public IProject getProject() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   260
		return project;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   261
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   262
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   263
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   264
	 * @param sisPath
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   265
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   266
	public void setSisPath(String sisPath) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   267
		this.sisPath = sisPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   268
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   269
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   270
	/**
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   271
	 * @return
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   272
	 */
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   273
	public String getSisPath() {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   274
		return sisPath;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   275
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   276
	
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   277
	/**
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   278
	 * Copy the data, for use by a transient dialog.
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   279
	 * @return new copy of data
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   280
	 */
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   281
	public LaunchWizardData copy() {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   282
		LaunchOptions launchOptions = new LaunchOptions();
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   283
		launchOptions.mmps = mmps;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   284
		launchOptions.exes = exes;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   285
		launchOptions.defaultExecutable = defaultExecutable;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   286
		launchOptions.project = project;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   287
		launchOptions.configurationName = configurationName;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   288
		launchOptions.isEmulation = isEmulation;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   289
		launchOptions.emulatorOnly = emulatorOnly;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   290
		launchOptions.mode = mode;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   291
		LaunchWizardData d = new LaunchWizardData(launchOptions, service);
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   292
		d.exeSelection = exeSelection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   293
		d.exeSelectionPath = exeSelectionPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   294
		d.buildBeforeLaunch = buildBeforeLaunch;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   295
		d.installPackage = installPackage;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   296
		d.sisPath = sisPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   297
		d.connection = connection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   298
		return d;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   299
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   300
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   301
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   302
	 * Apply the given data to the receiver (when a transient dialog is accepted) 
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   303
	 * @param dialogData
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   304
	 */
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   305
	public void apply(LaunchWizardData dialogData) {
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   306
		exeSelection = dialogData.exeSelection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   307
		exeSelectionPath = dialogData.exeSelectionPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   308
		buildBeforeLaunch = dialogData.buildBeforeLaunch;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   309
		installPackage = dialogData.installPackage;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   310
		sisPath = dialogData.sisPath;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   311
		connection = dialogData.connection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   312
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   313
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   314
	/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   315
	 * @return
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   316
	 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   317
	public boolean requiresInstallPackage() {
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   318
		return !isSysTRKConnection() || installPackage;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   319
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   320
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   321
	public void setConnection(IConnection connection) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   322
		this.connection = connection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   323
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   324
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   325
	public IConnection getConnection() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   326
		return connection;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   327
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   328
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   329
	public ILaunchConfigurationWorkingCopy createConfiguration() throws CoreException {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   330
		String launchTypeId = getApplicableLaunchTypeId();
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   331
		ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(launchTypeId);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   332
		ILaunchConfigurationWorkingCopy config = launchType.newInstance(null, configurationName);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   333
		initializeConfigSettings(launchTypeId, config);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   334
		
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   335
		return config;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   336
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   337
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   338
	private void initializeConfigSettings(String launchTypeId, ILaunchConfigurationWorkingCopy config) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   339
		IPath exePath = getExePath();
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   340
		IPath mmpPath = getMmpPath(exePath);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   341
		if (launchTypeId.equals(SettingsData.APP_TRK_LAUNCH_TYPE_ID)) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   342
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   343
		}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   344
		else if (launchTypeId.equals(SettingsData.SYS_TRK_LAUNCH_TYPE_ID)) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   345
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_SysTRK, project, mmpPath, exePath);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   346
		}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   347
		else if (launchTypeId.equals(SettingsData.ATTACH_LAUNCH_TYPE_ID)) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   348
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   349
		}
1041
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   350
		if (exeSelection.equals(EExeSelection.USE_REMOTE_EXECUTABLE))
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   351
			SettingsData.setProcessToLaunch(config, exeSelectionPath);
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   352
		
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   353
		addBuildOptions(config);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   354
		// always set the current connection id
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   355
		config.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, Registry.CURRENT_CONNECTION_ID);
1068
21b582a02214 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1066
diff changeset
   356
		if (installPackage) {
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   357
			config.setAttribute(PreferenceConstants.J_PN_SisFileHostPath, sisPath);
1068
21b582a02214 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1066
diff changeset
   358
			// special case handling for running out of E: drive - install into E: drive
21b582a02214 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1066
diff changeset
   359
			if (exeSelection.equals(EExeSelection.USE_REMOTE_EXECUTABLE) && 
21b582a02214 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1066
diff changeset
   360
					exeSelectionPath.getDevice().equalsIgnoreCase("E:")) //$NON-NLS-1$
21b582a02214 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1066
diff changeset
   361
				config.setAttribute(PreferenceConstants.J_PN_InstallToDrive, 4); // index 4 == E: drive
21b582a02214 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1066
diff changeset
   362
		}
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   363
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   364
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   365
	private IPath getMmpPath(IPath exePath) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   366
		if (!mmps.isEmpty()) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   367
			for (int i = 0; i < exes.size(); i++) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   368
				IPath exe = exes.get(i);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   369
				if (exe.lastSegment().equals(exePath.lastSegment()))
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   370
					return mmps.get(i);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   371
			}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   372
		}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   373
		return null;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   374
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   375
1066
4791b1e2e6ef 10809 - generating warning for missing sis file or missing exe
dadubrow
parents: 1041
diff changeset
   376
	public IPath getExePath() {
1041
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   377
		// if attach, doesn't matter so return first exe
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   378
		if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS))
1041
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   379
			return exes.isEmpty() ? Path.EMPTY : exes.get(0);
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   380
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   381
		// otherwise, see if we can use the selected path - process to launch string
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   382
		// by checking if the file name matches any of the ones in our list of exes
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   383
		String filename = exeSelectionPath.lastSegment();
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   384
		if (filename != null) {
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   385
			for (IPath exePath : exes) {
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   386
				if (filename.equalsIgnoreCase(exePath.lastSegment())) {
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   387
					return exePath;
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   388
				}
1041
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   389
			}
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   390
		}
7c4362faca1e bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 966
diff changeset
   391
		// none could be found matching the selected path, so use the first in the list
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1068
diff changeset
   392
		return getLaunchableExes().isEmpty() ? Path.EMPTY : getLaunchableExes().get(0);
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   393
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   394
	
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   395
	private IConnectedService getConnectedService() {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   396
		if (connection != null) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   397
			Collection<IConnectedService> connectedServices = 
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   398
				RemoteConnectionsActivator.getConnectionsManager().getConnectedServices(connection);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   399
			for (IConnectedService connectedService : connectedServices) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   400
				if (connectedService.getService().getIdentifier().equals(service.getIdentifier()))
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   401
					return connectedService;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   402
			}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   403
		}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   404
		return null;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   405
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   406
	
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   407
	public boolean isSysTRKConnection() {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   408
		IConnectedService connectedService = getConnectedService();
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   409
		if (connectedService instanceof IConnectedService2) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   410
			String value = ((IConnectedService2) connectedService).getProperties().get("is-system-trk"); //$NON-NLS-1$
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   411
			return Boolean.parseBoolean(value);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   412
		}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   413
		return false;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   414
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   415
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   416
	private String getApplicableLaunchTypeId() {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   417
		if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS))
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   418
			return SettingsData.ATTACH_LAUNCH_TYPE_ID;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   419
		else if (!installPackage || isSysTRKConnection())
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   420
			return SettingsData.SYS_TRK_LAUNCH_TYPE_ID;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   421
		else
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   422
			return SettingsData.APP_TRK_LAUNCH_TYPE_ID;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   423
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   424
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   425
	private void addBuildOptions(ILaunchConfigurationWorkingCopy config) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   426
		int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   427
		switch (buildBeforeLaunch) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   428
		case NEVER:
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   429
			buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   430
			break;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   431
		case ALWAYS:
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   432
			buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   433
			break;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   434
		}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   435
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   436
	}
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   437
}
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 911
diff changeset
   438