author | Ed Swartz <ed.swartz@nokia.com> |
Fri, 09 Apr 2010 07:45:47 -0500 | |
branch | RCL_2_4 |
changeset 1191 | 0523013ddf00 |
parent 1091 | 9ce8893d737f |
child 1210 | 889f3a3dcae6 |
permissions | -rw-r--r-- |
911 | 1 |
/* |
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
package com.nokia.cdt.internal.debug.launch.newwizard; |
|
19 |
||
20 |
import java.text.MessageFormat; |
|
21 |
||
953 | 22 |
import org.eclipse.core.runtime.IPath; |
1091 | 23 |
import org.eclipse.core.runtime.Path; |
911 | 24 |
import org.eclipse.core.runtime.Status; |
25 |
import org.eclipse.swt.widgets.Composite; |
|
26 |
import org.eclipse.swt.widgets.Shell; |
|
27 |
||
953 | 28 |
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
29 |
import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
|
30 |
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
|
31 |
import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; |
|
32 |
import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; |
|
911 | 33 |
import com.nokia.cpp.internal.api.utils.core.PathUtils; |
34 |
||
35 |
/** |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class DebugRunProcessSection extends AbstractLaunchWizardSection { |
|
39 |
||
959 | 40 |
public DebugRunProcessSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) { |
966 | 41 |
super(data, MessageFormat.format(Messages.getString("DebugRunProcessSection.Title"), data.getModeLabel()), launchOptionsPage); //$NON-NLS-1$ |
911 | 42 |
} |
43 |
||
44 |
@Override |
|
45 |
public void createControl(Composite parent) { |
|
46 |
createSection(parent, 1); |
|
47 |
} |
|
48 |
||
49 |
@Override |
|
50 |
protected void dispose() { |
|
51 |
||
52 |
} |
|
53 |
||
54 |
@Override |
|
55 |
public void initializeSettings() { |
|
56 |
data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); |
|
1091 | 57 |
if (data.getLaunchableExes().size() > 0) |
58 |
data.setExeSelectionPath(data.getLaunchableExes().get(0)); |
|
911 | 59 |
else if (data.getDefaultExecutable() != null) |
60 |
data.setExeSelectionPath(data.getDefaultExecutable()); |
|
1091 | 61 |
if (Path.EMPTY.equals(data.getExeSelectionPath())) |
62 |
data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
|
953 | 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 | 67 |
if (cpi != null) { |
68 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
|
69 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
|
70 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
|
71 |
data.setSisPath(sisPath.toOSString()); |
|
72 |
} |
|
73 |
} |
|
911 | 74 |
} |
75 |
||
76 |
@Override |
|
77 |
protected AbstractLaunchSettingsDialog createChangeSettingsDialog( |
|
953 | 78 |
Shell shell, LaunchWizardData dialogData) { |
911 | 79 |
return new DebugRunProcessDialog(shell, dialogData); |
80 |
} |
|
81 |
||
82 |
@Override |
|
83 |
protected void refresh() { |
|
84 |
updateUI(); |
|
85 |
} |
|
86 |
||
87 |
@Override |
|
88 |
protected void validate() { |
|
89 |
||
90 |
status = Status.OK_STATUS; |
|
91 |
||
92 |
switch (data.getExeSelection()) { |
|
93 |
case USE_PROJECT_EXECUTABLE: |
|
94 |
if (data.getExeSelectionPath() == null) |
|
966 | 95 |
status = error(Messages.getString("DebugRunProcessSection.NoExesError"), //$NON-NLS-1$ |
911 | 96 |
data.getModeLabel().toLowerCase()); |
97 |
break; |
|
98 |
case USE_REMOTE_EXECUTABLE: |
|
99 |
if (data.getExeSelectionPath() == null) |
|
966 | 100 |
status = error(Messages.getString("DebugRunProcessSection.NoRemoteExeError"), //$NON-NLS-1$ |
911 | 101 |
data.getModeLabel().toLowerCase()); |
102 |
break; |
|
103 |
case ATTACH_TO_PROCESS: |
|
104 |
break; |
|
105 |
} |
|
953 | 106 |
|
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 | 110 |
} |
953 | 111 |
|
911 | 112 |
@Override |
113 |
protected void updateUI() { |
|
114 |
||
115 |
validate(); |
|
116 |
||
117 |
if (status.isOK()) { |
|
966 | 118 |
String mainFormat = Messages.getString("DebugRunProcessSection.MainFormat"); //$NON-NLS-1$ |
119 |
String copyOrInstallMsg = ""; //$NON-NLS-1$ |
|
120 |
String runOrLaunchMsg = ""; //$NON-NLS-1$ |
|
911 | 121 |
|
122 |
switch (data.getExeSelection()) { |
|
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 | 126 |
break; |
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 | 130 |
break; |
131 |
case ATTACH_TO_PROCESS: |
|
966 | 132 |
runOrLaunchMsg = Messages.getString("DebugRunProcessSection.AttachMsg"); //$NON-NLS-1$ |
911 | 133 |
break; |
134 |
} |
|
135 |
||
953 | 136 |
copyOrInstallMsg = getCopyOrInstallMsg(); |
911 | 137 |
|
138 |
String runOrDebugProcessMessage = MessageFormat.format(mainFormat, copyOrInstallMsg, runOrLaunchMsg); |
|
139 |
descriptionLabel.setText(runOrDebugProcessMessage); |
|
140 |
} else { |
|
966 | 141 |
descriptionLabel.setText(status.getMessage() + "\n\n" + //$NON-NLS-1$ |
142 |
MessageFormat.format(Messages.getString("DebugRunProcessSection.ChangeMsg"), //$NON-NLS-1$ |
|
911 | 143 |
data.getModeLabel().toLowerCase())); |
144 |
} |
|
145 |
} |
|
146 |
||
953 | 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 | 151 |
return Messages.getString("DebugRunProcessSection.CopyMsg"); //$NON-NLS-1$ |
953 | 152 |
} |
153 |
||
911 | 154 |
} |