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