author | dadubrow |
Mon, 18 Oct 2010 16:58:49 -0500 | |
changeset 2160 | 3a82092877ea |
parent 1576 | ceccb3d7ade9 |
child 2163 | f0a9f2d04d4a |
permissions | -rw-r--r-- |
956 | 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 |
||
22 |
import org.eclipse.core.runtime.IPath; |
|
1090 | 23 |
import org.eclipse.core.runtime.Path; |
956 | 24 |
import org.eclipse.core.runtime.Status; |
25 |
import org.eclipse.swt.widgets.Composite; |
|
26 |
import org.eclipse.swt.widgets.Shell; |
|
27 |
||
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; |
|
33 |
import com.nokia.cpp.internal.api.utils.core.PathUtils; |
|
34 |
||
35 |
/** |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class DebugRunProcessSection extends AbstractLaunchWizardSection { |
|
39 |
||
2160 | 40 |
public DebugRunProcessSection(LaunchWizardData data, AbstractUnifiedLaunchOptionsPage launchOptionsPage) { |
969 | 41 |
super(data, MessageFormat.format(Messages.getString("DebugRunProcessSection.Title"), data.getModeLabel()), launchOptionsPage); //$NON-NLS-1$ |
956 | 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); |
|
1090 | 57 |
if (data.getLaunchableExes().size() > 0) |
58 |
data.setExeSelectionPath(data.getLaunchableExes().get(0)); |
|
956 | 59 |
else if (data.getDefaultExecutable() != null) |
60 |
data.setExeSelectionPath(data.getDefaultExecutable()); |
|
1090 | 61 |
if (Path.EMPTY.equals(data.getExeSelectionPath())) |
62 |
data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); |
|
1211 | 63 |
|
956 | 64 |
ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(data.getProject()); |
1211 | 65 |
boolean hasSisInstall = false; |
956 | 66 |
if (cpi != null) { |
67 |
ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); |
|
68 |
for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { |
|
69 |
IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); |
|
70 |
data.setSisPath(sisPath.toOSString()); |
|
1211 | 71 |
if (info.isEnabled()) { |
72 |
hasSisInstall = true; |
|
73 |
break; |
|
74 |
} |
|
956 | 75 |
} |
76 |
} |
|
1211 | 77 |
|
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 | 80 |
} else { |
81 |
Boolean detectedSysTrk = data.isSysTRKConnection(); // TRUE, FALSE, or null |
|
82 |
boolean isSysTrk = detectedSysTrk == Boolean.TRUE || (detectedSysTrk == null && data.isInternalLayout()); |
|
83 |
data.setInstallPackage(hasSisInstall || !isSysTrk); |
|
84 |
} |
|
85 |
||
956 | 86 |
} |
87 |
||
88 |
@Override |
|
89 |
protected AbstractLaunchSettingsDialog createChangeSettingsDialog( |
|
90 |
Shell shell, LaunchWizardData dialogData) { |
|
91 |
return new DebugRunProcessDialog(shell, dialogData); |
|
92 |
} |
|
93 |
||
94 |
@Override |
|
95 |
protected void refresh() { |
|
96 |
updateUI(); |
|
97 |
} |
|
98 |
||
99 |
@Override |
|
100 |
protected void validate() { |
|
101 |
||
102 |
status = Status.OK_STATUS; |
|
103 |
||
104 |
switch (data.getExeSelection()) { |
|
105 |
case USE_PROJECT_EXECUTABLE: |
|
106 |
if (data.getExeSelectionPath() == null) |
|
969 | 107 |
status = error(Messages.getString("DebugRunProcessSection.NoExesError"), //$NON-NLS-1$ |
956 | 108 |
data.getModeLabel().toLowerCase()); |
109 |
break; |
|
110 |
case USE_REMOTE_EXECUTABLE: |
|
111 |
if (data.getExeSelectionPath() == null) |
|
969 | 112 |
status = error(Messages.getString("DebugRunProcessSection.NoRemoteExeError"), //$NON-NLS-1$ |
956 | 113 |
data.getModeLabel().toLowerCase()); |
114 |
break; |
|
115 |
case ATTACH_TO_PROCESS: |
|
116 |
break; |
|
117 |
} |
|
118 |
||
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 | 122 |
} |
123 |
||
124 |
@Override |
|
125 |
protected void updateUI() { |
|
126 |
||
127 |
validate(); |
|
128 |
||
129 |
if (status.isOK()) { |
|
969 | 130 |
String mainFormat = Messages.getString("DebugRunProcessSection.MainFormat"); //$NON-NLS-1$ |
131 |
String copyOrInstallMsg = ""; //$NON-NLS-1$ |
|
132 |
String runOrLaunchMsg = ""; //$NON-NLS-1$ |
|
956 | 133 |
|
134 |
switch (data.getExeSelection()) { |
|
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 | 138 |
break; |
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 | 142 |
break; |
143 |
case ATTACH_TO_PROCESS: |
|
969 | 144 |
runOrLaunchMsg = Messages.getString("DebugRunProcessSection.AttachMsg"); //$NON-NLS-1$ |
956 | 145 |
break; |
146 |
} |
|
147 |
||
148 |
copyOrInstallMsg = getCopyOrInstallMsg(); |
|
149 |
||
150 |
String runOrDebugProcessMessage = MessageFormat.format(mainFormat, copyOrInstallMsg, runOrLaunchMsg); |
|
151 |
descriptionLabel.setText(runOrDebugProcessMessage); |
|
152 |
} else { |
|
969 | 153 |
descriptionLabel.setText(status.getMessage() + "\n\n" + //$NON-NLS-1$ |
154 |
MessageFormat.format(Messages.getString("DebugRunProcessSection.ChangeMsg"), //$NON-NLS-1$ |
|
956 | 155 |
data.getModeLabel().toLowerCase())); |
156 |
} |
|
157 |
} |
|
158 |
||
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 | 163 |
return Messages.getString("DebugRunProcessSection.CopyMsg"); //$NON-NLS-1$ |
956 | 164 |
} |
165 |
||
166 |
} |