debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java
author Ed Swartz <ed.swartz@nokia.com>
Fri, 09 Apr 2010 07:45:47 -0500
branchRCL_2_4
changeset 1191 0523013ddf00
parent 1091 9ce8893d737f
child 1210 889f3a3dcae6
permissions -rw-r--r--
Merge commits 1174, 1175, 1176, 1184, 1185 from default: Fix issues not disposing listeners in PNP launch wizard Fix use of PathUtils: do not use new Path() on a Windows format path; this breaks in Linux. Bug 11067: fix some issues with the PNP launch wizard Connected service properties need to be propagated just as their statuses are
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     1
/*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     3
* All rights reserved.
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     4
* This component and the accompanying materials are made available
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     6
* which accompanies this distribution, and is available
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     8
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
     9
* Initial Contributors:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    11
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    12
* Contributors:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    13
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    14
* Description: 
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    15
*
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    16
*/
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    17
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    18
package com.nokia.cdt.internal.debug.launch.newwizard;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    19
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    20
import java.text.MessageFormat;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    21
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    22
import org.eclipse.core.runtime.IPath;
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1044
diff changeset
    23
import org.eclipse.core.runtime.Path;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    24
import org.eclipse.core.runtime.Status;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    25
import org.eclipse.swt.widgets.Composite;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    26
import org.eclipse.swt.widgets.Shell;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    27
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    28
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    29
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    30
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    31
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo;
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    32
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection;
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    33
import com.nokia.cpp.internal.api.utils.core.PathUtils;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    34
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    35
/**
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    36
 * 
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    37
 */
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    38
public class DebugRunProcessSection extends AbstractLaunchWizardSection {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    39
959
a9c84e6d779f ui tweaks to new launch wizard
dadubrow
parents: 953
diff changeset
    40
	public DebugRunProcessSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) {
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
    41
		super(data, MessageFormat.format(Messages.getString("DebugRunProcessSection.Title"), data.getModeLabel()), launchOptionsPage); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    42
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    43
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    44
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    45
	public void createControl(Composite parent) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    46
		createSection(parent, 1);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    47
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    48
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    49
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    50
	protected void dispose() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    51
		
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    52
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    53
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    54
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    55
	public void initializeSettings() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    56
		data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE);
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1044
diff changeset
    57
		if (data.getLaunchableExes().size() > 0)
9ce8893d737f Fix 10861
dadubrow
parents: 1044
diff changeset
    58
			data.setExeSelectionPath(data.getLaunchableExes().get(0));
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    59
		else if (data.getDefaultExecutable() != null)
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    60
			data.setExeSelectionPath(data.getDefaultExecutable());
1091
9ce8893d737f Fix 10861
dadubrow
parents: 1044
diff changeset
    61
		if (Path.EMPTY.equals(data.getExeSelectionPath()))
9ce8893d737f Fix 10861
dadubrow
parents: 1044
diff changeset
    62
			data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS);
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    63
		ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(data.getProject());
1191
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
    64
		data.setInstallPackage((data.isSysTRKConnection() == Boolean.FALSE  /* but NOT if unknown */
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
    65
								|| !data.isInternalLayout())
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
    66
				&& !data.getExeSelection().equals(EExeSelection.ATTACH_TO_PROCESS));
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    67
		if (cpi != null) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    68
			ICarbideBuildConfiguration config = cpi.getDefaultConfiguration();
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    69
			for (ISISBuilderInfo info : config.getSISBuilderInfoList()) {
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    70
				IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath();
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    71
				data.setSisPath(sisPath.toOSString());
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    72
			}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    73
		}
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    74
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    75
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    76
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    77
	protected AbstractLaunchSettingsDialog createChangeSettingsDialog(
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
    78
			Shell shell, LaunchWizardData dialogData) {
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    79
		return new DebugRunProcessDialog(shell, dialogData);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    80
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    81
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    82
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    83
	protected void refresh() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    84
		updateUI();
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    85
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    86
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    87
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    88
	protected void validate() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    89
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    90
		status = Status.OK_STATUS;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    91
		
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    92
		switch (data.getExeSelection()) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    93
		case USE_PROJECT_EXECUTABLE:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    94
			if (data.getExeSelectionPath() == null) 
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
    95
				status = error(Messages.getString("DebugRunProcessSection.NoExesError"), //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    96
						data.getModeLabel().toLowerCase());
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    97
			break;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    98
		case USE_REMOTE_EXECUTABLE:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
    99
			if (data.getExeSelectionPath() == null)
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   100
				status = error(Messages.getString("DebugRunProcessSection.NoRemoteExeError"), //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   101
						data.getModeLabel().toLowerCase());
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   102
			break;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   103
		case ATTACH_TO_PROCESS:
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   104
			break;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   105
		}
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   106
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   107
		if (data.isInstallPackage() && (data.getSisPath() == null || data.getSisPath().length() == 0))
