debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java
author dadubrow
Mon, 18 Oct 2010 16:58:49 -0500
changeset 2160 3a82092877ea
parent 1576 ceccb3d7ade9
child 2163 f0a9f2d04d4a
permissions -rw-r--r--
initial commit for PS wizard
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
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    20
import java.text.MessageFormat;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    21
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    22
import org.eclipse.core.runtime.IPath;
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
    23
import org.eclipse.core.runtime.Path;
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    24
import org.eclipse.core.runtime.Status;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    25
import org.eclipse.swt.widgets.Composite;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    26
import org.eclipse.swt.widgets.Shell;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    27
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    28
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    29
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    30
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    31
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    32
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    33
import com.nokia.cpp.internal.api.utils.core.PathUtils;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    34
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    35
/**
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    36
 * 
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    37
 */
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    38
public class DebugRunProcessSection extends AbstractLaunchWizardSection {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    39
2160
3a82092877ea initial commit for PS wizard
dadubrow
parents: 1576
diff changeset
    40
	public DebugRunProcessSection(LaunchWizardData data, AbstractUnifiedLaunchOptionsPage launchOptionsPage) {
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
    41
		super(data, MessageFormat.format(Messages.getString("DebugRunProcessSection.Title"), data.getModeLabel()), launchOptionsPage); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    42
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    43
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    44
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    45
	public void createControl(Composite parent) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    46
		createSection(parent, 1);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    47
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    48
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    49
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    50
	protected void dispose() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    51
		
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
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    55
	public void initializeSettings() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    56
		data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE);
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
    57
		if (data.getLaunchableExes().size() > 0)
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
    58
			data.setExeSelectionPath(data.getLaunchableExes().get(0));
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    59
		else if (data.getDefaultExecutable() != null)
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    60
			data.setExeSelectionPath(data.getDefaultExecutable());
1090
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
    61
		if (Path.EMPTY.equals(data.getExeSelectionPath()))
02cf64aef519 Fix 10861
dadubrow
parents: 1045
diff changeset
    62
			data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS);
1211
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    63
		
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    64
		ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(data.getProject());
1211
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    65
		boolean hasSisInstall = false;
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    66
		if (cpi != null) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    67
			ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    68
			for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    69
				IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    70
				data.setSisPath(sisPath.toOSString());
1211
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    71
				if (info.isEnabled()) {
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    72
					hasSisInstall = true;
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    73
					break;
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    74
				}
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    75
			}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    76
		}
1211
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    77
		
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    78
		if (data.getExeSelection().equals(EExeSelection.ATTACH_TO_PROCESS)) {
1576
ceccb3d7ade9 Bug 11444 and bug 11599 - for non x86, allow non-exe executables and for attach don't ask for install file
dadubrow
parents: 1211
diff changeset
    79
			data.setInstallPackage(false);
1211
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    80
		} else {
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    81
			Boolean detectedSysTrk = data.isSysTRKConnection(); // TRUE, FALSE, or null
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    82
			boolean isSysTrk = detectedSysTrk == Boolean.TRUE || (detectedSysTrk == null && data.isInternalLayout());
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    83
			data.setInstallPackage(hasSisInstall || !isSysTrk);
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    84
		}
ad0a46b0b85f Fix bug 11067 properly
Ed Swartz <ed.swartz@nokia.com>
parents: 1186
diff changeset
    85
		
956
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
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    89
	protected AbstractLaunchSettingsDialog createChangeSettingsDialog(
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    90
			Shell shell, LaunchWizardData dialogData) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    91
		return new DebugRunProcessDialog(shell, dialogData);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    92
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    93
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    94
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    95
	protected void refresh() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    96
		updateUI();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    97
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    98
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
    99
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   100
	protected void validate() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   101
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   102
		status = Status.OK_STATUS;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   103
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   104
		switch (data.getExeSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   105
		case USE_PROJECT_EXECUTABLE:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   106
			if (data.getExeSelectionPath() == null) 
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   107
				status = error(Messages.getString("DebugRunProcessSection.NoExesError"), //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   108
						data.getModeLabel().toLowerCase());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   109
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   110
		case USE_REMOTE_EXECUTABLE:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   111
			if (data.getExeSelectionPath() == null)
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   112
				status = error(Messages.getString("DebugRunProcessSection.NoRemoteExeError"), //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   113
						data.getModeLabel().toLowerCase());
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   114
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   115
		case ATTACH_TO_PROCESS:
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   116
			break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   117
		}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   118
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   119
		if (data.isInstallPackage() && (data.getSisPath() == null || data.getSisPath().length() == 0))
1186
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   120
			status = error(Messages.getString("DebugRunProcessSection.MustInstallError"),
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   121
					data.getModeLabel().toLowerCase()); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   122
	}
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   123
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   124
	@Override
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   125
	protected void updateUI() {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   126
		
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   127
		validate();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   128
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   129
		if (status.isOK()) {
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   130
			String mainFormat = Messages.getString("DebugRunProcessSection.MainFormat"); //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   131
			String copyOrInstallMsg = ""; //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   132
			String runOrLaunchMsg = ""; //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   133
	
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   134
			switch (data.getExeSelection()) {
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   135
			case USE_PROJECT_EXECUTABLE:
1186
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   136
				runOrLaunchMsg = MessageFormat.format(Messages.getString("DebugRunProcessSection.LaunchFormat"), 
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   137
						data.getExeSelectionPath().lastSegment()); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   138
				break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   139
			case USE_REMOTE_EXECUTABLE:
1186
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   140
				runOrLaunchMsg = MessageFormat.format(Messages.getString("DebugRunProcessSection.LaunchFormat"), 
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   141
						PathUtils.convertPathToWindows(data.getExeSelectionPath().toString())); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   142
				break;
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   143
			case ATTACH_TO_PROCESS:
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   144
				runOrLaunchMsg = Messages.getString("DebugRunProcessSection.AttachMsg"); //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   145
				break;
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
			copyOrInstallMsg = getCopyOrInstallMsg();
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   149
			
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   150
			String runOrDebugProcessMessage = MessageFormat.format(mainFormat, copyOrInstallMsg, runOrLaunchMsg);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   151
			descriptionLabel.setText(runOrDebugProcessMessage);
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   152
		} else {
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   153
			descriptionLabel.setText(status.getMessage() + "\n\n" + //$NON-NLS-1$
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   154
					MessageFormat.format(Messages.getString("DebugRunProcessSection.ChangeMsg"), //$NON-NLS-1$
956
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   155
							data.getModeLabel().toLowerCase()));
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
d1e221a2875f new launch wizard implementation
dadubrow
parents:
diff changeset
   159
	private String getCopyOrInstallMsg() {
1186
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   160
		if (data.requiresInstallPackage())
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   161
			return MessageFormat.format(Messages.getString("DebugRunProcessSection.InstallMsg"), data.getSisPath()); //$NON-NLS-1$
067198a8221d Bug 11067: fix some issues with the PNP launch wizard
Ed Swartz <ed.swartz@nokia.com>
parents: 1090
diff changeset
   162
		else
969
b0dd389735fb externalize strings
dadubrow
parents: 960
diff changeset
   163
			return Messages.getString("DebugRunProcessSection.CopyMsg"); //$NON-NLS-1$
956
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
}