debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java
author Ed Swartz <ed.swartz@nokia.com>
Thu, 08 Apr 2010 15:03:50 -0500
changeset 1186 067198a8221d
parent 1090 02cf64aef519
child 1189 9efa81cf79bf
permissions -rw-r--r--
Bug 11067: fix some issues with the PNP launch wizard 1) If Sys TRK is detected, and you select to install a package, a Sys TRK launch is created 2) Error message was confusing when Carbide chose to install a package but SIS configuration was not complete. 3) In an internal layout, assume Sys TRK is more likely than App TRK if we cannot tell from the connection.
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
	public final static LaunchType PLATSIM_RUN_MODE = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    97
	public final static LaunchType PLATSIM_STOP_MODE = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    98
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    99
	// settings made in Debug/Run Process section
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   100
	enum EExeSelection {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   101
		USE_PROJECT_EXECUTABLE,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   102
		USE_REMOTE_EXECUTABLE,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   103
		ATTACH_TO_PROCESS,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   104
	};
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   105
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   106
	private EExeSelection exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   107
	private IPath exeSelectionPath = Path.EMPTY;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   108
	private EBuildBeforeLaunchOption buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   109
	private boolean installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   110
	private String sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   111
	private IConnection connection;
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   112
	private List<IPath> launchableExes;
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   113
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   114
	// settings made in the Other Settings section
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   115
	enum EBuildBeforeLaunchOption {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   116
		ALWAYS,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   117
		NEVER,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   118
		USE_WORKSPACE_SETTING,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   119
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   120
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   121
	public LaunchWizardData(LaunchOptions launchOptions, IService trkService) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   122
		this.mmps = launchOptions.mmps;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   123
		this.exes = launchOptions.exes;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   124
		this.defaultExecutable = launchOptions.defaultExecutable;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   125
		this.project = launchOptions.project;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   126
		this.configurationName = launchOptions.configurationName;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   127
		this.isEmulation = launchOptions.isEmulation;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   128
		this.emulatorOnly = launchOptions.emulatorOnly;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   129
		this.mode = launchOptions.mode;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   130
		this.service = trkService;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   131
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   132
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   133
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   134
	 * @return the service
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   135
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   136
	public IService getService() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   137
		return service;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   138
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   139
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   140
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   141
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   142
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   143
	public boolean isDebug() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   144
		return mode.equals(ILaunchManager.DEBUG_MODE);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   145
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   146
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   147
	public String getModeLabel() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   148
		if (mode.equals(ILaunchManager.RUN_MODE))
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   149
			return Messages.getString("LaunchWizardData.RunModeLabel"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   150
		else if (mode.equals(ILaunchManager.DEBUG_MODE))
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   151
			return Messages.getString("LaunchWizardData.DebugModeLabel"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   152
		else
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   153
			return TextUtils.titleCase(mode);
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
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   157
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   158
	 * Validate the detected and/or configured data
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   159
	 * @return IStatus, never <code>null</code>
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   160
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   161
	public IStatus validate() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   162
		return Status.OK_STATUS;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   163
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   164
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   165
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   166
	 * @return 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   167
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   168
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   169
	public List<IPath> getExes() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   170
		return exes;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   171
	}
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   172
	
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   173
	public List<IPath> getLaunchableExes() {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   174
		if (launchableExes == null) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   175
			launchableExes = new ArrayList<IPath>();
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   176
			for (IPath path : exes) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   177
				if ("exe".equalsIgnoreCase(path.getFileExtension()))
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   178
					launchableExes.add(path);
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   179
			}
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   180
		}
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   181
		return launchableExes;
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   182
	}
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   183
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   184
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   185
	 * @return the defaultExecutable
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   186
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   187
	public IPath getDefaultExecutable() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   188
		return defaultExecutable;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   189
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   190
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   191
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   192
	 * Set the executable selection mode
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   193
	 * @param selection
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   194
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   195
	public void setExeSelection(EExeSelection selection) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   196
		this.exeSelection = selection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   197
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   198
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   199
	 * Set the path for the exe
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   200
	 * @param path or <code>null</code>
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   201
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   202
	public void setExeSelectionPath(IPath path) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   203
		this.exeSelectionPath = path != null ? path : Path.EMPTY;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   204
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   205
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   206
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   207
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   208
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   209
	public EExeSelection getExeSelection() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   210
		return exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   211
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   212
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   213
	public IPath getExeSelectionPath() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   214
		return exeSelectionPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   215
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   216
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   217
	public String getConnectionName() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   218
		IConnection connection = getConnection();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   219
		if (connection == null)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   220
			return null;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   221
		return connection.getDisplayName();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   222
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   223
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   224
	public void setBuildBeforeLaunchOption(
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   225
			EBuildBeforeLaunchOption setting) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   226
		this.buildBeforeLaunch = setting;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   227
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   228
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   229
	public EBuildBeforeLaunchOption getBuildBeforeLaunch() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   230
		return buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   231
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   232
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   233
	/** Get current workspace setting */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   234
	public boolean isWorkspaceBuildBeforeLaunch() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   235
		// here's how to get the prefs from a plugin's #getPreferenceStore() without violating access
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   236
		String prefId = IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   237
		int idx = prefId.lastIndexOf('.');
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   238
		String plugin = prefId.substring(0, idx);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   239
		Preferences node = Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(plugin);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   240
		return node.getBoolean(prefId, true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   241
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   242
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   243
	/** Get actual launch-time setting */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   244
	public boolean isCurrentBuildBeforeLaunch() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   245
		if (buildBeforeLaunch != EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   246
			return buildBeforeLaunch == EBuildBeforeLaunchOption.ALWAYS;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   247
		return isWorkspaceBuildBeforeLaunch();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   248
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   249
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   250
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   251
	 * @param selection
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   252
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   253
	public void setInstallPackage(boolean selection) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   254
		this.installPackage = selection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   255
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   256
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   257
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   258
	 * @return the installPackage
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   259
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   260
	public boolean isInstallPackage() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   261
		return installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   262
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   263
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   264
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   265
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   266
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   267
	public IProject getProject() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   268
		return project;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   269
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   270
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   271
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   272
	 * @param sisPath
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   273
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   274
	public void setSisPath(String sisPath) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   275
		this.sisPath = sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   276
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   277
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   278
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   279
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   280
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   281
	public String getSisPath() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   282
		return sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   283
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   284
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   285
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   286
	 * Copy the data, for use by a transient dialog.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   287
	 * @return new copy of data
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   288
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   289
	public LaunchWizardData copy() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   290
		LaunchOptions launchOptions = new LaunchOptions();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   291
		launchOptions.mmps = mmps;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   292
		launchOptions.exes = exes;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   293
		launchOptions.defaultExecutable = defaultExecutable;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   294
		launchOptions.project = project;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   295
		launchOptions.configurationName = configurationName;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   296
		launchOptions.isEmulation = isEmulation;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   297
		launchOptions.emulatorOnly = emulatorOnly;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   298
		launchOptions.mode = mode;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   299
		LaunchWizardData d = new LaunchWizardData(launchOptions, service);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   300
		d.exeSelection = exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   301
		d.exeSelectionPath = exeSelectionPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   302
		d.buildBeforeLaunch = buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   303
		d.installPackage = installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   304
		d.sisPath = sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   305
		d.connection = connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   306
		return d;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   307
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   308
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   309
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   310
	 * Apply the given data to the receiver (when a transient dialog is accepted) 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   311
	 * @param dialogData
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   312
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   313
	public void apply(LaunchWizardData dialogData) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   314
		exeSelection = dialogData.exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   315
		exeSelectionPath = dialogData.exeSelectionPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   316
		buildBeforeLaunch = dialogData.buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   317
		installPackage = dialogData.installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   318
		sisPath = dialogData.sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   319
		connection = dialogData.connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   320
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   321
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   322
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   323
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   324
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   325
	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
   326
		return isSysTRKConnection() == Boolean.FALSE /* but not if unknown */ || installPackage;
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   327
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   328
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   329
	public void setConnection(IConnection connection) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   330
		this.connection = connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   331
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   332
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   333
	public IConnection getConnection() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   334
		return connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   335
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   336
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   337
	public ILaunchConfigurationWorkingCopy createConfiguration() throws CoreException {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   338
		String launchTypeId = getApplicableLaunchTypeId();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   339
		ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(launchTypeId);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   340
		ILaunchConfigurationWorkingCopy config = launchType.newInstance(null, configurationName);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   341
		initializeConfigSettings(launchTypeId, config);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   342
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   343
		return config;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   344
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   345
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   346
	private void initializeConfigSettings(String launchTypeId, ILaunchConfigurationWorkingCopy config) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   347
		IPath exePath = getExePath();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   348
		IPath mmpPath = getMmpPath(exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   349
		if (launchTypeId.equals(SettingsData.APP_TRK_LAUNCH_TYPE_ID)) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   350
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   351
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   352
		else if (launchTypeId.equals(SettingsData.SYS_TRK_LAUNCH_TYPE_ID)) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   353
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_SysTRK, project, mmpPath, exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   354
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   355
		else if (launchTypeId.equals(SettingsData.ATTACH_LAUNCH_TYPE_ID)) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   356
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   357
		}
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   358
		if (exeSelection.equals(EExeSelection.USE_REMOTE_EXECUTABLE))
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   359
			SettingsData.setProcessToLaunch(config, exeSelectionPath);
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   360
		
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   361
		addBuildOptions(config);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   362
		// always set the current connection id
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   363
		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
   364
		if (installPackage) {
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   365
			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
   366
			// 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
   367
			if (exeSelection.equals(EExeSelection.USE_REMOTE_EXECUTABLE) && 
16060a6479b9 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1067
diff changeset
   368
					exeSelectionPath.getDevice().equalsIgnoreCase("E:")) //$NON-NLS-1$
16060a6479b9 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1067
diff changeset
   369
				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
   370
		}
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   371
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   372
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   373
	private IPath getMmpPath(IPath exePath) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   374
		if (!mmps.isEmpty()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   375
			for (int i = 0; i < exes.size(); i++) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   376
				IPath exe = exes.get(i);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   377
				if (exe.lastSegment().equals(exePath.lastSegment()))
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   378
					return mmps.get(i);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   379
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   380
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   381
		return null;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   382
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   383
1067
856622c7b203 10809 - generating warning for missing sis file or missing exe
dadubrow
parents: 1042
diff changeset
   384
	public IPath getExePath() {
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   385
		// if attach, doesn't matter so return first exe
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   386
		if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS))
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   387
			return exes.isEmpty() ? Path.EMPTY : exes.get(0);
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   388
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   389
		// 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
   390
		// 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
   391
		String filename = exeSelectionPath.lastSegment();
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   392
		if (filename != null) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   393
			for (IPath exePath : exes) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   394
				if (filename.equalsIgnoreCase(exePath.lastSegment())) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   395
					return exePath;
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   396
				}
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   397
			}
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   398
		}
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   399
		// none could be found matching the selected path, so use the first in the list
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   400
		return getLaunchableExes().isEmpty() ? Path.EMPTY : getLaunchableExes().get(0);
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   401
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   402
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   403
	private IConnectedService getConnectedService() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   404
		if (connection != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   405
			Collection<IConnectedService> connectedServices = 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   406
				RemoteConnectionsActivator.getConnectionsManager().getConnectedServices(connection);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   407
			for (IConnectedService connectedService : connectedServices) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   408
				if (connectedService.getService().getIdentifier().equals(service.getIdentifier()))
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   409
					return connectedService;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   410
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   411
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   412
		return null;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   413
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   414
	
1186
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   415
	/** 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
   416
	 * 
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   417
	 * @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
   418
	 */
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   419
	public Boolean isSysTRKConnection() {
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   420
		IConnectedService connectedService = getConnectedService();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   421
		if (connectedService instanceof IConnectedService2) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   422
			String value = ((IConnectedService2) connectedService).getProperties().get("is-system-trk"); //$NON-NLS-1$
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   423
			return Boolean.parseBoolean(value);
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