debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java
author dadubrow
Wed, 10 Mar 2010 15:25:49 -0600
changeset 1090 02cf64aef519
parent 1069 16060a6479b9
child 1186 067198a8221d
permissions -rw-r--r--
Fix 10861
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;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    38
import org.osgi.service.prefs.Preferences;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    39
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    40
import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    41
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    42
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    43
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    44
import com.nokia.carbide.remoteconnections.interfaces.IService;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    45
import com.nokia.carbide.remoteconnections.internal.api.IConnectedService2;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    46
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    47
import com.nokia.cdt.debug.cw.symbian.SettingsData;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    48
import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    49
import com.nokia.cpp.internal.api.utils.core.TextUtils;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    50
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    51
import cwdbg.PreferenceConstants;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    52
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    53
/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    54
 * Data manipulated by the launch wizard and its dialogs.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    55
 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    56
@SuppressWarnings("restriction")
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    57
public class LaunchWizardData extends LaunchOptions {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    58
	public interface IPathValidator {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    59
		/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    60
		 * @param path IPath
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    61
		 * @return Error string or <code>null</code> if is valid
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    62
		 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    63
		String isValidPath(IPath path);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    64
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    65
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    66
	private final IService service;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    67
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    68
	// overall target
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    69
	public static class LaunchType {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    70
		private final String launchId;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    71
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    72
		public LaunchType(String launchId) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    73
			this.launchId = launchId;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    74
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    75
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    76
		public boolean isApplicable(LaunchWizardData data) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    77
			return true;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    78
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    79
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    80
		public String getLaunchId() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    81
			return 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
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    85
	public final static LaunchType APP_TRK = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    86
	public final static LaunchType SYS_TRK = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    87
	public final static LaunchType ATTACH_TO_PROCESS_LAUNCH = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    88
	public final static LaunchType PLATSIM_RUN_MODE = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    89
	public final static LaunchType PLATSIM_STOP_MODE = new LaunchType(null);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    90
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    91
	// settings made in Debug/Run Process section
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    92
	enum EExeSelection {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    93
		USE_PROJECT_EXECUTABLE,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    94
		USE_REMOTE_EXECUTABLE,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    95
		ATTACH_TO_PROCESS,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    96
	};
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    97
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    98
	private EExeSelection exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    99
	private IPath exeSelectionPath = Path.EMPTY;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   100
	private EBuildBeforeLaunchOption buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   101
	private boolean installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   102
	private String sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   103
	private IConnection connection;
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   104
	private List<IPath> launchableExes;
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   105
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   106
	// settings made in the Other Settings section
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   107
	enum EBuildBeforeLaunchOption {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   108
		ALWAYS,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   109
		NEVER,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   110
		USE_WORKSPACE_SETTING,
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   111
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   112
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   113
	public LaunchWizardData(LaunchOptions launchOptions, IService trkService) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   114
		this.mmps = launchOptions.mmps;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   115
		this.exes = launchOptions.exes;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   116
		this.defaultExecutable = launchOptions.defaultExecutable;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   117
		this.project = launchOptions.project;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   118
		this.configurationName = launchOptions.configurationName;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   119
		this.isEmulation = launchOptions.isEmulation;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   120
		this.emulatorOnly = launchOptions.emulatorOnly;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   121
		this.mode = launchOptions.mode;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   122
		this.service = trkService;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   123
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   124
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   125
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   126
	 * @return the service
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   127
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   128
	public IService getService() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   129
		return service;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   133
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   134
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   135
	public boolean isDebug() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   136
		return mode.equals(ILaunchManager.DEBUG_MODE);
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
	public String getModeLabel() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   140
		if (mode.equals(ILaunchManager.RUN_MODE))
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   141
			return Messages.getString("LaunchWizardData.RunModeLabel"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   142
		else if (mode.equals(ILaunchManager.DEBUG_MODE))
969
b0dd389735fb externalize strings
dadubrow
parents: 956
diff changeset
   143
			return Messages.getString("LaunchWizardData.DebugModeLabel"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   144
		else
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   145
			return TextUtils.titleCase(mode);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   146
			
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   147
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   148
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   149
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   150
	 * Validate the detected and/or configured data
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   151
	 * @return IStatus, never <code>null</code>
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   152
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   153
	public IStatus validate() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   154
		return Status.OK_STATUS;
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
	 * @return 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   159
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   160
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   161
	public List<IPath> getExes() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   162
		return exes;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   163
	}
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   164
	
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   165
	public List<IPath> getLaunchableExes() {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   166
		if (launchableExes == null) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   167
			launchableExes = new ArrayList<IPath>();
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   168
			for (IPath path : exes) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   169
				if ("exe".equalsIgnoreCase(path.getFileExtension()))
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   170
					launchableExes.add(path);
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   171
			}
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   172
		}
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   173
		return launchableExes;
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   174
	}
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   175
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   176
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   177
	 * @return the defaultExecutable
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   178
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   179
	public IPath getDefaultExecutable() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   180
		return defaultExecutable;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   184
	 * Set the executable selection mode
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   185
	 * @param selection
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   186
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   187
	public void setExeSelection(EExeSelection selection) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   188
		this.exeSelection = selection;
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
	 * Set the path for the exe
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   192
	 * @param path or <code>null</code>
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   193
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   194
	public void setExeSelectionPath(IPath path) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   195
		this.exeSelectionPath = path != null ? path : Path.EMPTY;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   196
	}
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
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   200
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   201
	public EExeSelection getExeSelection() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   202
		return exeSelection;
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
	public IPath getExeSelectionPath() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   206
		return exeSelectionPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   207
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   208
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   209
	public String getConnectionName() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   210
		IConnection connection = getConnection();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   211
		if (connection == null)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   212
			return null;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   213
		return connection.getDisplayName();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   214
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   215
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   216
	public void setBuildBeforeLaunchOption(
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   217
			EBuildBeforeLaunchOption setting) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   218
		this.buildBeforeLaunch = setting;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   219
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   220
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   221
	public EBuildBeforeLaunchOption getBuildBeforeLaunch() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   222
		return buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   223
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   224
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   225
	/** Get current workspace setting */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   226
	public boolean isWorkspaceBuildBeforeLaunch() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   227
		// here's how to get the prefs from a plugin's #getPreferenceStore() without violating access
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   228
		String prefId = IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   229
		int idx = prefId.lastIndexOf('.');
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   230
		String plugin = prefId.substring(0, idx);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   231
		Preferences node = Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(plugin);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   232
		return node.getBoolean(prefId, true);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   233
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   234
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   235
	/** Get actual launch-time setting */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   236
	public boolean isCurrentBuildBeforeLaunch() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   237
		if (buildBeforeLaunch != EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   238
			return buildBeforeLaunch == EBuildBeforeLaunchOption.ALWAYS;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   239
		return isWorkspaceBuildBeforeLaunch();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   240
	}
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
	 * @param selection
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   244
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   245
	public void setInstallPackage(boolean selection) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   246
		this.installPackage = selection;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   250
	 * @return the installPackage
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   251
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   252
	public boolean isInstallPackage() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   253
		return installPackage;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   257
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   258
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   259
	public IProject getProject() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   260
		return project;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   264
	 * @param sisPath
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   265
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   266
	public void setSisPath(String sisPath) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   267
		this.sisPath = sisPath;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   271
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   272
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   273
	public String getSisPath() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   274
		return sisPath;
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
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   278
	 * Copy the data, for use by a transient dialog.
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   279
	 * @return new copy of data
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   280
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   281
	public LaunchWizardData copy() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   282
		LaunchOptions launchOptions = new LaunchOptions();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   283
		launchOptions.mmps = mmps;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   284
		launchOptions.exes = exes;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   285
		launchOptions.defaultExecutable = defaultExecutable;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   286
		launchOptions.project = project;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   287
		launchOptions.configurationName = configurationName;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   288
		launchOptions.isEmulation = isEmulation;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   289
		launchOptions.emulatorOnly = emulatorOnly;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   290
		launchOptions.mode = mode;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   291
		LaunchWizardData d = new LaunchWizardData(launchOptions, service);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   292
		d.exeSelection = exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   293
		d.exeSelectionPath = exeSelectionPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   294
		d.buildBeforeLaunch = buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   295
		d.installPackage = installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   296
		d.sisPath = sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   297
		d.connection = connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   298
		return d;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   299
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   300
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   301
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   302
	 * Apply the given data to the receiver (when a transient dialog is accepted) 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   303
	 * @param dialogData
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   304
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   305
	public void apply(LaunchWizardData dialogData) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   306
		exeSelection = dialogData.exeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   307
		exeSelectionPath = dialogData.exeSelectionPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   308
		buildBeforeLaunch = dialogData.buildBeforeLaunch;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   309
		installPackage = dialogData.installPackage;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   310
		sisPath = dialogData.sisPath;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   311
		connection = dialogData.connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   312
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   313
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   314
	/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   315
	 * @return
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   316
	 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   317
	public boolean requiresInstallPackage() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   318
		return !isSysTRKConnection() || installPackage;
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
	public void setConnection(IConnection connection) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   322
		this.connection = connection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   323
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   324
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   325
	public IConnection getConnection() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   326
		return connection;
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 ILaunchConfigurationWorkingCopy createConfiguration() throws CoreException {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   330
		String launchTypeId = getApplicableLaunchTypeId();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   331
		ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(launchTypeId);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   332
		ILaunchConfigurationWorkingCopy config = launchType.newInstance(null, configurationName);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   333
		initializeConfigSettings(launchTypeId, config);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   334
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   335
		return config;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   336
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   337
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   338
	private void initializeConfigSettings(String launchTypeId, ILaunchConfigurationWorkingCopy config) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   339
		IPath exePath = getExePath();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   340
		IPath mmpPath = getMmpPath(exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   341
		if (launchTypeId.equals(SettingsData.APP_TRK_LAUNCH_TYPE_ID)) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   342
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   343
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   344
		else if (launchTypeId.equals(SettingsData.SYS_TRK_LAUNCH_TYPE_ID)) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   345
    		SettingsData.setDefaults(config, SettingsData.LaunchConfig_SysTRK, project, mmpPath, exePath);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   346
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   347
		else if (launchTypeId.equals(SettingsData.ATTACH_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
		}
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   350
		if (exeSelection.equals(EExeSelection.USE_REMOTE_EXECUTABLE))
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   351
			SettingsData.setProcessToLaunch(config, exeSelectionPath);
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   352
		
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   353
		addBuildOptions(config);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   354
		// always set the current connection id
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   355
		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
   356
		if (installPackage) {
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   357
			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
   358
			// 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
   359
			if (exeSelection.equals(EExeSelection.USE_REMOTE_EXECUTABLE) && 
16060a6479b9 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1067
diff changeset
   360
					exeSelectionPath.getDevice().equalsIgnoreCase("E:")) //$NON-NLS-1$
16060a6479b9 10823 - if installing and launching from E:, install into E: also
dadubrow
parents: 1067
diff changeset
   361
				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
   362
		}
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   363
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   364
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   365
	private IPath getMmpPath(IPath exePath) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   366
		if (!mmps.isEmpty()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   367
			for (int i = 0; i < exes.size(); i++) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   368
				IPath exe = exes.get(i);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   369
				if (exe.lastSegment().equals(exePath.lastSegment()))
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   370
					return mmps.get(i);
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
		return null;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   374
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   375
1067
856622c7b203 10809 - generating warning for missing sis file or missing exe
dadubrow
parents: 1042
diff changeset
   376
	public IPath getExePath() {
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   377
		// if attach, doesn't matter so return first exe
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   378
		if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS))
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   379
			return exes.isEmpty() ? Path.EMPTY : exes.get(0);
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   380
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   381
		// 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
   382
		// 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
   383
		String filename = exeSelectionPath.lastSegment();
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   384
		if (filename != null) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   385
			for (IPath exePath : exes) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   386
				if (filename.equalsIgnoreCase(exePath.lastSegment())) {
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   387
					return exePath;
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   388
				}
1042
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   389
			}
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   390
		}
a1a443e77261 bugs 10806 + 10807 fix problems with program to launch
dadubrow
parents: 969
diff changeset
   391
		// none could be found matching the selected path, so use the first in the list
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1069
diff changeset
   392
		return getLaunchableExes().isEmpty() ? Path.EMPTY : getLaunchableExes().get(0);
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   393
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   394
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   395
	private IConnectedService getConnectedService() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   396
		if (connection != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   397
			Collection<IConnectedService> connectedServices = 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   398
				RemoteConnectionsActivator.getConnectionsManager().getConnectedServices(connection);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   399
			for (IConnectedService connectedService : connectedServices) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   400
				if (connectedService.getService().getIdentifier().equals(service.getIdentifier()))
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   401
					return connectedService;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   402
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   403
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   404
		return null;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   405
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   406
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   407
	public boolean isSysTRKConnection() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   408
		IConnectedService connectedService = getConnectedService();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   409
		if (connectedService instanceof IConnectedService2) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   410
			String value = ((IConnectedService2) connectedService).getProperties().get("is-system-trk"); //$NON-NLS-1$
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   411
			return Boolean.parseBoolean(value);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   412
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   413
		return false;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   414
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   415
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   416
	private String getApplicableLaunchTypeId() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   417
		if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS))
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   418
			return SettingsData.ATTACH_LAUNCH_TYPE_ID;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   419
		else if (!installPackage || isSysTRKConnection())
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   420
			return SettingsData.SYS_TRK_LAUNCH_TYPE_ID;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   421
		else
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   422
			return SettingsData.APP_TRK_LAUNCH_TYPE_ID;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   423
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   424
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   425
	private void addBuildOptions(ILaunchConfigurationWorkingCopy config) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   426
		int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   427
		switch (buildBeforeLaunch) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   428
		case NEVER:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   429
			buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   430
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   431
		case ALWAYS:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   432
			buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   433
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   434
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   435
		config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   436
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   437
}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   438