1191
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   108
			status = error(Messages.getString("DebugRunProcessSection.MustInstallError"),
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   109
					data.getModeLabel().toLowerCase()); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   110
	}
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   111
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   112
	@Override
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   113
	protected void updateUI() {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   114
		
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   115
		validate();
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   116
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   117
		if (status.isOK()) {
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   118
			String mainFormat = Messages.getString("DebugRunProcessSection.MainFormat"); //$NON-NLS-1$
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   119
			String copyOrInstallMsg = ""; //$NON-NLS-1$
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   120
			String runOrLaunchMsg = ""; //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   121
	
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   122
			switch (data.getExeSelection()) {
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   123
			case USE_PROJECT_EXECUTABLE:
1191
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   124
				runOrLaunchMsg = MessageFormat.format(Messages.getString("DebugRunProcessSection.LaunchFormat"), 
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   125
						data.getExeSelectionPath().lastSegment()); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   126
				break;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   127
			case USE_REMOTE_EXECUTABLE:
1191
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   128
				runOrLaunchMsg = MessageFormat.format(Messages.getString("DebugRunProcessSection.LaunchFormat"), 
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   129
						PathUtils.convertPathToWindows(data.getExeSelectionPath().toString())); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   130
				break;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   131
			case ATTACH_TO_PROCESS:
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   132
				runOrLaunchMsg = Messages.getString("DebugRunProcessSection.AttachMsg"); //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   133
				break;
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   134
			}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   135
			
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   136
			copyOrInstallMsg = getCopyOrInstallMsg();
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   137
			
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   138
			String runOrDebugProcessMessage = MessageFormat.format(mainFormat, copyOrInstallMsg, runOrLaunchMsg);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   139
			descriptionLabel.setText(runOrDebugProcessMessage);
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   140
		} else {
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   141
			descriptionLabel.setText(status.getMessage() + "\n\n" + //$NON-NLS-1$
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   142
					MessageFormat.format(Messages.getString("DebugRunProcessSection.ChangeMsg"), //$NON-NLS-1$
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   143
							data.getModeLabel().toLowerCase()));
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   144
		}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   145
	}
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   146
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   147
	private String getCopyOrInstallMsg() {
1191
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   148
		if (data.requiresInstallPackage())
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   149
			return MessageFormat.format(Messages.getString("DebugRunProcessSection.InstallMsg"), data.getSisPath()); //$NON-NLS-1$
0523013ddf00 Merge commits 1174, 1175, 1176, 1184, 1185 from default:
Ed Swartz <ed.swartz@nokia.com>
parents: 1091
diff changeset
   150
		else
966
15c9cbbf6707 externalize strings
dadubrow
parents: 959
diff changeset
   151
			return Messages.getString("DebugRunProcessSection.CopyMsg"); //$NON-NLS-1$
953
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   152
	}
68b6a294ab01 new launch wizard implementation
dadubrow
parents: 913
diff changeset
   153
911
81a2e70a37d7 new wizard initial commit
dadubrow
parents:
diff changeset
   154
}